Search in sources :

Example 36 with OrientGraphNoTx

use of com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx 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)

Example 37 with OrientGraphNoTx

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

the class TestOutInChain method before.

@BeforeClass
public static void before() {
    // generate schema
    OrientGraphNoTx graph = new OrientGraphNoTx("memory:" + TestOutInChain.class.getSimpleName(), "admin", "admin");
    graph.command(new OCommandSQL("create class User extends V")).execute();
    graph.command(new OCommandSQL("create class Car extends V")).execute();
    graph.command(new OCommandSQL("create class Owns extends E")).execute();
    initTestMultipleLabels(graph);
    graph.shutdown();
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OrientGraphNoTx(com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx) BeforeClass(org.junit.BeforeClass)

Example 38 with OrientGraphNoTx

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

the class GraphInsertSpeedMTTest method init.

@Override
public void init() {
    if (factory.exists())
        factory.drop();
    final OrientGraphNoTx graph = factory.getNoTx();
    try {
        if (graph.getVertexType("Client") == null) {
            final OrientVertexType clientType = graph.createVertexType("Client");
            final OrientVertexType.OrientVertexProperty property = clientType.createProperty("uid", OType.STRING);
            // CREATE ONE CLUSTER PER THREAD
            for (int i = 0; i < getThreads(); ++i) {
                System.out.println("Creating cluster: client_" + i + "...");
                clientType.addCluster("client_" + i);
            }
        }
    } finally {
        graph.shutdown();
    }
}
Also used : OrientGraphNoTx(com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx) OrientVertexType(com.tinkerpop.blueprints.impls.orient.OrientVertexType)

Example 39 with OrientGraphNoTx

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

the class GraphInsertSpeedMTTest method deinit.

@Override
public void deinit() {
    final OrientGraphNoTx graph = factory.getNoTx();
    try {
        final long total = graph.countVertices("Client");
        System.out.println("\nTotal objects in Client cluster after the test: " + total);
        System.out.println("Created " + (total));
        Assert.assertEquals(total, threadCycles);
        final long indexedItems = graph.getRawGraph().getMetadata().getIndexManager().getIndex("Client.uid").getSize();
        System.out.println("\nTotal indexed objects after the test: " + indexedItems);
    } finally {
        graph.shutdown();
    }
}
Also used : OrientGraphNoTx(com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx)

Example 40 with OrientGraphNoTx

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

the class BasicShardingNoReplicaScenarioTest method executeTest.

@Override
public void executeTest() throws Exception {
    OHazelcastPlugin manager1 = (OHazelcastPlugin) serverInstance.get(0).getServerInstance().getDistributedManager();
    final OModifiableDistributedConfiguration databaseConfiguration = manager1.getDatabaseConfiguration(this.getDatabaseName()).modify();
    ODocument cfg = databaseConfiguration.getDocument();
    OrientGraphFactory localFactory = new OrientGraphFactory("plocal:target/server0/databases/" + getDatabaseName());
    OrientGraphNoTx graphNoTx = null;
    try {
        graphNoTx = localFactory.getNoTx();
        final OrientVertexType clientType = graphNoTx.createVertexType("Client", 1);
        OModifiableDistributedConfiguration dCfg = new OModifiableDistributedConfiguration(cfg);
        for (int i = 0; i < serverInstance.size(); ++i) {
            final String serverName = serverInstance.get(i).getServerInstance().getDistributedManager().getLocalNodeName();
            clientType.addCluster("client_" + serverName);
            dCfg.setServerOwner("client_" + serverName, serverName);
        }
        manager1.updateCachedDatabaseConfiguration(this.getDatabaseName(), dCfg, true);
        final OrientVertexType.OrientVertexProperty prop = clientType.createProperty("name", OType.STRING);
        prop.createIndex(OClass.INDEX_TYPE.NOTUNIQUE);
        assertTrue(graphNoTx.getRawGraph().getMetadata().getIndexManager().existsIndex("Client.name"));
        Thread.sleep(500);
        graphNoTx.getRawGraph().close();
        // writes on the three clusters
        executeMultipleWritesOnShards(executeTestsOnServers, "plocal");
        // check consistency (no-replica)
        checkAvailabilityOnShardsNoReplica(serverInstance, executeTestsOnServers);
        // network fault on server3
        System.out.println("Shutdown on server3.\n");
        simulateServerFault(serverInstance.get(2), "shutdown");
        assertFalse(serverInstance.get(2).isActive());
        waitForDatabaseIsOffline(executeTestsOnServers.get(2).getServerInstance().getDistributedManager().getLocalNodeName(), getDatabaseName(), 10000);
        // check consistency (no-replica)
        executeTestsOnServers.remove(2);
        checkAvailabilityOnShardsNoReplica(executeTestsOnServers, executeTestsOnServers);
        // this query doesn't return any result
        try {
            System.out.print("Checking that records on server3 are not available in the cluster...");
            graphNoTx = localFactory.getNoTx();
            ODatabaseRecordThreadLocal.INSTANCE.set(graphNoTx.getRawGraph());
            final String uniqueId = "client_asia-s2-t10-v0";
            Iterable<Vertex> it = graphNoTx.command(new OCommandSQL("select from Client where name = '" + uniqueId + "'")).execute();
            List<OrientVertex> result = new LinkedList<OrientVertex>();
            for (Vertex v : it) {
                result.add((OrientVertex) v);
            }
            assertEquals(0, result.size());
            System.out.println("Done");
            graphNoTx.getRawGraph().close();
            ODatabaseRecordThreadLocal.INSTANCE.set(null);
        } catch (Exception e) {
            e.printStackTrace();
            fail();
        }
        // restarting server3
        serverInstance.get(2).startServer(getDistributedServerConfiguration(serverInstance.get(SERVERS - 1)));
        System.out.println("Server 3 restarted.");
        assertTrue(serverInstance.get(2).isActive());
        waitForDatabaseIsOnline(0, serverInstance.get(2).getServerInstance().getDistributedManager().getLocalNodeName(), getDatabaseName(), 10000);
        // checking server3 status by querying a record inserted on it
        try {
            System.out.print("Checking server3 status by querying a record inserted on it...");
            localFactory = new OrientGraphFactory("plocal:target/server2/databases/" + getDatabaseName());
            graphNoTx = localFactory.getNoTx();
            ODatabaseRecordThreadLocal.INSTANCE.set(graphNoTx.getRawGraph());
            final String uniqueId = "client_asia-s2-t10-v0";
            Iterable<Vertex> it = graphNoTx.command(new OCommandSQL("select from Client where name = '" + uniqueId + "'")).execute();
            List<OrientVertex> result = new LinkedList<OrientVertex>();
            for (Vertex v : it) {
                result.add((OrientVertex) v);
            }
            assertEquals(1, result.size());
            graphNoTx.getRawGraph().close();
            ODatabaseRecordThreadLocal.INSTANCE.set(null);
        } catch (Exception e) {
            e.printStackTrace();
            fail(e.toString());
        }
        // check consistency (no-replica)
        executeTestsOnServers.add(serverInstance.get(2));
        checkAvailabilityOnShardsNoReplica(serverInstance, executeTestsOnServers);
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.toString());
    } finally {
        if (!graphNoTx.getRawGraph().isClosed()) {
            ODatabaseRecordThreadLocal.INSTANCE.set(graphNoTx.getRawGraph());
            graphNoTx.getRawGraph().close();
            ODatabaseRecordThreadLocal.INSTANCE.set(null);
        }
    }
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) OrientVertex(com.tinkerpop.blueprints.impls.orient.OrientVertex) OHazelcastPlugin(com.orientechnologies.orient.server.hazelcast.OHazelcastPlugin) OrientVertex(com.tinkerpop.blueprints.impls.orient.OrientVertex) OModifiableDistributedConfiguration(com.orientechnologies.orient.server.distributed.OModifiableDistributedConfiguration) LinkedList(java.util.LinkedList) OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OrientGraphFactory(com.tinkerpop.blueprints.impls.orient.OrientGraphFactory) OrientGraphNoTx(com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx) OrientVertexType(com.tinkerpop.blueprints.impls.orient.OrientVertexType) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

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