use of com.tinkerpop.blueprints.impls.orient.OrientGraph in project orientdb by orientechnologies.
the class TransactionConsistencyTest method deletesWithinTransactionArentWorking.
@Test
public void deletesWithinTransactionArentWorking() throws IOException {
OrientGraph graph = new OrientGraph(url);
graph.setUseLightweightEdges(false);
try {
if (graph.getVertexType("Foo") == null)
graph.createVertexType("Foo");
if (graph.getVertexType("Bar") == null)
graph.createVertexType("Bar");
if (graph.getVertexType("Sees") == null)
graph.createEdgeType("Sees");
// Commenting out the transaction will result in the test succeeding.
ODocument foo = graph.addVertex("class:Foo", "prop", "test1").getRecord();
// Comment out these two lines and the test will succeed. The issue appears to be related to an edge
// connecting a deleted vertex during a transaction
ODocument bar = graph.addVertex("class:Bar", "prop", "test1").getRecord();
ODocument sees = graph.addEdge(null, graph.getVertex(foo), graph.getVertex(bar), "Sees").getRecord();
graph.commit();
List<ODocument> foos = graph.getRawGraph().query(new OSQLSynchQuery("select * from Foo"));
Assert.assertEquals(foos.size(), 1);
graph.removeVertex(graph.getVertex(foos.get(0)));
} finally {
graph.shutdown();
}
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraph in project orientdb by orientechnologies.
the class TraverseTest method init.
@BeforeClass
public void init() {
OrientGraph graph = new OrientGraph(database);
graph.setUseLightweightEdges(false);
graph.createVertexType("Movie");
graph.createVertexType("Actor");
tomCruise = graph.addVertex("class:Actor", "name", "Tom Cruise").getRecord();
totalElements++;
megRyan = graph.addVertex("class:Actor", "name", "Meg Ryan").getRecord();
totalElements++;
nicoleKidman = graph.addVertex("class:Actor", "name", "Nicole Kidman", "attributeWithDotValue", "a.b").getRecord();
totalElements++;
ODocument topGun = graph.addVertex("class:Movie", "name", "Top Gun", "year", 1986).getRecord();
totalElements++;
ODocument missionImpossible = graph.addVertex("class:Movie", "name", "Mission: Impossible", "year", 1996).getRecord();
totalElements++;
ODocument youHaveGotMail = graph.addVertex("class:Movie", "name", "You've Got Mail", "year", 1998).getRecord();
totalElements++;
graph.addEdge(null, graph.getVertex(tomCruise), graph.getVertex(topGun), "actorIn");
totalElements++;
graph.addEdge(null, graph.getVertex(megRyan), graph.getVertex(topGun), "actorIn");
totalElements++;
graph.addEdge(null, graph.getVertex(tomCruise), graph.getVertex(missionImpossible), "actorIn");
totalElements++;
graph.addEdge(null, graph.getVertex(megRyan), graph.getVertex(youHaveGotMail), "actorIn");
totalElements++;
graph.addEdge(null, graph.getVertex(tomCruise), graph.getVertex(megRyan), "friend");
totalElements++;
graph.addEdge(null, graph.getVertex(tomCruise), graph.getVertex(nicoleKidman), "married").setProperty("year", 1990);
totalElements++;
graph.commit();
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraph in project orientdb by orientechnologies.
the class DistributedSuperNodeTest method onAfterExecution.
@Override
protected void onAfterExecution() {
OrientGraph graph = factory.getTx();
try {
OrientVertex root = graph.getVertex(rootVertexId);
Assert.assertEquals(((OMultiCollectionIterator) root.getEdges(Direction.OUT)).size(), count * serverInstance.size() * writerCount);
} finally {
graph.shutdown();
}
super.onAfterExecution();
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraph in project orientdb by orientechnologies.
the class ConcurrentDistributedUpdateTest method createWriter.
protected Callable<Void> createWriter(final int serverId, final int threadId, final String databaseURL) {
return new Callable<Void>() {
@Override
public Void call() throws Exception {
final String id = serverId + "." + threadId;
boolean isRunning = true;
final OrientBaseGraph graph = new OrientGraph(databaseURL);
try {
String query = "select from Test where prop2='v2-1'";
for (int i = 0; i < 100 && isRunning; i++) {
if ((i % 25) == 0) {
log("[" + id + "] Records Processed: [" + i + "]");
}
Iterable<Vertex> vtxs = graph.command(new OCommandSQL(query)).execute();
boolean update = true;
for (Vertex vtx : vtxs) {
if (update) {
update = true;
for (int k = 0; k < 10 && update; k++) {
OrientVertex vtx1 = (OrientVertex) vtx;
try {
vtx1.setProperty("prop5", "prop55");
graph.commit();
// log("[" + id + "/" + i + "/" + k + "] OK!\n");
break;
} catch (OConcurrentModificationException ex) {
vtx1.reload();
} catch (ODistributedRecordLockedException ex) {
log("[" + id + "/" + i + "/" + k + "] Distributed lock Exception " + ex + " for vertex " + vtx1 + " \n");
// ex.printStackTrace();
update = false;
// isRunning = false;
break;
} catch (Exception ex) {
log("[" + id + "/" + i + "/" + k + "] Exception " + ex + " for vertex " + vtx1 + "\n\n");
ex.printStackTrace();
isRunning = false;
break;
}
}
if (!isRunning)
break;
}
}
}
} catch (Exception ex) {
System.out.println("ID: [" + id + "]********** Exception " + ex + " \n\n");
ex.printStackTrace();
} finally {
log("[" + id + "] Done................>>>>>>>>>>>>>>>>>>");
graph.shutdown();
runningWriters.countDown();
}
Assert.assertTrue(isRunning);
return null;
}
};
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraph 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