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