com.orientechnologies.orient.core.db.OPartitionedDatabasePool Java Examples

The following examples show how to use com.orientechnologies.orient.core.db.OPartitionedDatabasePool. 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: DatabasePoolSupport.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
protected void replaceStorage(final OPartitionedDatabasePool pool, final OStorage storage) {
  if (partitionsField != null) {
    ODatabaseDocumentInternal originalDb = ODatabaseRecordThreadLocal.instance().getIfDefined();
    try {
      // use reflection as workaround until public API is available
      for (Object partition : (Object[]) partitionsField.get(pool)) {
        for (ODatabaseDocumentTx db : (Iterable<ODatabaseDocumentTx>) partitionQueueField.get(partition)) {
          replaceStorage(db, storage);
        }
      }
    }
    catch (Exception | LinkageError e) {
      log.warn("Problem replacing storage for {}", storage.getName(), e);
    }
    finally {
      ODatabaseRecordThreadLocal.instance().set(originalDb);
    }
  }
}
 
Example #2
Source File: DatabaseManagerSupport.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
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;
}
 
Example #3
Source File: DatabasePoolWithOverflowImpl.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
public DatabasePoolWithOverflowImpl(final OPartitionedDatabasePool delegate,
                                    final OPartitionedDatabasePool overflow,
                                    final String name)
{
  super(name);
  this.delegate = checkNotNull(delegate);
  this.overflow = checkNotNull(overflow);
}
 
Example #4
Source File: TestPeopleDao.java    From thorntail with Apache License 2.0 4 votes vote down vote up
public TestPeopleDao(OPartitionedDatabasePool databasePool) {
    this.databasePool = databasePool;
}
 
Example #5
Source File: StatefulTestBean.java    From thorntail with Apache License 2.0 4 votes vote down vote up
public ClassLoader getNoSQLClassLoader() {
    return OPartitionedDatabasePool.class.getClassLoader();
}
 
Example #6
Source File: AbstractTestCase.java    From thorntail with Apache License 2.0 4 votes vote down vote up
private OPartitionedDatabasePool getDatabasePool() throws NamingException {
    return databasePool;
}
 
Example #7
Source File: DatabasePoolImpl.java    From nexus-public with Eclipse Public License 1.0 4 votes vote down vote up
public DatabasePoolImpl(final OPartitionedDatabasePool delegate, final String name) {
  super(name);
  this.delegate = checkNotNull(delegate);
}
 
Example #8
Source File: OrienteerModule.java    From Orienteer with Apache License 2.0 4 votes vote down vote up
@Provides
public OPartitionedDatabasePool getPartitionedDatabasePool(IOrientDbSettings settings) {
	OrienteerWebSession session = OrienteerWebSession.get();
	return settings.getDatabasePoolFactory().get(settings.getDBUrl(), session.getUsername(), session.getPassword());
}