databasePool = new OPartitionedDatabasePool(url, user, password);
/** * Creates a factory with given credentials and pool with maximum amount of connections equal to amount of CPU cores if that is * needed. * <p> * If you wish to change pool settings call com.tinkerpop.blueprints.impls.orient.OrientGraphFactory#setupPool(int, int) method. * * @param iURL to the database * @param iUser name of the user * @param iPassword of the user * @param createPool flag which indicates whether pool should be created. */ public OrientGraphFactory(final String iURL, final String iUser, final String iPassword, boolean createPool) { url = iURL; user = iUser; password = iPassword; if (createPool) pool = new OPartitionedDatabasePool(url, user, password, 8, -1).setAutoCreate(true); }
@Override protected void createPool() { //since max pool size was set, use it to create the partitioned pool int maxPartitionSize = Runtime.getRuntime().availableProcessors(); pool = new OPartitionedDatabasePool(getUrl(), getUsername(), getPassword(), maxPartitionSize, maxPoolSize); }
/** * 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; }
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; }
@Override protected void createPool() { pool = new OPartitionedDatabasePool(getUrl(), getUsername(), getPassword(), maxPoolSize, -1); }
@Override protected void createPool() { pool = new OPartitionedDatabasePool(getUrl(), getUsername(), getPassword(), maxPoolSize); }
public OPartitionedDatabasePool get(final String url, final String userName, final String userPassword) { checkForClose(); final PoolIdentity poolIdentity = new PoolIdentity(url, userName, userPassword); OPartitionedDatabasePool pool = poolStore.get(poolIdentity); if (pool != null && !pool.isClosed()) return pool; if (pool != null) poolStore.remove(poolIdentity, pool); while (true) { pool = new OPartitionedDatabasePool(url, userName, userPassword, 8, maxPoolSize); final OPartitionedDatabasePool oldPool = poolStore.putIfAbsent(poolIdentity, pool); if (oldPool != null) { if (!oldPool.isClosed()) { return oldPool; } else { poolStore.remove(poolIdentity, oldPool); } } else { return pool; } } }