use of com.tinkerpop.blueprints.impls.orient.OrientBaseGraph in project orientdb by orientechnologies.
the class BlueprintsConcurrentGraphChangesTestNoTx method createGraphAndDeleteEdges.
protected void createGraphAndDeleteEdges() throws Exception {
OrientBaseGraph graph = getGraph();
graph.drop();
// START ADD AND REMOVE EDGES
generateVertexes();
generateEdges();
initGraph();
System.out.println("Start adding edges concurrently for further delete edges...");
addEdgesConcurrently();
System.out.println("Checking the graph...");
assertCreatedGraph();
System.out.println("Start deleting edges concurrently...");
deleteEdgesConcurrently();
System.out.println("Checking the graph...");
assertEdgesDeletedGraph();
// START TEST REMOVE VERTICES
vertexes.clear();
vertexesToCreate.clear();
edges.clear();
graph = getGraph();
graph.drop();
}
use of com.tinkerpop.blueprints.impls.orient.OrientBaseGraph in project orientdb by orientechnologies.
the class TestGraphRecovering method testRecoverPerfectGraphLW.
@Test
public void testRecoverPerfectGraphLW() {
final OrientBaseGraph g = new OrientGraphNoTx("memory:testRecoverPerfectGraphLW");
try {
init(g, true);
final TestListener eventListener = new TestListener();
new OGraphRepair().setEventListener(eventListener).repair(g, null, null);
Assert.assertEquals(eventListener.scannedEdges, 0);
Assert.assertEquals(eventListener.removedEdges, 0);
Assert.assertEquals(eventListener.scannedVertices, 3);
Assert.assertEquals(eventListener.scannedLinks, 6);
Assert.assertEquals(eventListener.removedLinks, 0);
Assert.assertEquals(eventListener.repairedVertices, 0);
} finally {
g.shutdown();
}
}
use of com.tinkerpop.blueprints.impls.orient.OrientBaseGraph in project orientdb by orientechnologies.
the class ConcurrentSQLBatchUpdateSuperNodeTest method concurrentOptimisticUpdates.
@Test(enabled = true)
public void concurrentOptimisticUpdates() throws Exception {
// System.out.println("Started Test OPTIMISTIC Batch Update against SuperNode");
counter.set(0);
startedOn = System.currentTimeMillis();
OrientBaseGraph graphPool = new OrientGraph(url);
OrientVertex superNode = graphPool.addVertex(null, "optimisticSuperNode", true);
graphPool.commit();
OptimisticThread[] ops = new OptimisticThread[THREADS];
for (int i = 0; i < THREADS; ++i) ops[i] = new OptimisticThread(url, superNode, i, "thread" + i);
Thread[] threads = new Thread[THREADS];
for (int i = 0; i < THREADS; ++i) threads[i] = new Thread(ops[i], "ConcurrentSQLBatchUpdateSuperNodeTest-optimistic" + i);
for (int i = 0; i < THREADS; ++i) threads[i].start();
for (int i = 0; i < THREADS; ++i) {
threads[i].join();
// System.out.println("Thread " + i + " completed");
}
// System.out.println("ConcurrentSQLBatchUpdateSuperNodeTest Optimistic Done! Total updates executed in parallel: "
// + counter.get() + " total retries: " + totalRetries.get() + " average retries: "
// + ((float) totalRetries.get() / (float) counter.get()));
Assert.assertEquals(counter.get(), OPTIMISTIC_CYCLES * THREADS);
OrientVertex loadedSuperNode = graphPool.getVertex(superNode.getIdentity());
for (int i = 0; i < THREADS; ++i) Assert.assertEquals(loadedSuperNode.countEdges(Direction.IN), OPTIMISTIC_CYCLES * THREADS);
graphPool.shutdown();
// System.out.println("ConcurrentSQLBatchUpdateSuperNodeTest Optimistic Test completed in "
// + (System.currentTimeMillis() - startedOn));
}
use of com.tinkerpop.blueprints.impls.orient.OrientBaseGraph in project orientdb by orientechnologies.
the class ConcurrentSQLBatchUpdateSuperNodeTest method concurrentPessimisticUpdates.
@Test(enabled = false)
public void concurrentPessimisticUpdates() throws Exception {
// System.out.println("Started Test PESSIMISTIC Batch Update against SuperNode");
counter.set(0);
startedOn = System.currentTimeMillis();
OrientBaseGraph graphPool = new OrientGraph(url);
graphPool.setThreadMode(OrientBaseGraph.THREAD_MODE.ALWAYS_AUTOSET);
OrientVertex superNode = graphPool.addVertex(null, "pessimisticSuperNode", true);
graphPool.commit();
PessimisticThread[] ops = new PessimisticThread[THREADS];
for (int i = 0; i < THREADS; ++i) ops[i] = new PessimisticThread(url, superNode, i, "thread" + i);
Thread[] threads = new Thread[THREADS];
for (int i = 0; i < THREADS; ++i) threads[i] = new Thread(ops[i], "ConcurrentSQLBatchUpdateSuperNodeTest-pessimistic" + i);
for (int i = 0; i < THREADS; ++i) threads[i].start();
for (int i = 0; i < THREADS; ++i) {
threads[i].join();
// System.out.println("Thread " + i + " completed");
}
// System.out.println("ConcurrentSQLBatchUpdateSuperNodeTest Pessimistic Done! Total updates executed in parallel: "
// + counter.get() + " average retries: " + ((float) totalRetries.get() / (float) counter.get()));
Assert.assertEquals(counter.get(), PESSIMISTIC_CYCLES * THREADS);
OrientVertex loadedSuperNode = graphPool.getVertex(superNode.getIdentity());
for (int i = 0; i < THREADS; ++i) Assert.assertEquals(loadedSuperNode.countEdges(Direction.IN), PESSIMISTIC_CYCLES * THREADS);
graphPool.shutdown();
// System.out.println("ConcurrentSQLBatchUpdateSuperNodeTest Pessimistic Test completed in "
// + (System.currentTimeMillis() - startedOn));
}
use of com.tinkerpop.blueprints.impls.orient.OrientBaseGraph in project orientdb by orientechnologies.
the class DatabaseConflictStategyTest method runTest.
public void runTest() {
OrientBaseGraph orientGraph = new OrientGraphNoTx(getDBURL());
log("Set database CONFLICTSTRATEGY to automerge");
orientGraph.command(new OCommandSQL("ALTER database CONFLICTSTRATEGY 'automerge'")).execute();
createVertexType(orientGraph, "Test");
orientGraph.shutdown();
OrientBaseGraph graph = getGraphFactory().getTx();
Vertex vertex = graph.addVertex("class:Test");
vertex.setProperty("prop1", "v1-1");
vertex.setProperty("prop2", "v2-1");
vertex.setProperty("prop3", "v3-1");
graph.shutdown();
Thread th1 = startThread(2, 1000, "prop1");
Thread th2 = startThread(3, 2000, "prop1");
Thread th3 = startThread(4, 3000, "prop1");
try {
th1.join();
th2.join();
th3.join();
} catch (Exception ex) {
ex.printStackTrace();
}
}
Aggregations