Java Code Examples for com.orientechnologies.orient.server.OServer#activate()

The following examples show how to use com.orientechnologies.orient.server.OServer#activate() . 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 File: EmbeddOrientDbApplicationListener.java    From wicket-orientdb with Apache License 2.0 5 votes vote down vote up
@Override
public void onAfterInitialized(Application application) {
	try {
		OrientDbWebApplication app = (OrientDbWebApplication)application;
		OServer server = OServerMain.create(false);
		if(url!=null)
		{
			server.startup(url.openStream());
		}
		else if(configFile!=null)
		{
			server.startup(configFile);
		}
		else if(config!=null)
		{
			server.startup(config);
		}
		else if(serverConfiguration!=null)
		{
			server.startup(serverConfiguration);
		}
		else
		{
			server.startup();
		}
		server.activate();
		server.removeShutdownHook();
		app.setServer(server);
		app.getOrientDbSettings().setDatabasePoolFactory(server.getDatabasePoolFactory());
		onAfterServerStartupAndActivation(app);
	} catch (Exception e) {
		throw new WicketRuntimeException("Can't start OrientDB Embedded Server", e);
	}
}
 
Example 2
Source File: TestStandaloneOrientDBCompatibility.java    From wicket-orientdb with Apache License 2.0 5 votes vote down vote up
public void testOrientDbLifeCycle(String dbURL, boolean createDb, boolean dropDb) throws Exception
	{
		Orient.instance().startup();
		assertNotNull(ODatabaseRecordThreadLocal.instance());
		Orient.instance().removeShutdownHook();
		OServer server = OServerMain.create();
		server.startup(OrientDbTestWebApplication.class.getResource("db.config.xml").openStream());
		server.activate();
		if(createDb)
		{
			ODatabaseDocument dbToCreate = new ODatabaseDocumentTx(dbURL);
			if(!dbToCreate.exists()) dbToCreate.create();
			dbToCreate.close();
		}
		assertNotNull(ODatabaseRecordThreadLocal.instance());
		ODatabaseDocument db = new OPartitionedDatabasePoolFactory().get(dbURL, "admin", "admin").acquire();
		db.close();
		assertNotNull(ODatabaseRecordThreadLocal.instance());
		if(dropDb)
		{
			@SuppressWarnings("resource")
			ODatabaseDocument dbToDrop = new ODatabaseDocumentTx(dbURL);
			dbToDrop.open("admin", "admin");
			dbToDrop.drop();
		}
		server.shutdown();
		Orient.instance().shutdown();
//		Thread.sleep(50);
	}
 
Example 3
Source File: OrientDbEmbeddedTrial.java    From nexus-public with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * 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 4
Source File: DatabaseServerImpl.java    From nexus-public with 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;
}