use of com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx in project guice-persist-orient by xvik.
the class GraphPool method get.
@Override
public OrientBaseGraph get() {
if (transaction.get() == null) {
final ODatabaseDocumentTx documentDb = documentPool.get();
final OrientBaseGraph graph = transactionManager.getActiveTransactionType() == OTransaction.TXTYPE.NOTX ? new OrientGraphNoTx(documentDb) : new OrientGraph(documentDb);
transaction.set(graph);
}
final OrientBaseGraph db = transaction.get();
db.getRawGraph().activateOnCurrentThread();
return db;
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx in project guice-persist-orient by xvik.
the class OrientGraphNoTxProvider method get.
@Override
public OrientGraphNoTx get() {
final OrientBaseGraph graph = provider.get();
Preconditions.checkState(graph instanceof OrientGraphNoTx, "You must use OrientGraph within transaction or disable transaction " + "(or use OrientBaseGraph as universal solution for all cases)");
return (OrientGraphNoTx) graph;
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx in project orientdb by orientechnologies.
the class LuceneTransactionQueryTest method init.
@Before
public void init() {
final OrientVertexType c1 = new OrientGraphNoTx(db).createVertexType("C1");
c1.createProperty("p1", OType.STRING);
c1.createIndex("C1.p1", "FULLTEXT", null, null, "LUCENE", new String[] { "p1" });
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx in project orientdb by orientechnologies.
the class WWConflictAndNodeInDeadlockScenarioTest method onServerStarted.
@Override
protected void onServerStarted(ServerRun server) {
super.onServerStarted(server);
if (serverStarted++ == (2)) {
// startQueueMonitorTask();
startCountMonitorTask("Person");
// BACKUP LAST SERVER, RUN ASYNCHRONOUSLY
new Thread(new Runnable() {
@Override
public void run() {
try {
// CRASH LAST SERVER try {
executeWhen(new Callable<Boolean>() {
// CONDITION
@Override
public Boolean call() throws Exception {
return server3inDeadlock.get();
}
}, // ACTION
new Callable() {
@Override
public Object call() throws Exception {
banner("STARTING BACKUP SERVER " + (2));
OrientGraphFactory factory = new OrientGraphFactory("plocal:target/server2/databases/" + getDatabaseName());
OrientGraphNoTx g = factory.getNoTx();
backupInProgress = true;
File file = null;
try {
file = File.createTempFile("orientdb_test_backup", ".zip");
if (file.exists())
Assert.assertTrue(file.delete());
g.getRawGraph().backup(new FileOutputStream(file), null, new Callable<Object>() {
@Override
public Object call() throws Exception {
// SIMULATE LONG BACKUP UNTIL SPECIFIED BY VARIABLE 'server3inDeadlock'
while (server3inDeadlock.get()) {
Thread.sleep(1000);
}
return null;
}
}, null, 9, 1000000);
} catch (IOException e) {
e.printStackTrace();
} finally {
banner("COMPLETED BACKUP SERVER " + (2));
backupInProgress = false;
g.shutdown();
if (file != null)
file.delete();
}
return null;
}
});
} catch (Exception e) {
e.printStackTrace();
fail("Error on execution flow");
}
}
}).start();
}
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx in project orientdb by orientechnologies.
the class ConcurrentDistributedUpdateTest method executeTest.
@Override
public void executeTest() throws Exception {
OrientBaseGraph orientGraph = new OrientGraphNoTx(getPlocalDatabaseURL(serverInstance.get(0)));
OClass clazz = orientGraph.getVertexType("Test");
if (clazz == null) {
log("Creating vertex type - " + "Test");
orientGraph.createVertexType("Test");
}
orientGraph.shutdown();
OrientBaseGraph graph = new OrientGraphNoTx(getPlocalDatabaseURL(serverInstance.get(0)));
for (int i = 0; i < 2; i++) {
Vertex vertex = graph.addVertex("class:Test");
vertex.setProperty("prop1", "v1-" + i);
vertex.setProperty("prop2", "v2-1");
vertex.setProperty("prop3", "v3-1");
graph.commit();
if ((i % 100) == 0) {
log("Created " + i + " nodes");
}
}
graph.shutdown();
executeMultipleTest();
}
Aggregations