com.orientechnologies.orient.server.OServer Java Examples

The following examples show how to use com.orientechnologies.orient.server.OServer. 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: DatabaseFreezeServiceImpl.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
@Inject
public DatabaseFreezeServiceImpl(final Set<Provider<DatabaseInstance>> providers,
                                 final EventManager eventManager,
                                 final DatabaseFrozenStateManager databaseFrozenStateManager,
                                 final Provider<OServer> server,
                                 final NodeAccess nodeAccess,
                                 final SecurityHelper securityHelper,
                                 final List<Freezable> freezables)
{
  this.providers = checkNotNull(providers);
  this.eventManager = checkNotNull(eventManager);
  this.databaseFrozenStateManager = checkNotNull(databaseFrozenStateManager);
  checkNotNull(server);
  distributedServerManagerProvider = () -> server.get().getDistributedManager();
  this.nodeAccess = checkNotNull(nodeAccess);
  this.securityHelper = securityHelper;
  this.freezables = checkNotNull(freezables);
}
 
Example #2
Source File: OrientDbSettings.java    From wicket-orientdb with Apache License 2.0 5 votes vote down vote up
/**
 * Resolve OrientDB REST API URL to be used for OrientDb REST bridge
 * @return OrientDB REST API URL
 */
public String resolveOrientDBRestApiUrl()
{
	OrientDbWebApplication app = OrientDbWebApplication.get();
	OServer server = app.getServer();
	if(server!=null)
	{
		OServerNetworkListener http = server.getListenerByProtocol(ONetworkProtocolHttpAbstract.class);
		if(http!=null)
		{
			return "http://"+http.getListeningAddress(true);
		}
	}
	return null;
}
 
Example #3
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 #4
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 #5
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 #6
Source File: OrienteerModule.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@Provides
public OServer getOServer(WebApplication application)
{

	OrienteerWebApplication app = (OrienteerWebApplication)application;
	return app.getServer();
}
 
Example #7
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 #8
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;
}
 
Example #9
Source File: DatabaseServerImpl.java    From nexus-public with Eclipse Public License 1.0 4 votes vote down vote up
@Guarded(by = STARTED)
public OServer getOrientServer() {
  return orientServer;
}
 
Example #10
Source File: DatabaseServerImpl.java    From nexus-public with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public OServer get() {
  return databaseServer.getOrientServer();
}
 
Example #11
Source File: OrientDbWebApplication.java    From wicket-orientdb with Apache License 2.0 4 votes vote down vote up
public OServer getServer() {
	return server;
}
 
Example #12
Source File: OrientDbWebApplication.java    From wicket-orientdb with Apache License 2.0 4 votes vote down vote up
public void setServer(OServer server) {
	this.server = server;
}
 
Example #13
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();
}
 
Example #14
Source File: OLuceneIndexPlugin.java    From orientdb-lucene with Apache License 2.0 2 votes vote down vote up
@Override
public void config(OServer oServer, OServerParameterConfiguration[] iParams) {

}