@Override public void cleanup() throws DBException { INIT_LOCK.lock(); try { clientCounter--; if (clientCounter == 0) { databasePool.close(); databasePool = null; initialized = false; } } finally { INIT_LOCK.unlock(); } }
@Override public void onEviction( final PoolIdentity poolIdentity, final OPartitionedDatabasePool partitionedDatabasePool) { partitionedDatabasePool .close(); } };
/** * Closes all pooled databases and clear the pool. */ public void close() { if (pool != null) pool.close(); pool = null; }
@Override public void onShutdown() { close(); }
@Override protected void doStop() throws Exception { delegate.close(); }
/** * {@inheritDoc} * Releases resources which have been used dataStore. Eg:- OrientDB Client connection pool. */ @Override public void close() { docBatch.clear(); remoteServerAdmin.close(); connectionPool.close(); }
public void destroy() { try { if (!this.pool.isClosed()) { this.pool.close(); } } catch (Throwable t) { LOG.error(t.getMessage(), t); } finally { isClosed = true; } }
/** * Setting up the factory to use database pool instead of creation a new instance of database connection each time. * * @param iMin minimum size of pool * @param iMax maximum size of pool * * @return this */ public OrientGraphFactory setupPool(final int iMin, final int iMax) { if (pool != null) { pool.close(); } pool = new OPartitionedDatabasePool(url, user, password, 8, iMax).setAutoCreate(true); properties.entrySet().forEach(p -> pool.setProperty(p.getKey(), p.getValue())); return this; }
public void reset() { while (!poolStore.isEmpty()) { final Iterator<OPartitionedDatabasePool> poolIterator = poolStore.values().iterator(); while (poolIterator.hasNext()) { final OPartitionedDatabasePool pool = poolIterator.next(); try { pool.close(); } catch (Exception e) { OLogManager.instance().error(this, "Error during pool close", e); } poolIterator.remove(); } } for (OPartitionedDatabasePool pool : poolStore.values()) pool.close(); poolStore.clear(); }
private static volatile int schemaVersion = -1; private OPartitionedDatabasePool pool; protected void createPool() { pool = new OPartitionedDatabasePool(getUrl(), getUsername(), getPassword()); } @Override public synchronized ODatabaseDocumentTx openDatabase() { ODatabaseDocumentTx db = pool.acquire(); //DatabaseInfo is a simple class put in a static contect that holds the schema version. DatabaseInfo databaseInfo = CurrentDatabaseInfo.getDatabaseInfo(); ODocument document = db.load((ORID) databaseInfo.getId(), "schemaVersion:0", true); Integer version = document.field("schemaVersion"); if (schemaVersion == -1) { schemaVersion = version; } else if (schemaVersion < version) { db.getMetadata().getSchema().reload(); schemaVersion = version; pool.close(); createPool(); db = pool.acquire(); } return db; }
pool.close();