Search in sources :

Example 6 with OrientBaseGraph

use of com.tinkerpop.blueprints.impls.orient.OrientBaseGraph in project orientdb by orientechnologies.

the class BlueprintsConcurrentGraphChangesTestNoTx method addEdgesConcurrently.

private void addEdgesConcurrently() throws Exception {
    ExecutorService executorService = Executors.newCachedThreadPool();
    beginTime = System.currentTimeMillis();
    List<Future<Void>> futures = new ArrayList<Future<Void>>();
    for (int i = 0; i < THREADS; i++) futures.add(executorService.submit(new ConcurrentGraphCreator()));
    latchCreate.countDown();
    for (Future<Void> future : futures) future.get();
    final OrientBaseGraph g = getGraph();
    printStats(g);
    g.shutdown();
}
Also used : ExecutorService(java.util.concurrent.ExecutorService) ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future) OrientBaseGraph(com.tinkerpop.blueprints.impls.orient.OrientBaseGraph)

Example 7 with OrientBaseGraph

use of com.tinkerpop.blueprints.impls.orient.OrientBaseGraph in project orientdb by orientechnologies.

the class BlueprintsConcurrentGraphChangesTestNoTx method assertEdgesDeletedGraph.

private void assertEdgesDeletedGraph() {
    OrientBaseGraph graph = getGraph();
    graph.setUseLightweightEdges(false);
    Assert.assertEquals(VERTEXES_COUNT, graph.countVertices("TestVertex"));
    Assert.assertEquals(0, graph.countEdges("TestEdge"));
    for (TestVertex vertex : vertexes) {
        Iterable<Vertex> vertexes = graph.command(new OSQLSynchQuery<Vertex>("select from TestVertex where uuid = '" + vertex.uuid + "'")).execute();
        Assert.assertTrue(vertexes.iterator().hasNext());
        Vertex gVertex = vertexes.iterator().next();
        OMultiCollectionIterator<Edge> outEdges = (OMultiCollectionIterator<Edge>) gVertex.getEdges(Direction.OUT);
        Assert.assertEquals(outEdges.size(), 0);
        OMultiCollectionIterator<Edge> inEdges = (OMultiCollectionIterator<Edge>) gVertex.getEdges(Direction.IN);
        Assert.assertEquals(inEdges.size(), 0);
    }
    assertGraphIsConsistent(graph);
    graph.shutdown();
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) OSQLSynchQuery(com.orientechnologies.orient.core.sql.query.OSQLSynchQuery) OMultiCollectionIterator(com.orientechnologies.common.collection.OMultiCollectionIterator) OrientBaseGraph(com.tinkerpop.blueprints.impls.orient.OrientBaseGraph) Edge(com.tinkerpop.blueprints.Edge)

Example 8 with OrientBaseGraph

use of com.tinkerpop.blueprints.impls.orient.OrientBaseGraph in project orientdb by orientechnologies.

the class BlueprintsConcurrentGraphChangesTestNoTx method assertVerticesDeletedGraph.

private void assertVerticesDeletedGraph() {
    OrientBaseGraph graph = getGraph();
    graph.setUseLightweightEdges(false);
    Assert.assertEquals(0, graph.countVertices("TestVertex"));
    Assert.assertEquals(0, graph.countEdges("TestEdge"));
    assertGraphIsConsistent(graph);
    graph.shutdown();
}
Also used : OrientBaseGraph(com.tinkerpop.blueprints.impls.orient.OrientBaseGraph)

Example 9 with OrientBaseGraph

use of com.tinkerpop.blueprints.impls.orient.OrientBaseGraph in project orientdb by orientechnologies.

the class BlueprintsConcurrentGraphChangesTestNoTx method deleteVerticesConcurrently.

private void deleteVerticesConcurrently() throws Exception {
    ExecutorService executorService = Executors.newCachedThreadPool();
    beginTime = System.currentTimeMillis();
    List<Future<Void>> futures = new ArrayList<Future<Void>>();
    for (int i = 0; i < THREADS; i++) futures.add(executorService.submit(new ConcurrentVertexRemover()));
    latchVertexDelete.countDown();
    for (Future<Void> future : futures) future.get();
    final OrientBaseGraph g = getGraph();
    printStats(g);
    g.shutdown();
}
Also used : ExecutorService(java.util.concurrent.ExecutorService) ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future) OrientBaseGraph(com.tinkerpop.blueprints.impls.orient.OrientBaseGraph)

Example 10 with OrientBaseGraph

use of com.tinkerpop.blueprints.impls.orient.OrientBaseGraph in project orientdb by orientechnologies.

the class BlueprintsConcurrentGraphChangesTestNoTx method createGraphAndDeleteVertices.

protected void createGraphAndDeleteVertices() throws Exception {
    OrientBaseGraph graph = getGraph();
    graph.drop();
    generateVertexes();
    generateEdges();
    initGraph();
    System.out.println("Start adding edges concurrently for further delete vertices...");
    addEdgesConcurrently();
    System.out.println("Checking the graph...");
    assertCreatedGraph();
    System.out.println("Start removing vertices concurrently...");
    deleteVerticesConcurrently();
    System.out.println("Checking the graph...");
    assertVerticesDeletedGraph();
    graph = getGraph();
    graph.drop();
}
Also used : OrientBaseGraph(com.tinkerpop.blueprints.impls.orient.OrientBaseGraph)

Aggregations

OrientBaseGraph (com.tinkerpop.blueprints.impls.orient.OrientBaseGraph)70 OrientVertex (com.tinkerpop.blueprints.impls.orient.OrientVertex)40 OrientGraph (com.tinkerpop.blueprints.impls.orient.OrientGraph)19 Vertex (com.tinkerpop.blueprints.Vertex)13 OrientGraphNoTx (com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx)13 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)11 OrientGraphFactory (com.tinkerpop.blueprints.impls.orient.OrientGraphFactory)8 Test (org.junit.Test)8 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)7 Edge (com.tinkerpop.blueprints.Edge)7 ODatabaseDocument (com.orientechnologies.orient.core.db.document.ODatabaseDocument)6 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)5 OGraphRepair (com.tinkerpop.blueprints.impls.orient.OGraphRepair)5 ArrayList (java.util.ArrayList)5 ONeedRetryException (com.orientechnologies.common.concur.ONeedRetryException)4 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)4 OConcurrentModificationException (com.orientechnologies.orient.core.exception.OConcurrentModificationException)4 OSQLSynchQuery (com.orientechnologies.orient.core.sql.query.OSQLSynchQuery)4 ORecordDuplicatedException (com.orientechnologies.orient.core.storage.ORecordDuplicatedException)4 OrientEdge (com.tinkerpop.blueprints.impls.orient.OrientEdge)4