Search in sources :

Example 11 with OrientBaseGraph

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();
}
Also used : OrientBaseGraph(com.tinkerpop.blueprints.impls.orient.OrientBaseGraph)

Example 12 with OrientBaseGraph

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();
    }
}
Also used : OGraphRepair(com.tinkerpop.blueprints.impls.orient.OGraphRepair) OrientGraphNoTx(com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx) OrientBaseGraph(com.tinkerpop.blueprints.impls.orient.OrientBaseGraph) Test(org.junit.Test)

Example 13 with OrientBaseGraph

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));
}
Also used : OrientGraph(com.tinkerpop.blueprints.impls.orient.OrientGraph) OrientVertex(com.tinkerpop.blueprints.impls.orient.OrientVertex) OrientBaseGraph(com.tinkerpop.blueprints.impls.orient.OrientBaseGraph) Test(org.testng.annotations.Test)

Example 14 with OrientBaseGraph

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));
}
Also used : OrientGraph(com.tinkerpop.blueprints.impls.orient.OrientGraph) OrientVertex(com.tinkerpop.blueprints.impls.orient.OrientVertex) OrientBaseGraph(com.tinkerpop.blueprints.impls.orient.OrientBaseGraph) Test(org.testng.annotations.Test)

Example 15 with OrientBaseGraph

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();
    }
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OrientVertex(com.tinkerpop.blueprints.impls.orient.OrientVertex) Vertex(com.tinkerpop.blueprints.Vertex) OrientGraphNoTx(com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx) 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