use of com.orientechnologies.orient.core.db.OPartitionedDatabasePool in project orientdb by orientechnologies.
the class OServerInfo method getDatabases.
public static void getDatabases(final OServer server, final OJSONWriter json) throws IOException {
json.beginCollection(1, true, "dbs");
if (!server.getDatabasePoolFactory().isClosed()) {
Collection<OPartitionedDatabasePool> dbPools = server.getDatabasePoolFactory().getPools();
for (OPartitionedDatabasePool pool : dbPools) {
writeField(json, 2, "db", pool.getUrl());
writeField(json, 2, "user", pool.getUserName());
json.endObject(2);
}
}
json.endCollection(1, false);
}
use of com.orientechnologies.orient.core.db.OPartitionedDatabasePool in project orientdb by orientechnologies.
the class HookInstallServerTest method test.
@Test
public void test() {
OPartitionedDatabasePool pool = new OPartitionedDatabasePool("remote:localhost/test", "admin", "admin");
for (int i = 0; i < 10; i++) {
ODatabaseDocument some = pool.acquire();
try {
some.save(new ODocument("Test").field("entry", i));
} finally {
some.close();
}
}
pool.close();
Assert.assertEquals(10, count);
}
use of com.orientechnologies.orient.core.db.OPartitionedDatabasePool in project orientdb by orientechnologies.
the class DbCreationTest method testCreateAndConnectionPool.
@Test(dependsOnMethods = "testSubFolderDbCreateConnPool")
public void testCreateAndConnectionPool() throws IOException {
ODatabaseDocument db = new ODatabaseDocumentTx(url);
db.activateOnCurrentThread();
ODatabaseHelper.dropDatabase(db, getStorageType());
ODatabaseHelper.createDatabase(db, url, getStorageType());
if (pool != null) {
pool.close();
}
pool = new OPartitionedDatabasePool(url, "admin", "admin");
// Get connection from pool
db = pool.acquire();
db.close();
// Destroy db in the back of the pool
db = new ODatabaseDocumentTx(url);
ODatabaseHelper.dropDatabase(db, getStorageType());
// Re-create it so that the db exists for the pool
db = new ODatabaseDocumentTx(url);
ODatabaseHelper.createDatabase(db, url, getStorageType());
}
use of com.orientechnologies.orient.core.db.OPartitionedDatabasePool in project orientdb by orientechnologies.
the class SQLDeleteTest method deleteInPool.
@Test
public void deleteInPool() {
OPartitionedDatabasePool pool = new OPartitionedDatabasePool(url, "admin", "admin");
ODatabaseDocumentTx db = pool.acquire();
final Long total = db.countClass("Profile");
final List<ODocument> resultset = db.query(new OSQLSynchQuery<Object>("select from Profile where sex = 'male' and salary > 120 and salary <= 133"));
final Number records = (Number) db.command(new OCommandSQL("delete from Profile where sex = 'male' and salary > 120 and salary <= 133")).execute();
Assert.assertEquals(records.intValue(), resultset.size());
Assert.assertEquals(db.countClass("Profile"), total - records.intValue());
db.close();
}
use of com.orientechnologies.orient.core.db.OPartitionedDatabasePool in project orientdb by orientechnologies.
the class CRUDDocumentPhysicalTest method testPool.
@Test
public void testPool() throws IOException {
OPartitionedDatabasePool pool = new OPartitionedDatabasePool(url, "admin", "admin");
final ODatabaseDocumentTx[] dbs = new ODatabaseDocumentTx[pool.getMaxPartitonSize()];
for (int i = 0; i < 10; ++i) {
for (int db = 0; db < dbs.length; ++db) dbs[db] = pool.acquire();
for (int db = 0; db < dbs.length; ++db) dbs[db].close();
}
pool.close();
}
Aggregations