Search in sources :

Example 1 with OrientGraphNoTx

use of com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx in project guice-persist-orient by xvik.

the class GraphPool method get.

@Override
public OrientBaseGraph get() {
    if (transaction.get() == null) {
        final ODatabaseDocumentTx documentDb = documentPool.get();
        final OrientBaseGraph graph = transactionManager.getActiveTransactionType() == OTransaction.TXTYPE.NOTX ? new OrientGraphNoTx(documentDb) : new OrientGraph(documentDb);
        transaction.set(graph);
    }
    final OrientBaseGraph db = transaction.get();
    db.getRawGraph().activateOnCurrentThread();
    return db;
}
Also used : OrientGraph(com.tinkerpop.blueprints.impls.orient.OrientGraph) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) OrientGraphNoTx(com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx) OrientBaseGraph(com.tinkerpop.blueprints.impls.orient.OrientBaseGraph)

Example 2 with OrientGraphNoTx

use of com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx in project guice-persist-orient by xvik.

the class OrientGraphNoTxProvider method get.

@Override
public OrientGraphNoTx get() {
    final OrientBaseGraph graph = provider.get();
    Preconditions.checkState(graph instanceof OrientGraphNoTx, "You must use OrientGraph within transaction or disable transaction " + "(or use OrientBaseGraph as universal solution for all cases)");
    return (OrientGraphNoTx) graph;
}
Also used : OrientGraphNoTx(com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx) OrientBaseGraph(com.tinkerpop.blueprints.impls.orient.OrientBaseGraph)

Example 3 with OrientGraphNoTx

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

the class LuceneTransactionQueryTest method init.

@Before
public void init() {
    final OrientVertexType c1 = new OrientGraphNoTx(db).createVertexType("C1");
    c1.createProperty("p1", OType.STRING);
    c1.createIndex("C1.p1", "FULLTEXT", null, null, "LUCENE", new String[] { "p1" });
}
Also used : OrientVertexType(com.tinkerpop.blueprints.impls.orient.OrientVertexType) OrientGraphNoTx(com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx) Before(org.junit.Before)

Example 4 with OrientGraphNoTx

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

the class WWConflictAndNodeInDeadlockScenarioTest method onServerStarted.

@Override
protected void onServerStarted(ServerRun server) {
    super.onServerStarted(server);
    if (serverStarted++ == (2)) {
        // startQueueMonitorTask();
        startCountMonitorTask("Person");
        // BACKUP LAST SERVER, RUN ASYNCHRONOUSLY
        new Thread(new Runnable() {

            @Override
            public void run() {
                try {
                    // CRASH LAST SERVER try {
                    executeWhen(new Callable<Boolean>() {

                        // CONDITION
                        @Override
                        public Boolean call() throws Exception {
                            return server3inDeadlock.get();
                        }
                    }, // ACTION
                    new Callable() {

                        @Override
                        public Object call() throws Exception {
                            banner("STARTING BACKUP SERVER " + (2));
                            OrientGraphFactory factory = new OrientGraphFactory("plocal:target/server2/databases/" + getDatabaseName());
                            OrientGraphNoTx g = factory.getNoTx();
                            backupInProgress = true;
                            File file = null;
                            try {
                                file = File.createTempFile("orientdb_test_backup", ".zip");
                                if (file.exists())
                                    Assert.assertTrue(file.delete());
                                g.getRawGraph().backup(new FileOutputStream(file), null, new Callable<Object>() {

                                    @Override
                                    public Object call() throws Exception {
                                        // SIMULATE LONG BACKUP UNTIL SPECIFIED BY VARIABLE 'server3inDeadlock'
                                        while (server3inDeadlock.get()) {
                                            Thread.sleep(1000);
                                        }
                                        return null;
                                    }
                                }, null, 9, 1000000);
                            } catch (IOException e) {
                                e.printStackTrace();
                            } finally {
                                banner("COMPLETED BACKUP SERVER " + (2));
                                backupInProgress = false;
                                g.shutdown();
                                if (file != null)
                                    file.delete();
                            }
                            return null;
                        }
                    });
                } catch (Exception e) {
                    e.printStackTrace();
                    fail("Error on execution flow");
                }
            }
        }).start();
    }
}
Also used : IOException(java.io.IOException) IOException(java.io.IOException) Callable(java.util.concurrent.Callable) FileOutputStream(java.io.FileOutputStream) OrientGraphFactory(com.tinkerpop.blueprints.impls.orient.OrientGraphFactory) OrientGraphNoTx(com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) File(java.io.File)

Example 5 with OrientGraphNoTx

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

the class ConcurrentDistributedUpdateTest method executeTest.

@Override
public void executeTest() throws Exception {
    OrientBaseGraph orientGraph = new OrientGraphNoTx(getPlocalDatabaseURL(serverInstance.get(0)));
    OClass clazz = orientGraph.getVertexType("Test");
    if (clazz == null) {
        log("Creating vertex type - " + "Test");
        orientGraph.createVertexType("Test");
    }
    orientGraph.shutdown();
    OrientBaseGraph graph = new OrientGraphNoTx(getPlocalDatabaseURL(serverInstance.get(0)));
    for (int i = 0; i < 2; i++) {
        Vertex vertex = graph.addVertex("class:Test");
        vertex.setProperty("prop1", "v1-" + i);
        vertex.setProperty("prop2", "v2-1");
        vertex.setProperty("prop3", "v3-1");
        graph.commit();
        if ((i % 100) == 0) {
            log("Created " + i + " nodes");
        }
    }
    graph.shutdown();
    executeMultipleTest();
}
Also used : OrientVertex(com.tinkerpop.blueprints.impls.orient.OrientVertex) Vertex(com.tinkerpop.blueprints.Vertex) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) OrientGraphNoTx(com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx) OrientBaseGraph(com.tinkerpop.blueprints.impls.orient.OrientBaseGraph)

Aggregations

OrientGraphNoTx (com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx)72 OrientVertex (com.tinkerpop.blueprints.impls.orient.OrientVertex)28 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)23 Test (org.junit.Test)22 OrientGraphFactory (com.tinkerpop.blueprints.impls.orient.OrientGraphFactory)20 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)17 OrientVertexType (com.tinkerpop.blueprints.impls.orient.OrientVertexType)17 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)16 OrientBaseGraph (com.tinkerpop.blueprints.impls.orient.OrientBaseGraph)15 OSQLSynchQuery (com.orientechnologies.orient.core.sql.query.OSQLSynchQuery)7 Vertex (com.tinkerpop.blueprints.Vertex)6 OrientGraph (com.tinkerpop.blueprints.impls.orient.OrientGraph)6 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)5 OGraphMLReader (com.orientechnologies.orient.graph.graphml.OGraphMLReader)5 OGraphRepair (com.tinkerpop.blueprints.impls.orient.OGraphRepair)5 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)4 Edge (com.tinkerpop.blueprints.Edge)4 OSchema (com.orientechnologies.orient.core.metadata.schema.OSchema)3 OrientEdge (com.tinkerpop.blueprints.impls.orient.OrientEdge)3 File (java.io.File)3