use of com.tinkerpop.blueprints.impls.orient.OrientGraphFactory in project orientdb by orientechnologies.
the class ServerRun method createDatabase.
public OrientBaseGraph createDatabase(final String iName, final OCallable<Object, OrientGraphFactory> iCfgCallback) {
String dbPath = getDatabasePath(iName);
new File(dbPath).mkdirs();
OrientGraphFactory factory = new OrientGraphFactory("plocal:" + dbPath);
if (factory.exists()) {
System.out.println("Dropping previous database '" + iName + "' under: " + dbPath + "...");
new ODatabaseDocumentTx("plocal:" + dbPath).open("admin", "admin").drop();
OFileUtils.deleteRecursively(new File(dbPath));
factory.drop();
factory = new OrientGraphFactory("plocal:" + dbPath);
}
if (iCfgCallback != null)
iCfgCallback.call(factory);
System.out.println("Creating database '" + iName + "' under: " + dbPath + "...");
return factory.getNoTx();
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraphFactory in project orientdb by orientechnologies.
the class DatabaseConflictStrategyAutoMergeTest method testAutoMerge.
@Test
public void testAutoMerge() throws Throwable {
OrientGraphFactory factory = new OrientGraphFactory(CLIENT_ORIENT_URL_MAIN);
OrientBaseGraph graph = factory.getNoTx();
graph.setConflictStrategy(OAutoMergeRecordConflictStrategy.NAME);
graph.createVertexType("vertextype");
graph.createEdgeType("edgetype");
graph.shutdown();
factory.close();
Thread dbClient1 = new Thread() {
@Override
public void run() {
dbClient1();
}
};
dbClient1.start();
// Start the second DB client.
Thread dbClient2 = new Thread() {
@Override
public void run() {
dbClient2();
}
};
dbClient2.start();
dbClient1.join();
dbClient2.join();
if (exceptionInThread != null) {
throw exceptionInThread;
}
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraphFactory in project orientdb by orientechnologies.
the class OOrientDBLoader method beginLoader.
public void beginLoader(OETLPipeline pipeline) {
synchronized (this) {
ODatabaseDocument documentDatabase = null;
OrientBaseGraph graphDatabase = null;
final OrientGraphFactory factory = new OrientGraphFactory(dbURL, dbUser, dbPassword);
graphDatabase = tx ? factory.getTx() : factory.getNoTx();
graphDatabase.setUseLightweightEdges(useLightweightEdges);
graphDatabase.setStandardElementConstraints(standardElementConstraints);
documentDatabase = graphDatabase.getRawGraph();
pipeline.setDocumentDatabase(documentDatabase);
pipeline.setGraphDatabase(graphDatabase);
createSchema(pipeline, documentDatabase);
documentDatabase.getMetadata().getSchema().reload();
documentDatabase.declareIntent(new OIntentMassiveInsert());
}
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraphFactory in project orientdb by orientechnologies.
the class OOrientDBLoader method configureGraphDB.
private void configureGraphDB() {
OrientGraphFactory factory = new OrientGraphFactory(dbURL, dbUser, dbPassword);
if (dbAutoDropIfExists && factory.exists()) {
log(INFO, "Dropping existent database '%s'...", dbURL);
factory.drop();
}
if (!factory.exists()) {
factory = new OrientGraphFactory(dbURL, dbUser, dbPassword);
}
final OrientBaseGraph graphDatabase = tx ? factory.getTx() : factory.getNoTx();
graphDatabase.shutdown();
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraphFactory in project orientdb by orientechnologies.
the class GraphValidationTest method fail.
@Test
public void fail() {
setupSchema();
final OrientGraphFactory orientGraphFactory = new OrientGraphFactory(URL, "admin", "admin").setupPool(1, 10);
OrientGraph graph = orientGraphFactory.getTx();
try {
graph.addVertex("class:M", "name", "n0");
try {
graph.addVertex("class:M");
graph.commit();
// This is what happens => not OK?
throw new RuntimeException("Schema problem was not detected!");
} catch (OValidationException e) {
System.out.println("This is the Message I want to see: \n" + e);
}
} finally {
graph.shutdown();
}
}
Aggregations