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());
}
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();
}
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;
}
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();
}
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();
}
}
Aggregations