Search in sources :

Example 1 with OPartitionedDatabasePool

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);
}
Also used : OPartitionedDatabasePool(com.orientechnologies.orient.core.db.OPartitionedDatabasePool)

Example 2 with OPartitionedDatabasePool

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);
}
Also used : ODatabaseDocument(com.orientechnologies.orient.core.db.document.ODatabaseDocument) OPartitionedDatabasePool(com.orientechnologies.orient.core.db.OPartitionedDatabasePool) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.junit.Test)

Example 3 with OPartitionedDatabasePool

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());
}
Also used : ODatabaseDocument(com.orientechnologies.orient.core.db.document.ODatabaseDocument) OPartitionedDatabasePool(com.orientechnologies.orient.core.db.OPartitionedDatabasePool) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)

Example 4 with OPartitionedDatabasePool

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();
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OPartitionedDatabasePool(com.orientechnologies.orient.core.db.OPartitionedDatabasePool) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test)

Example 5 with OPartitionedDatabasePool

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();
}
Also used : OPartitionedDatabasePool(com.orientechnologies.orient.core.db.OPartitionedDatabasePool) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) Test(org.testng.annotations.Test)

Aggregations

OPartitionedDatabasePool (com.orientechnologies.orient.core.db.OPartitionedDatabasePool)17 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)11 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)5 Test (org.testng.annotations.Test)5 ORecord (com.orientechnologies.orient.core.record.ORecord)3 ODatabaseDocument (com.orientechnologies.orient.core.db.document.ODatabaseDocument)2 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)2 OSchema (com.orientechnologies.orient.core.metadata.schema.OSchema)2 ByteIterator (com.yahoo.ycsb.ByteIterator)2 StringByteIterator (com.yahoo.ycsb.StringByteIterator)2 File (java.io.File)2 Test (org.junit.Test)2 OServerAdmin (com.orientechnologies.orient.client.remote.OServerAdmin)1 OCommandOutputListener (com.orientechnologies.orient.core.command.OCommandOutputListener)1 ODatabaseCompare (com.orientechnologies.orient.core.db.tool.ODatabaseCompare)1 OEntityManager (com.orientechnologies.orient.core.entity.OEntityManager)1 OConcurrentModificationException (com.orientechnologies.orient.core.exception.OConcurrentModificationException)1 ODatabaseException (com.orientechnologies.orient.core.exception.ODatabaseException)1 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)1 OSQLSynchQuery (com.orientechnologies.orient.core.sql.query.OSQLSynchQuery)1