use of com.tinkerpop.blueprints.impls.orient.OrientGraph in project orientdb by orientechnologies.
the class DirtyManagerGraph method testLoopOfNewTree.
@Test
public void testLoopOfNewTree() {
OrientGraph graph = new OrientGraph("memory:" + DirtyManagerGraph.class.getSimpleName());
Object prev = OGlobalConfiguration.RID_BAG_EMBEDDED_TO_SBTREEBONSAI_THRESHOLD.getValue();
OGlobalConfiguration.RID_BAG_EMBEDDED_TO_SBTREEBONSAI_THRESHOLD.setValue(-1);
try {
graph.createEdgeType("next");
OrientVertex vertex = graph.addVertex(null);
OrientVertex vertex1 = graph.addVertex(null);
OrientVertex vertex2 = graph.addVertex(null);
OrientVertex vertex3 = graph.addVertex(null);
OrientEdge edge1 = (OrientEdge) vertex.addEdge("next", vertex1);
OrientEdge edge2 = (OrientEdge) vertex1.addEdge("next", vertex2);
OrientEdge edge3 = (OrientEdge) vertex2.addEdge("next", vertex3);
OrientEdge edge4 = (OrientEdge) vertex3.addEdge("next", vertex);
ODocument rec = vertex.getRecord();
ODirtyManager manager = ORecordInternal.getDirtyManager(rec);
List<OIdentifiable> pointed = manager.getPointed(vertex.getRecord());
assertEquals(2, pointed.size());
assertTrue(pointed.contains(edge1.getRecord()));
assertTrue(pointed.contains(edge4.getRecord()));
pointed = manager.getPointed(vertex1.getRecord());
assertEquals(2, pointed.size());
assertTrue(pointed.contains(edge1.getRecord()));
assertTrue(pointed.contains(edge2.getRecord()));
pointed = manager.getPointed(vertex2.getRecord());
assertEquals(2, pointed.size());
assertTrue(pointed.contains(edge2.getRecord()));
assertTrue(pointed.contains(edge3.getRecord()));
pointed = manager.getPointed(vertex3.getRecord());
assertEquals(2, pointed.size());
assertTrue(pointed.contains(edge3.getRecord()));
assertTrue(pointed.contains(edge4.getRecord()));
pointed = manager.getPointed(edge1.getRecord());
assertEquals(2, pointed.size());
assertTrue(pointed.contains(vertex.getRecord()));
assertTrue(pointed.contains(vertex1.getRecord()));
pointed = manager.getPointed(edge2.getRecord());
assertEquals(2, pointed.size());
assertTrue(pointed.contains(vertex1.getRecord()));
assertTrue(pointed.contains(vertex2.getRecord()));
pointed = manager.getPointed(edge3.getRecord());
assertEquals(2, pointed.size());
assertTrue(pointed.contains(vertex2.getRecord()));
assertTrue(pointed.contains(vertex3.getRecord()));
pointed = manager.getPointed(edge4.getRecord());
assertEquals(2, pointed.size());
assertTrue(pointed.contains(vertex3.getRecord()));
assertTrue(pointed.contains(vertex.getRecord()));
} finally {
OGlobalConfiguration.RID_BAG_EMBEDDED_TO_SBTREEBONSAI_THRESHOLD.setValue(prev);
graph.drop();
}
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraph in project orientdb by orientechnologies.
the class GraphNonBlockingQueryRemote method testNonBlockingClose.
@Test
public void testNonBlockingClose() throws ExecutionException, InterruptedException {
OrientGraph database = new OrientGraph("remote:localhost:3064/" + GraphNonBlockingQueryRemote.class.getSimpleName());
database.createVertexType("Prod").createProperty("something", OType.STRING);
for (int i = 0; i < 21; i++) {
OrientVertex vertex = database.addVertex("class:Prod");
vertex.setProperty("something", "value");
vertex.save();
}
database.commit();
final CountDownLatch ended = new CountDownLatch(21);
try {
OSQLNonBlockingQuery<Object> test = new OSQLNonBlockingQuery<Object>("select * from Prod ", new OCommandResultListener() {
int resultCount = 0;
@Override
public boolean result(Object iRecord) {
resultCount++;
ODocument odoc = ((ODocument) iRecord);
for (String name : odoc.fieldNames()) {
// <----------- PROBLEM
assertEquals("something", name);
}
ended.countDown();
return resultCount > 20 ? false : true;
}
@Override
public void end() {
ended.countDown();
}
@Override
public Object getResult() {
return resultCount;
}
});
database.command(test).execute();
assertTrue(ended.await(10, TimeUnit.SECONDS));
} finally {
database.shutdown();
}
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraph in project orientdb by orientechnologies.
the class ODatabaseFailDueCloseTest method setup.
@BeforeClass
public static void setup() {
createGraph();
pool = new OrientGraphFactory("memory:temp", "admin", "admin").setupPool(1, 10);
OrientGraph graph = pool.getTx();
try {
fillTheGraph(graph);
} finally {
graph.shutdown();
}
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraph in project orientdb by orientechnologies.
the class ODatabaseFailDueCloseTest method test1.
@Test()
public void test1() {
final OrientGraph graph = pool.getTx();
try {
String queryText = "SELECT @rid as rid, localName FROM Person WHERE ( 'milano' IN out('lives').localName OR 'roma' IN out('lives').localName ) ORDER BY age ASC";
OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<ODocument>(queryText);
List<ODocument> results = graph.getRawGraph().query(query);
assertNotNull(results);
assertTrue(results.size() > 0);
} finally {
graph.shutdown();
}
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraph in project orientdb by orientechnologies.
the class ODatabaseFailDueCloseTest method test2.
@Test
public void test2() {
final OrientGraph graph = pool.getTx();
try {
String queryText = "SELECT @rid as rid, localName FROM Person WHERE age > 30";
OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<ODocument>(queryText);
List<ODocument> results = graph.getRawGraph().query(query);
assertNotNull(results);
assertTrue(results.size() > 0);
} finally {
graph.shutdown();
}
}
Aggregations