Search in sources :

Example 1 with OPartitionedDatabasePoolFactory

use of com.orientechnologies.orient.core.db.OPartitionedDatabasePoolFactory in project orientdb by orientechnologies.

the class OServer method startupFromConfiguration.

public OServer startupFromConfiguration() throws IllegalArgumentException, SecurityException, InvocationTargetException, NoSuchMethodException, IOException {
    OLogManager.instance().info(this, "OrientDB Server v" + OConstants.getVersion() + " is starting up...");
    Orient.instance();
    if (startupLatch == null)
        startupLatch = new CountDownLatch(1);
    if (shutdownLatch == null)
        shutdownLatch = new CountDownLatch(1);
    clientConnectionManager = new OClientConnectionManager(this);
    initFromConfiguration();
    if (OGlobalConfiguration.ENVIRONMENT_DUMP_CFG_AT_STARTUP.getValueAsBoolean()) {
        System.out.println("Dumping environment after server startup...");
        OGlobalConfiguration.dumpConfiguration(System.out);
    }
    dbPoolFactory = new OPartitionedDatabasePoolFactory();
    dbPoolFactory.setMaxPoolSize(contextConfiguration.getValueAsInteger(OGlobalConfiguration.DB_POOL_MAX));
    databaseDirectory = contextConfiguration.getValue("server.database.path", serverRootDirectory + "/databases/");
    databaseDirectory = OFileUtils.getPath(OSystemVariableResolver.resolveSystemVariables(databaseDirectory));
    databaseDirectory = databaseDirectory.replace("//", "/");
    // CONVERT IT TO ABSOLUTE PATH
    databaseDirectory = (new File(databaseDirectory)).getCanonicalPath();
    databaseDirectory = OFileUtils.getPath(databaseDirectory);
    if (!databaseDirectory.endsWith("/"))
        databaseDirectory += "/";
    OLogManager.instance().info(this, "Databases directory: " + new File(databaseDirectory).getAbsolutePath());
    Orient.instance().getProfiler().registerHookValue("system.databases", "List of databases configured in Server", METRIC_TYPE.TEXT, new OProfilerHookValue() {

        @Override
        public Object getValue() {
            final StringBuilder dbs = new StringBuilder(64);
            for (String dbName : getAvailableStorageNames().keySet()) {
                if (dbs.length() > 0)
                    dbs.append(',');
                dbs.append(dbName);
            }
            return dbs.toString();
        }
    });
    return this;
}
Also used : OProfilerHookValue(com.orientechnologies.common.profiler.OAbstractProfiler.OProfilerHookValue) OPartitionedDatabasePoolFactory(com.orientechnologies.orient.core.db.OPartitionedDatabasePoolFactory) CountDownLatch(java.util.concurrent.CountDownLatch) File(java.io.File)

Example 2 with OPartitionedDatabasePoolFactory

use of com.orientechnologies.orient.core.db.OPartitionedDatabasePoolFactory in project guice-persist-orient by xvik.

the class DocumentPool method start.

@Override
public void start(final String uri) {
    this.uri = uri;
    poolFactory = new OPartitionedDatabasePoolFactory();
    poolFactory.setMaxPoolSize(OGlobalConfiguration.DB_POOL_MAX.getValueAsInteger());
    // check database connection
    new ODatabaseDocumentTx(uri).open(userManager.getUser(), userManager.getPassword()).close();
    logger.debug("Pool {} started for '{}'", getType(), uri);
}
Also used : ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) OPartitionedDatabasePoolFactory(com.orientechnologies.orient.core.db.OPartitionedDatabasePoolFactory)

Example 3 with OPartitionedDatabasePoolFactory

use of com.orientechnologies.orient.core.db.OPartitionedDatabasePoolFactory in project wicket-orientdb by OrienteerBAP.

the class TestStandaloneOrientDBCompatibility method testOrientDbLifeCycle.

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) {
        ODatabaseDocument dbToDrop = new ODatabaseDocumentTx(dbURL);
        dbToDrop.open("admin", "admin");
        dbToDrop.drop();
    }
    server.shutdown();
    Orient.instance().shutdown();
// Thread.sleep(50);
}
Also used : OServer(com.orientechnologies.orient.server.OServer) ODatabaseDocument(com.orientechnologies.orient.core.db.document.ODatabaseDocument) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) OPartitionedDatabasePoolFactory(com.orientechnologies.orient.core.db.OPartitionedDatabasePoolFactory)

Aggregations

OPartitionedDatabasePoolFactory (com.orientechnologies.orient.core.db.OPartitionedDatabasePoolFactory)3 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)2 OProfilerHookValue (com.orientechnologies.common.profiler.OAbstractProfiler.OProfilerHookValue)1 ODatabaseDocument (com.orientechnologies.orient.core.db.document.ODatabaseDocument)1 OServer (com.orientechnologies.orient.server.OServer)1 File (java.io.File)1 CountDownLatch (java.util.concurrent.CountDownLatch)1