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);
}
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();
}
}
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();
}
}
}
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();
}
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;
}
Aggregations