use of com.tinkerpop.blueprints.impls.orient.OrientBaseGraph in project orientdb by orientechnologies.
the class TestAsyncReplMode2Servers method dbClient1.
protected void dbClient1() {
OGlobalConfiguration.LOG_CONSOLE_LEVEL.setValue("FINEST");
synchronized (LOCK) {
OrientBaseGraph graph = new OrientGraph(getRemoteURL());
try {
OrientVertex parentV1 = graph.addVertex("vertextype", (String) null);
graph.commit();
assertEquals(1, parentV1.getRecord().getVersion());
parentV1Id = parentV1.getId();
OrientVertex parentV2 = graph.addVertex("vertextype", (String) null);
graph.commit();
assertEquals(1, parentV2.getRecord().getVersion());
parentV2Id = parentV2.getId();
int countPropValue = 0;
for (int i = 0; i < NUM_OF_LOOP_ITERATIONS; i++) {
pause();
if (exceptionInThread != null)
break;
for (int attempt = 0; attempt < NUM_OF_RETRIES; attempt++) {
try {
parentV1.setProperty(CNT_PROP_NAME, ++countPropValue);
graph.commit();
System.out.println("Committing parentV1" + parentV1.getRecord() + "...");
break;
} catch (OConcurrentModificationException c) {
graph.rollback();
parentV1.reload();
}
}
for (int attempt = 0; attempt < NUM_OF_RETRIES; attempt++) {
try {
parentV2.setProperty(CNT_PROP_NAME, countPropValue);
graph.commit();
System.out.println("Committing parentV2" + parentV2.getRecord() + "...");
break;
} catch (OConcurrentModificationException c) {
graph.rollback();
parentV2.reload();
}
}
}
} catch (Throwable e) {
if (exceptionInThread == null) {
exceptionInThread = e;
}
} finally {
System.out.println("Shutting down");
graph.shutdown();
LOCK.notifyAll();
}
}
}
use of com.tinkerpop.blueprints.impls.orient.OrientBaseGraph in project orientdb by orientechnologies.
the class TestAsyncReplMode2Servers2OpsCommitConcurrent method exec.
protected void exec(final String iClient) {
counter.countDown();
try {
counter.await();
} catch (InterruptedException e) {
e.printStackTrace();
}
OrientBaseGraph graph = new OrientGraph(getLocalURL());
OrientVertex vertex1 = graph.getVertex(vertex1Id);
final AtomicInteger conflicts = new AtomicInteger(0);
try {
int i = 0;
for (; i < TOTAL; ++i) {
for (int retry = 0; retry < 20; ++retry) {
try {
OrientVertex vertex2 = graph.addVertex("vertextype", (String) null);
vertex1.addEdge("edgetype", vertex2);
graph.commit();
break;
} catch (ONeedRetryException e) {
System.out.println(iClient + " - caught conflict, reloading vertex. v=" + vertex1.getRecord().getVersion() + " retry: " + retry + " conflicts so far: " + conflicts.get());
graph.rollback();
vertex1.reload();
conflicts.incrementAndGet();
}
}
}
// STATISTICALLY HERE AT LEAST ONE CONFLICT HAS BEEN RECEIVED
vertex1.reload();
Assert.assertTrue("No conflicts recorded. conflicts=" + conflicts.get(), conflicts.get() > 0);
Assert.assertEquals(TOTAL, i);
} catch (Throwable e) {
if (exceptionInThread == null)
exceptionInThread = e;
} finally {
System.out.println("Shutting down");
graph.shutdown();
}
}
use of com.tinkerpop.blueprints.impls.orient.OrientBaseGraph in project orientdb by orientechnologies.
the class TestAsyncReplMode2Servers2OpsCommitConcurrent method dbClient1.
protected void dbClient1() {
OGlobalConfiguration.DISTRIBUTED_CONCURRENT_TX_AUTORETRY_DELAY.setValue(1);
OrientBaseGraph graph = new OrientGraph(getLocalURL());
OrientVertex vertex1 = graph.addVertex("vertextype", (String) null);
graph.commit();
graph.shutdown();
vertex1Id = vertex1.getIdentity();
exec("client1");
}
use of com.tinkerpop.blueprints.impls.orient.OrientBaseGraph in project orientdb by orientechnologies.
the class TestAsyncReplMode2ServersAddEdge method dbClient1.
protected void dbClient1() {
OGlobalConfiguration.LOG_CONSOLE_LEVEL.setValue("FINEST");
synchronized (LOCK) {
OrientBaseGraph graph = new OrientGraph(getLocalURL());
try {
OrientVertex parentV1 = graph.addVertex("vertextype", (String) null);
graph.commit();
assertEquals(1, parentV1.getRecord().getVersion());
parentV1Id = parentV1.getId();
for (int i = 0; i < NUM_OF_LOOP_ITERATIONS; i++) {
Vertex childV = graph.addVertex("vertextype", (String) null);
graph.commit();
assertEquals(1, ((OrientVertex) childV).getRecord().getVersion());
parentV1.addEdge("edgetype", childV);
graph.commit();
OLogManager.instance().error(this, "parentV1 %s v%d should be v%d", parentV1.getIdentity(), parentV1.getRecord().getVersion(), i + 2);
assertEquals(i + 2, ((OrientVertex) parentV1).getRecord().getVersion());
assertEquals(2, ((OrientVertex) childV).getRecord().getVersion());
}
pause();
} catch (Throwable e) {
OLogManager.instance().error(this, "Exception", e);
if (exceptionInThread == null) {
exceptionInThread = e;
}
} finally {
System.out.println("Shutting down");
graph.shutdown();
LOCK.notifyAll();
}
}
}
use of com.tinkerpop.blueprints.impls.orient.OrientBaseGraph in project orientdb by orientechnologies.
the class TestRemoteDelete method dbClient1.
@Override
protected void dbClient1() {
OrientBaseGraph graph = new OrientGraph(getRemoteURL());
try {
Vertex v1 = graph.addVertex("vertextype", (String) null);
graph.commit();
assertEquals(1, ((OrientVertex) v1).getRecord().getVersion());
Vertex v2 = graph.addVertex("vertextype", (String) null);
graph.commit();
assertEquals(1, ((OrientVertex) v2).getRecord().getVersion());
Edge e = v1.addEdge("edgetype", v2);
graph.commit();
assertEquals(2, ((OrientVertex) v1).getRecord().getVersion());
assertEquals(2, ((OrientVertex) v2).getRecord().getVersion());
e.remove();
graph.commit();
assertFalse(((OrientVertex) v1).getVertices(Direction.OUT, "edgetype").iterator().hasNext());
assertFalse(((OrientVertex) v2).getVertices(Direction.IN, "edgetype").iterator().hasNext());
} catch (Throwable e) {
if (exceptionInThread == null) {
exceptionInThread = e;
}
} finally {
OLogManager.instance().info(this, "Shutting down");
graph.shutdown();
}
}
Aggregations