Search in sources :

Example 11 with OrientGraphNoTx

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

the class DistributedDbDropAndReCreateAnotherTest method onAfterExecution.

@Override
protected void onAfterExecution() throws Exception {
    do {
        ServerRun server = serverInstance.get(0);
        ODatabaseDocumentTx db = new ODatabaseDocumentTx(getDatabaseURL(server));
        db.open("admin", "admin");
        waitForDatabaseIsOnline(0, "europe-0", getDatabaseName(), 5000);
        waitForDatabaseIsOnline(0, "europe-1", getDatabaseName(), 5000);
        waitForDatabaseIsOnline(0, "europe-2", getDatabaseName(), 5000);
        db.drop();
        waitForDatabaseIsOffline("europe-0", getDatabaseName(), 5000);
        waitForDatabaseIsOffline("europe-1", getDatabaseName(), 5000);
        waitForDatabaseIsOffline("europe-2", getDatabaseName(), 5000);
        server = serverInstance.get(lastServerNum);
        ++lastServerNum;
        final String dbName = getDatabaseURL(server);
        banner("(RE)CREATING DATABASE " + dbName + " ON SERVER " + server.getServerId());
        final OrientGraphNoTx graph = new OrientGraphNoTx(dbName);
        waitForDatabaseIsOnline(0, "europe-0", getDatabaseName(), 15000);
        waitForDatabaseIsOnline(0, "europe-1", getDatabaseName(), 15000);
        waitForDatabaseIsOnline(0, "europe-2", getDatabaseName(), 15000);
        checkSameClusters();
        graph.makeActive();
        onAfterDatabaseCreation(graph);
        graph.shutdown();
        checkThePersonClassIsPresentOnAllTheServers();
    } while (lastServerNum < serverInstance.size());
    banner("EXECUTING FINAL TESTS");
    dumpDistributedDatabaseCfgOfAllTheServers();
    Thread.sleep(10000);
    executeMultipleTest(0);
}
Also used : ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) OrientGraphNoTx(com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx)

Example 12 with OrientGraphNoTx

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

the class ServerClusterQueryTest method createDatabase.

private void createDatabase() {
    OrientGraphFactory factory = new OrientGraphFactory("plocal:target/server0/databases/" + getDatabaseName());
    OrientGraphNoTx g = factory.getNoTx();
    try {
        g.createVertexType("V1");
        g.createEdgeType("E1");
        v1 = g.addVertex("class:V1");
        v1.setProperty("amount", 10);
        v1.setProperty("kind", "a");
        v2 = g.addVertex("class:V2");
        v2.setProperty("amount", 15);
        v2.setProperty("kind", "b");
        v3 = g.addVertex("class:V2");
        v3.setProperty("amount", 21);
        v3.setProperty("kind", "b");
        v1.addEdge("E1", v2);
    } finally {
        g.shutdown();
    }
}
Also used : OrientGraphFactory(com.tinkerpop.blueprints.impls.orient.OrientGraphFactory) OrientGraphNoTx(com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx)

Example 13 with OrientGraphNoTx

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

the class ServerClusterQueryTest method checkShardedGroupBy.

private void checkShardedGroupBy() {
    for (int s = 0; s < SERVERS; ++s) {
        OrientGraphFactory factory = new OrientGraphFactory("plocal:target/server" + s + "/databases/" + getDatabaseName());
        OrientGraphNoTx g = factory.getNoTx();
        try {
            Iterable<OrientVertex> result = g.command(new OCommandSQL("select from ( select amount, kind from v group by kind ) order by kind")).execute();
            Iterator<OrientVertex> it = result.iterator();
            Assert.assertTrue(it.hasNext());
            OrientVertex r1 = it.next();
            Assert.assertTrue(it.hasNext());
            OrientVertex r2 = it.next();
            Assert.assertFalse(it.hasNext());
            Assert.assertEquals(r1.getProperty("kind"), "a");
            Assert.assertEquals(r2.getProperty("kind"), "b");
        } finally {
            g.shutdown();
        }
    }
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OrientGraphFactory(com.tinkerpop.blueprints.impls.orient.OrientGraphFactory) OrientGraphNoTx(com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx) OrientVertex(com.tinkerpop.blueprints.impls.orient.OrientVertex)

Example 14 with OrientGraphNoTx

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

the class HAClusterStrategyTest method executeTest.

@Override
public void executeTest() throws Exception {
    final OrientGraphFactory factory = new OrientGraphFactory(getDatabaseURL(serverInstance.get(0)));
    final OrientGraphNoTx g = factory.getNoTx();
    g.createVertexType("Test");
    g.shutdown();
    for (int i = 0; i < 10; ++i) {
        // pressing 'return' 2 to 10 times should trigger the described behavior
        Thread.sleep(100);
        final OrientGraph graph = factory.getTx();
        // should always be 'local', but eventually changes to 'round-robin'
        System.out.println("StrategyClassName: " + graph.getVertexType("Test").getClusterSelection().getClass().getName());
        System.out.println("ClusterSelectionStrategy for " + graph.getRawGraph().getURL() + ": " + graph.getVertexType("Test").getClusterSelection().getName());
        Assert.assertEquals(graph.getVertexType("Test").getClusterSelection().getClass().getName(), OLocalClusterWrapperStrategy.class.getName());
        Assert.assertEquals(graph.getVertexType("Test").getClusterSelection().getName(), "round-robin");
        graph.addVertex("class:Test", "firstName", "Roger", "lastName", "Smith");
        graph.getRawGraph().commit();
        graph.shutdown();
    }
    factory.close();
    factory.drop();
}
Also used : OLocalClusterWrapperStrategy(com.orientechnologies.orient.server.distributed.impl.OLocalClusterWrapperStrategy) OrientGraph(com.tinkerpop.blueprints.impls.orient.OrientGraph) OrientGraphFactory(com.tinkerpop.blueprints.impls.orient.OrientGraphFactory) OrientGraphNoTx(com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx)

Example 15 with OrientGraphNoTx

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

the class TestShardingDocsAndEdges method execute.

static Set<String> execute(ODatabaseDocument db, String command) throws InterruptedException {
    System.out.println(command);
    Set<String> resultSet = new HashSet();
    db.open("admin", "admin");
    // CREATE A GRAPH TO MANIPULATE ELEMENTS
    final OrientGraphNoTx graph = new OrientGraphNoTx((ODatabaseDocumentTx) db);
    graph.makeActive();
    try {
        Object o = db.command(new OCommandSQL(command)).execute();
        if (o instanceof List) {
            List<ODocument> resultList = (List) o;
            for (OIdentifiable d : resultList) {
                resultSet.add((String) ((ODocument) d.getRecord()).field("name"));
            }
        }
    } finally {
        db.close();
        graph.shutdown();
    }
    return resultSet;
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OrientGraphNoTx(com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx) List(java.util.List) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) HashSet(java.util.HashSet) 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