Java Code Examples for com.orientechnologies.orient.core.config.OGlobalConfiguration

The following examples show how to use com.orientechnologies.orient.core.config.OGlobalConfiguration. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: orientdb-etl   Source File: OEdgeTransformerTest.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void setUp() {
  OGlobalConfiguration.USE_WAL.setValue(true);

  super.setUp();
  final OrientVertexType v1 = graph.createVertexType("V1");
  final OrientVertexType v2 = graph.createVertexType("V2");

  final OrientEdgeType edgeType = graph.createEdgeType("Friend");
  edgeType.createProperty("in", OType.LINK, v2);
  edgeType.createProperty("out", OType.LINK, v1);

  // ASSURE NOT DUPLICATES
  edgeType.createIndex("out_in", OClass.INDEX_TYPE.UNIQUE, "in", "out");

  graph.addVertex("class:V2").setProperty("name", "Luca");
  graph.commit();
}
 
Example 2
Source Project: graphdb-benchmarks   Source File: OrientMassiveInsertion.java    License: Apache License 2.0 6 votes vote down vote up
public OrientMassiveInsertion(final String url)
{
    super(GraphDatabaseType.ORIENT_DB, null /* resultsPath */);
    OGlobalConfiguration.ENVIRONMENT_CONCURRENT.setValue(false);
    OrientGraphNoTx transactionlessGraph = new OrientGraphNoTx(url);
    for (int i = 0; i < NUMBER_OF_ORIENT_CLUSTERS; ++i)
    {
        transactionlessGraph.getVertexBaseType().addCluster("v_" + i);
        transactionlessGraph.getEdgeBaseType().addCluster("e_" + i);
    }
    transactionlessGraph.shutdown();

    graph = new OGraphBatchInsertBasic(url);
    graph.setAverageEdgeNumberPerNode(AVERAGE_NUMBER_OF_EDGES_PER_NODE);
    graph.setEstimatedEntries(ESTIMATED_ENTRIES);
    graph.setIdPropertyName("nodeId");
    graph.begin();
}
 
Example 3
Source Project: bjoern   Source File: CSVImporter.java    License: GNU General Public License v3.0 5 votes vote down vote up
protected void openNoTxForMassiveInsert()
{
	OGlobalConfiguration.USE_WAL.setValue(false);
	OGlobalConfiguration.WAL_SYNC_ON_PAGE_FLUSH.setValue(false);

	noTx = new OrientGraphNoTx(
			"plocal:" + System.getProperty("ORIENTDB_HOME") + "/databases/" + dbName);
	noTx.declareIntent(new OIntentMassiveInsert());
}
 
Example 4
Source Project: orientdb-etl   Source File: OVertexTransformerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
  super.setUp();
  OGlobalConfiguration.USE_WAL.setValue(true);

  graph.createVertexType("Person");
  graph.createKeyIndex("name", Vertex.class, new Parameter<String, String>("type", "UNIQUE"), new Parameter<String, String>(
      "class", "Person"));
  graph.commit();
}
 
Example 5
Source Project: orientdb-lucene   Source File: OLuceneIndexEngine.java    License: Apache License 2.0 5 votes vote down vote up
public OLuceneIndexEngine(OLuceneIndexManagerAbstract delegate, String indexType) {
  super(OGlobalConfiguration.ENVIRONMENT_CONCURRENT.getValueAsBoolean(), OGlobalConfiguration.MVRBTREE_TIMEOUT
      .getValueAsInteger(), true);

  this.lucene = delegate;
  this.indexType = indexType;
}
 
Example 6
Source Project: light   Source File: ServiceLocator.java    License: Apache License 2.0 5 votes vote down vote up
public OrientGraphFactory getFactory() {
    if(factory == null) {
        factory = new OrientGraphFactory(getDbUrl()).setupPool(1,100);
        OGlobalConfiguration.RID_BAG_EMBEDDED_TO_SBTREEBONSAI_THRESHOLD.setValue(-1);
    }
    return factory;
}
 
Example 7
Source Project: graphdb-benchmarks   Source File: OrientGraphDatabase.java    License: Apache License 2.0 5 votes vote down vote up
public OrientGraphDatabase(BenchmarkConfiguration config, File dbStorageDirectoryIn)
{
    super(GraphDatabaseType.ORIENT_DB, dbStorageDirectoryIn);
    OGlobalConfiguration.STORAGE_COMPRESSION_METHOD.setValue("nothing");
    this.useLightWeightEdges = config.orientLightweightEdges() == null ? true : config.orientLightweightEdges()
        .booleanValue();
}
 
Example 8
Source Project: graphdb-benchmarks   Source File: OrientGraphDatabase.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public void createGraphForSingleLoad()
{
    OGlobalConfiguration.STORAGE_KEEP_OPEN.setValue(false);
    graph = getGraph(dbStorageDirectory);
    createSchema();
}
 
Example 9
Source Project: graphdb-benchmarks   Source File: OrientGraphDatabase.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public void createGraphForMassiveLoad()
{
    OGlobalConfiguration.STORAGE_KEEP_OPEN.setValue(false);
    graph = getGraph(dbStorageDirectory);
    createSchema();
}
 
Example 10
/**
 * Tests configuring the server w/o xml but configuring the JAXB objects directly.
 */
@SuppressWarnings("java:S2699") //sonar wants assertions, but this test is not run in CI
@Test
public void embeddedServerProgrammatic() throws Exception {
  File homeDir = util.createTempDir("orientdb-home").getCanonicalFile();
  System.setProperty("orient.home", homeDir.getPath());
  System.setProperty(Orient.ORIENTDB_HOME, homeDir.getPath());

  OServer server = new OServer();
  OServerConfiguration config = new OServerConfiguration();

  // Unsure what this is used for, its apparently assigned to xml location, but forcing it here
  config.location = "DYNAMIC-CONFIGURATION";

  File databaseDir = new File(homeDir, "db");
  config.properties = new OServerEntryConfiguration[] {
      new OServerEntryConfiguration("server.database.path", databaseDir.getPath())
  };

  config.handlers = Lists.newArrayList();

  config.hooks = Lists.newArrayList();

  config.network = new OServerNetworkConfiguration();
  config.network.protocols = Lists.newArrayList(
      new OServerNetworkProtocolConfiguration("binary", ONetworkProtocolBinary.class.getName())
  );

  OServerNetworkListenerConfiguration binaryListener = new OServerNetworkListenerConfiguration();
  binaryListener.ipAddress = "0.0.0.0";
  binaryListener.portRange = "2424-2430";
  binaryListener.protocol = "binary";
  binaryListener.socket = "default";

  config.network.listeners = Lists.newArrayList(
      binaryListener
  );

  config.storages = new OServerStorageConfiguration[] {};

  config.users = new OServerUserConfiguration[] {
      new OServerUserConfiguration("admin", "admin", "*")
  };

  config.security = new OServerSecurityConfiguration();
  config.security.users = Lists.newArrayList();
  config.security.resources = Lists.newArrayList();

  server.startup(config);

  // Dump config to log stream
  StringWriter buff = new StringWriter();
  OGlobalConfiguration.dumpConfiguration(new PrintStream(new WriterOutputStream(buff), true));
  log("Global configuration:\n{}", buff);

  server.activate();
  server.shutdown();
}
 
Example 11
Source Project: nexus-public   Source File: DatabaseServerImpl.java    License: Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected void doStart() throws Exception {

  // global startup
  Orient.instance().startup();

  // instance startup
  OServer server = new OServer(false)
  {
    @Override
    public Map<String, String> getAvailableStorageNames() {
      return getExistingDatabaseUrls();
    }
  };

  configureOrientMinimumLogLevel();
  server.setExtensionClassLoader(uberClassLoader);
  OServerConfiguration config = createConfiguration();
  server.startup(config);

  // remove Orient shutdown-hooks added during startup, we'll manage shutdown ourselves
  Orient.instance().removeShutdownHook();
  server.removeShutdownHook();

  // create default root user to avoid orientdb prompt on console
  server.addUser(OServerConfiguration.DEFAULT_ROOT_USER, null, "*");

  // Log global configuration
  if (log.isDebugEnabled()) {
    // dumpConfiguration() only accepts ancient stream api
    String encoding = StandardCharsets.UTF_8.name();
    ByteArrayOutputStream buff = new ByteArrayOutputStream();
    OGlobalConfiguration.dumpConfiguration(new PrintStream(buff, true, encoding));
    log.debug("Global configuration:\n{}", new String(buff.toByteArray(), encoding));
  }

  Orient.instance().addDbLifecycleListener(entityHook);

  server.activate();
  log.info("Activated");

  this.orientServer = server;
}
 
Example 12
Source Project: nexus-public   Source File: DatabaseServerImpl.java    License: Eclipse Public License 1.0 4 votes vote down vote up
private OServerConfiguration createConfiguration() {
  File configDir = applicationDirectories.getConfigDirectory("fabric");

  // FIXME: Unsure what this directory is used for
  File orientDir = applicationDirectories.getWorkDirectory("orient");
  System.setProperty("orient.home", orientDir.getPath());
  System.setProperty(Orient.ORIENTDB_HOME, orientDir.getPath());

  OServerConfiguration config = new OServerConfiguration();

  // FIXME: Unsure what this is used for, its apparently assigned to xml location, but forcing it here
  config.location = "DYNAMIC-CONFIGURATION";

  File securityFile = new File(configDir, "orientdb-security.json");

  config.properties = new OServerEntryConfiguration[]{
      new OServerEntryConfiguration("server.database.path", databasesDir.getPath()),
      new OServerEntryConfiguration("server.security.file", securityFile.getPath()),
      new OServerEntryConfiguration("plugin.dynamic", String.valueOf(dynamicPlugins))
  };

  config.handlers = new ArrayList<>(injectedHandlers);
  config.hooks = new ArrayList<>();

  config.network = new OServerNetworkConfiguration();
  config.network.protocols = Lists.newArrayList(
      new OServerNetworkProtocolConfiguration("binary", ONetworkProtocolBinary.class.getName()),
      new OServerNetworkProtocolConfiguration("http", ONetworkProtocolHttpDb.class.getName())
  );

  config.network.listeners = new ArrayList<>();

  OServerNetworkListenerConfiguration binaryListener = null, httpListener = null;

  if (binaryListenerEnabled) {
    binaryListener = createBinaryListener(binaryPortRange);
    config.network.listeners.add(binaryListener);
  }

  if (httpListenerEnabled) {
    httpListener = createHttpListener(httpPortRange);
    config.network.listeners.add(httpListener);
  }

  config.storages = new OServerStorageConfiguration[]{};

  config.users = new OServerUserConfiguration[]{
      new OServerUserConfiguration("admin", "admin", "*")
  };

  config.security = new OServerSecurityConfiguration();
  config.security.users = new ArrayList<>();
  config.security.resources = new ArrayList<>();

  // latest advice is to disable DB compression as it doesn't buy much,
  // also snappy has issues with use of native lib (unpacked under tmp)
  OGlobalConfiguration.STORAGE_COMPRESSION_METHOD.setValue("nothing");
  
  // ensure we don't set a file lock, which can behave badly on NFS https://issues.sonatype.org/browse/NEXUS-11289
  OGlobalConfiguration.FILE_LOCK.setValue(false);

  // disable auto removal of servers, SharedHazelcastPlugin removes gracefully shutdown nodes but for crashes and
  // especially network partitions we don't want the write quorum getting lowered and endanger consistency 
  OGlobalConfiguration.DISTRIBUTED_AUTO_REMOVE_OFFLINE_SERVERS.setValue(-1);

  // Apply customizations to server configuration
  configCustomizers.forEach((it) -> it.apply(config));

  if (binaryListener != null) {
    log.info("Binary listener enabled: {}:[{}]", binaryListener.ipAddress, binaryListener.portRange);
  }

  if (httpListener != null) {
    log.info("HTTP listener enabled: {}:[{}]", httpListener.ipAddress, httpListener.portRange);
  }

  return config;
}
 
Example 13
Source Project: orientdb-etl   Source File: OOrientDBLoader.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void configure(final OETLProcessor iProcessor, final ODocument iConfiguration, final OCommandContext iContext) {
  super.configure(iProcessor, iConfiguration, iContext);

  if (iConfiguration.containsField("dbURL"))
    dbURL = (String) resolve(iConfiguration.field("dbURL"));
  if (iConfiguration.containsField("dbUser"))
    dbUser = (String) resolve(iConfiguration.field("dbUser"));
  if (iConfiguration.containsField("dbPassword"))
    dbPassword = (String) resolve(iConfiguration.field("dbPassword"));
  if (iConfiguration.containsField("dbType"))
    dbType = DB_TYPE.valueOf(iConfiguration.field("dbType").toString().toUpperCase());
  if (iConfiguration.containsField("tx"))
    tx = (Boolean) iConfiguration.field("tx");
  if (iConfiguration.containsField("wal"))
    wal = (Boolean) iConfiguration.field("wal");
  if (iConfiguration.containsField("txUseLog"))
    txUseLog = (Boolean) iConfiguration.field("txUseLog");
  if (iConfiguration.containsField("batchCommit"))
    batchCommit = (Integer) iConfiguration.field("batchCommit");
  if (iConfiguration.containsField("dbAutoCreate"))
    dbAutoCreate = (Boolean) iConfiguration.field("dbAutoCreate");
  if (iConfiguration.containsField("dbAutoDropIfExists"))
    dbAutoDropIfExists = (Boolean) iConfiguration.field("dbAutoDropIfExists");
  if (iConfiguration.containsField("dbAutoCreateProperties"))
    dbAutoCreateProperties = (Boolean) iConfiguration.field("dbAutoCreateProperties");
  if (iConfiguration.containsField("useLightweightEdges"))
    useLightweightEdges = (Boolean) iConfiguration.field("useLightweightEdges");
  if (iConfiguration.containsField("standardElementConstraints"))
    standardElementConstraints = (Boolean) iConfiguration.field("standardElementConstraints");

  clusterName = iConfiguration.field("cluster");
  className = iConfiguration.field("class");
  indexes = iConfiguration.field("indexes");
  classes = iConfiguration.field("classes");

  if (iConfiguration.containsField("settings")) {
    final ODocument settings = (ODocument) iConfiguration.field("settings");
    settings.setAllowChainedAccess(false);
    for (String s : settings.fieldNames()) {
      final OGlobalConfiguration v = OGlobalConfiguration.findByKey(s);
      if (v != null)
        v.setValue(settings.field(s));
    }
  }

  if (!wal)
    OGlobalConfiguration.USE_WAL.setValue(wal);

  switch (dbType) {
  case DOCUMENT:
    final ODatabaseDocumentTx documentDatabase = new ODatabaseDocumentTx(dbURL);
    if (documentDatabase.exists() && dbAutoDropIfExists) {
      log(OETLProcessor.LOG_LEVELS.INFO, "Dropping existent database '%s'...", dbURL);
      documentDatabase.open(dbUser, dbPassword);
      documentDatabase.drop();
    }

    if (documentDatabase.exists()) {
      log(OETLProcessor.LOG_LEVELS.DEBUG, "Opening database '%s'...", dbURL);
      documentDatabase.open(dbUser, dbPassword);
    } else if (dbAutoCreate) {
      documentDatabase.create();
    } else
      throw new IllegalArgumentException("Database '" + dbURL + "' not exists and 'dbAutoCreate' setting is false");

    documentDatabase.close();
    break;

  case GRAPH:
    final OrientGraphFactory factory = new OrientGraphFactory(dbURL, dbUser, dbPassword);
    if (dbAutoDropIfExists && factory.exists()) {
      log(OETLProcessor.LOG_LEVELS.INFO, "Dropping existent database '%s'...", dbURL);
      factory.drop();
    }

    final OrientBaseGraph graphDatabase = tx ? factory.getTx() : factory.getNoTx();
    graphDatabase.shutdown();
    break;
  }
}
 
Example 14
public OLuceneIndexManagerAbstract() {
  super(OGlobalConfiguration.ENVIRONMENT_CONCURRENT.getValueAsBoolean(), OGlobalConfiguration.MVRBTREE_TIMEOUT
      .getValueAsInteger(), true);
  Orient.instance().registerListener(this);
}
 
Example 15
Source Project: light   Source File: LightServer.java    License: Apache License 2.0 4 votes vote down vote up
static public void start() {
    // hosts and server configuration
    Map<String, Object> hostConfigMap = ServiceLocator.getInstance().getJsonMapConfig(ServiceLocator.HOST_CONFIG);
    Map<String, Object> serverConfigMap = ServiceLocator.getInstance().getJsonMapConfig(ServiceLocator.SERVER_CONFIG);

    OrientGraphFactory factory = ServiceLocator.getInstance().getFactory();
    // check if database exists, if not create it and init it.
    if(!factory.exists()) {
        try {
            OrientBaseGraph g = new OrientGraph(ServiceLocator.getInstance().getDbUrl());
            // database is auto created
            g.command(new OCommandSQL("alter database custom useLightweightEdges=true")).execute();
            g.command(new OCommandSQL("alter database DATETIMEFORMAT yyyy-MM-dd'T'HH:mm:ss.SSS")).execute();
            g.command(new OCommandSQL("alter database TIMEZONE UTC")).execute();
            OGlobalConfiguration.RID_BAG_EMBEDDED_TO_SBTREEBONSAI_THRESHOLD.setValue(-1);
        } finally {
            // this also closes the OrientGraph instances created by the factory
            // Note that OrientGraphFactory does not implement Closeable
            factory.close();
        }
        InitDatabase.initDb();
        // load rule compileCache here
        AbstractRuleRule.loadCompileCache();
        // replay all the event to create database image.
        // TODO need to rethink replay as orientdb is used instead of Memory Image.
        replayEvent();
    } else {
        // load rule compileCache here
        AbstractRuleRule.loadCompileCache();
    }

    NameVirtualHostHandler virtualHostHandler = new NameVirtualHostHandler();
    Iterator<String> it = hostConfigMap.keySet().iterator();
    while (it.hasNext()) {
        String host = it.next();
        Map<String, String> hostPropMap = (Map<String, String>)hostConfigMap.get(host);
        String base = hostPropMap.get("base");
        String transferMinSize = hostPropMap.get("transferMinSize");
        virtualHostHandler
                .addHost(
                        host,
                        Handlers.predicates(
                            PredicatedHandlersParser.parse("not path-prefix('/images', '/assets', '/api') -> rewrite('/index.html')"
                            //PredicatedHandlersParser.parse("not path-suffix['.js', '.html', '.css'] -> rewrite['/index.html']"
                            //PredicatedHandlersParser.parse("path-prefix['/home', '/page', '/form'] -> rewrite['/index.html']"
                            , LightServer.class.getClassLoader()),
                                new PathHandler(resource(new FileResourceManager(
                                        new File(base), Integer
                                        .valueOf(transferMinSize))))
                                        .addPrefixPath("/api/rs",
                                                new EagerFormParsingHandler().setNext(
                                                        new RestHandler()))
                                        .addPrefixPath("/api/ws",
                                                websocket(new WebSocketHandler()))
                        ));
    }
    String ip = (String)serverConfigMap.get("ip");
    String port = (String)serverConfigMap.get("port");
    server = Undertow
            .builder()
            .addHttpListener(Integer.valueOf(port), ip)
            .setBufferSize(1024 * 16)
            .setServerOption(UndertowOptions.ALWAYS_SET_KEEP_ALIVE, false)
            .setHandler(
                    Handlers.header(virtualHostHandler,
                            Headers.SERVER_STRING, "LIGHT"))
            .setWorkerThreads(200).build();
    server.start();

}