Search in sources :

Example 81 with ODatabaseDocument

use of com.orientechnologies.orient.core.db.document.ODatabaseDocument 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 82 with ODatabaseDocument

use of com.orientechnologies.orient.core.db.document.ODatabaseDocument in project orientdb by orientechnologies.

the class OCRUDWorkload method check.

@Override
public void check(final ODatabaseIdentifier databaseIdentifier) {
    final ODatabaseDocument db = (ODatabaseDocument) getDocumentDatabase(databaseIdentifier, OStorageRemote.CONNECTION_STRATEGY.STICKY);
    final ODatabaseTool repair = new ODatabaseRepair().setDatabase(db);
    repair.run();
}
Also used : ODatabaseTool(com.orientechnologies.orient.core.db.tool.ODatabaseTool) ODatabaseRepair(com.orientechnologies.orient.core.db.tool.ODatabaseRepair) ODatabaseDocument(com.orientechnologies.orient.core.db.document.ODatabaseDocument)

Example 83 with ODatabaseDocument

use of com.orientechnologies.orient.core.db.document.ODatabaseDocument in project divide by HiddenStage.

the class TestUtils method setUp.

public static TestWrapper setUp() {
    TestWrapper container = new TestWrapper();
    container.time = System.nanoTime();
    container.db = new ODatabaseDocumentTx(OrientDBDao.DEFAULT_CONFIG);
    if (container.db.exists()) {
        container.db.open("admin", "admin");
    } else {
        container.db.create();
    }
    container.serverDao = new OrientDBDao((ODatabaseDocument) container.db);
    try {
        container.serverDao.query(new QueryBuilder().delete().from(Credentials.class).build());
    } catch (ServerDAO.DAOException e) {
        e.printStackTrace();
    }
    container.app = new TestApplication(container.serverDao);
    return container;
}
Also used : ServerDAO(io.divide.dao.ServerDAO) OrientDBDao(io.divide.dao.orientdb.OrientDBDao) ODatabaseDocument(com.orientechnologies.orient.core.db.document.ODatabaseDocument) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) QueryBuilder(io.divide.shared.transitory.query.QueryBuilder)

Example 84 with ODatabaseDocument

use of com.orientechnologies.orient.core.db.document.ODatabaseDocument in project orientdb by orientechnologies.

the class OOrientDBLoader method manageRemoteDatabase.

private void manageRemoteDatabase() {
    if (!dbAutoCreate && !dbAutoDropIfExists) {
        log(INFO, "nothing setup  on remote database " + dbURL);
        return;
    }
    if (NOT_DEF.equals(serverPassword) || NOT_DEF.equals(serverUser)) {
        log(ERROR, "please provide server administrator credentials");
        throw new OLoaderException("unable to manage remote db without server admin credentials");
    }
    ODatabaseDocument documentDatabase = new ODatabaseDocumentTx(dbURL);
    try {
        OServerAdmin admin = new OServerAdmin(documentDatabase.getURL()).connect(serverUser, serverPassword);
        boolean exists = admin.existsDatabase();
        if (!exists && dbAutoCreate) {
            admin.createDatabase(documentDatabase.getName(), dbType.name(), "plocal");
        } else if (exists && dbAutoDropIfExists) {
            admin.dropDatabase(documentDatabase.getName(), documentDatabase.getType());
        }
        admin.close();
    } catch (IOException e) {
        throw new OLoaderException(e);
    }
    documentDatabase.close();
}
Also used : ODatabaseDocument(com.orientechnologies.orient.core.db.document.ODatabaseDocument) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) OServerAdmin(com.orientechnologies.orient.client.remote.OServerAdmin) IOException(java.io.IOException)

Example 85 with ODatabaseDocument

use of com.orientechnologies.orient.core.db.document.ODatabaseDocument in project orientdb by orientechnologies.

the class OOrientDBLoader method load.

@Override
public void load(OETLPipeline pipeline, final Object input, OCommandContext context) {
    if (input == null)
        return;
    if (dbAutoCreateProperties) {
        autoCreateProperties(pipeline, input);
    }
    if (tx && dbType == DOCUMENT) {
        final ODatabaseDocument documentDatabase = pipeline.getDocumentDatabase();
        if (!documentDatabase.getTransaction().isActive()) {
            documentDatabase.begin();
            documentDatabase.getTransaction().setUsingLog(txUseLog);
        }
    }
    if (input instanceof OrientVertex) {
        final OrientVertex v = (OrientVertex) input;
        try {
            v.save(clusterName);
        } catch (ORecordDuplicatedException e) {
            if (skipDuplicates) {
            } else {
                throw e;
            }
        } finally {
        }
    } else if (input instanceof ODocument) {
        final ODocument doc = (ODocument) input;
        if (className != null) {
            doc.setClassName(className);
        }
        if (clusterName != null) {
            doc.save(clusterName);
        } else {
            doc.save();
        }
    }
    progress.incrementAndGet();
    // DO BATCH COMMIT
    if (batchCommitSize > 0 && batchCounter.get() > batchCommitSize) {
        if (dbType == DOCUMENT) {
            final ODatabaseDocument documentDatabase = pipeline.getDocumentDatabase();
            log(DEBUG, "committing batch");
            documentDatabase.commit();
            documentDatabase.begin();
            documentDatabase.getTransaction().setUsingLog(txUseLog);
        } else {
            log(DEBUG, "committing batch");
            pipeline.getGraphDatabase().commit();
        }
        batchCounter.set(0);
    } else {
        batchCounter.incrementAndGet();
    }
}
Also used : ODatabaseDocument(com.orientechnologies.orient.core.db.document.ODatabaseDocument) ORecordDuplicatedException(com.orientechnologies.orient.core.storage.ORecordDuplicatedException) OrientVertex(com.tinkerpop.blueprints.impls.orient.OrientVertex) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Aggregations

ODatabaseDocument (com.orientechnologies.orient.core.db.document.ODatabaseDocument)187 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)81 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)68 Test (org.testng.annotations.Test)53 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)47 ORecordId (com.orientechnologies.orient.core.id.ORecordId)23 OCommandExecutionException (com.orientechnologies.orient.core.exception.OCommandExecutionException)17 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)16 ORecord (com.orientechnologies.orient.core.record.ORecord)14 Test (org.junit.Test)14 OCommandRequestText (com.orientechnologies.orient.core.command.OCommandRequestText)12 ORID (com.orientechnologies.orient.core.id.ORID)11 OSQLSynchQuery (com.orientechnologies.orient.core.sql.query.OSQLSynchQuery)10 ODatabaseException (com.orientechnologies.orient.core.exception.ODatabaseException)9 OValidationException (com.orientechnologies.orient.core.exception.OValidationException)9 OSchema (com.orientechnologies.orient.core.metadata.schema.OSchema)9 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)9 ArrayList (java.util.ArrayList)9 OMetadataInternal (com.orientechnologies.orient.core.metadata.OMetadataInternal)8 HashSet (java.util.HashSet)8