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

The following examples show how to use com.orientechnologies.orient.server.OServer#shutdown() . 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: TestStandaloneOrientDBCompatibility.java    From wicket-orientdb with Apache License 2.0 5 votes vote down vote up
@Test(expected=OStorageException.class)
@Ignore
public void testMemoryDBShouldDisapear() throws Exception
{
	try
	{
		testOrientDbLifeCycle(MEMORY_DB_NAME, true, false);
		testOrientDbLifeCycle(MEMORY_DB_NAME, false, true);
	} finally
	{
		OServer server = OServerMain.server();
		if(server!=null) server.shutdown();
		Orient.instance().shutdown();
	}
}
 
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: EmbeddOrientDbApplicationListener.java    From wicket-orientdb with Apache License 2.0 4 votes vote down vote up
@Override
public void onBeforeDestroyed(Application application) {
	OrientDbWebApplication app = (OrientDbWebApplication)application;
	OServer server = app.getServer();
	if(server!=null) server.shutdown();
}