Java源码示例:com.orientechnologies.orient.core.db.OPartitionedDatabasePool

示例1
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);
    }
  }
}
 
示例2
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;
}
 
示例3
public DatabasePoolWithOverflowImpl(final OPartitionedDatabasePool delegate,
                                    final OPartitionedDatabasePool overflow,
                                    final String name)
{
  super(name);
  this.delegate = checkNotNull(delegate);
  this.overflow = checkNotNull(overflow);
}
 
示例4
public TestPeopleDao(OPartitionedDatabasePool databasePool) {
    this.databasePool = databasePool;
}
 
示例5
public ClassLoader getNoSQLClassLoader() {
    return OPartitionedDatabasePool.class.getClassLoader();
}
 
示例6
private OPartitionedDatabasePool getDatabasePool() throws NamingException {
    return databasePool;
}
 
示例7
public DatabasePoolImpl(final OPartitionedDatabasePool delegate, final String name) {
  super(name);
  this.delegate = checkNotNull(delegate);
}
 
示例8
@Provides
public OPartitionedDatabasePool getPartitionedDatabasePool(IOrientDbSettings settings) {
	OrienteerWebSession session = OrienteerWebSession.get();
	return settings.getDatabasePoolFactory().get(settings.getDBUrl(), session.getUsername(), session.getPassword());
}