/** * Start given component if it implements {@link Lifecycle} or {@link LifecycleAware}. * * @see #start(Lifecycle) * @see #start(LifecycleAware) */ public static void start(final Object component) { if (component instanceof Lifecycle) { start((Lifecycle) component); } else if (component instanceof LifecycleAware) { start((LifecycleAware) component); } else { log.warn("Unable to start component; not a lifecycle: {}", component); } }
/** * Start given lifecycle-aware and propagate exceptions. * * @see #start(Lifecycle) */ public static void start(final LifecycleAware component) { checkNotNull(component); start(component.getLifecycle()); }
@Override protected void doStart() throws Exception { nodeAccess.start(); databaseServer.get().start(); Lifecycles.start(databaseManager.get()); }
private DatabaseInstanceImpl createInstance(final String name) { DatabaseInstanceImpl instance; final Logger explainLogger = LoggerFactory.getLogger(EXPLAIN_PREFIX + name); if (explainLogger.isDebugEnabled()) { instance = new DatabaseInstanceImpl(this, name) { @Override public ODatabaseDocumentTx acquire() { String uri = connectionUri(name); ODatabaseDocumentTx db = new ExplainODatabaseDocumentTx(uri, explainLogger); db.open(SYSTEM_USER, SYSTEM_PASSWORD); return db; } }; } else { instance = new DatabaseInstanceImpl(this, name); } Lifecycles.start(instance); log.debug("Created database instance: {}", instance); return instance; }
private DatabasePoolSupport createPool(final String name) { String uri = connectionUri(name); // primary pool for this DB which may have a per-core limit or an overall limit OPartitionedDatabasePool underlying = new OPartitionedDatabasePool( uri, SYSTEM_USER, SYSTEM_PASSWORD, maxConnectionsPerCore, maxConnections); DatabasePoolSupport pool; if (maxConnections > 0) { // when there's an overall limit Orient will use a single partition // and block any pending requests when there's no connections left log.info("Configuring OrientDB pool {} with overall limit of {}", name, maxConnections); pool = new DatabasePoolImpl(underlying, name); } else if (maxConnectionsPerCore > 0) { // otherwise Orient uses a partition per-core which throws an ISE when // there are no connections left in the partition - to fall back to the // original blocking behaviour we add an overflow with an overall limit // the same as the per-core limit OPartitionedDatabasePool overflow = new OPartitionedDatabasePool( uri, SYSTEM_USER, SYSTEM_PASSWORD, -1 /* unused */, maxConnectionsPerCore); log.info("Configuring OrientDB pool {} with per-core limit of {}", name, maxConnectionsPerCore); pool = new DatabasePoolWithOverflowImpl(underlying, overflow, name); } else { throw new IllegalArgumentException( "Either " + MAX_CONNECTIONS_PER_CORE_PROPERTY + " or " + MAX_CONNECTIONS_PROPERTY + " must be positive"); } Lifecycles.start(pool); return pool; }