use of com.tinkerpop.blueprints.impls.orient.OrientGraphFactory 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.OrientGraphFactory in project orientdb by orientechnologies.
the class AbstractServerClusterSQLGraphTest method onAfterDatabaseCreation.
@Override
protected void onAfterDatabaseCreation(final OrientBaseGraph graph) {
System.out.println("Creating graph schema...");
// CREATE BASIC SCHEMA
OrientVertexType personClass = graph.createVertexType("Person");
personClass.createProperty("id", OType.STRING);
personClass.createProperty("name", OType.STRING);
personClass.createProperty("birthday", OType.DATE);
personClass.createProperty("children", OType.STRING);
OrientVertexType person = graph.getVertexType("Person");
idx = person.createIndex("Person.name", OClass.INDEX_TYPE.UNIQUE, "name");
OrientVertexType customer = graph.createVertexType("Customer", person);
customer.createProperty("totalSold", OType.DECIMAL);
OrientVertexType provider = graph.createVertexType("Provider", person);
provider.createProperty("totalPurchased", OType.DECIMAL);
OrientEdgeType knows = graph.createEdgeType("Knows");
factory = new OrientGraphFactory(graph.getRawGraph().getURL(), "admin", "admin", false);
factory.setStandardElementConstraints(false);
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraphFactory 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.OrientGraphFactory in project orientdb by orientechnologies.
the class ServerClusterRemoteInsertBalancedTest method testRoundRobinOnConnect.
private void testRoundRobinOnConnect() {
final OrientGraphFactory factory = new OrientGraphFactory("remote:localhost/" + getDatabaseName());
factory.setConnectionStrategy(OStorageRemote.CONNECTION_STRATEGY.ROUND_ROBIN_CONNECT.toString());
OrientGraphNoTx graph = factory.getNoTx();
graph.createVertexType("Client");
graph.shutdown();
Map<Integer, Integer> clusterIds = new HashMap<Integer, Integer>();
for (int i = 0; i < ITERATIONS; ++i) {
graph = factory.getNoTx();
try {
final OrientVertex v = graph.addVertex("class:Client");
Integer value = clusterIds.get(v.getIdentity().getClusterId());
if (value == null)
value = 1;
else
value++;
clusterIds.put(v.getIdentity().getClusterId(), value);
} finally {
graph.shutdown();
}
}
Assert.assertTrue(clusterIds.size() > 1);
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraphFactory in project orientdb by orientechnologies.
the class ServerClusterSchemaTest method executeTest.
@Override
protected void executeTest() throws Exception {
for (int s = 0; s < SERVERS; ++s) {
OrientGraphFactory factory = new OrientGraphFactory("plocal:target/server" + s + "/databases/" + getDatabaseName());
OrientGraphNoTx g = factory.getNoTx();
try {
System.out.println("Creating vertex class Client" + s + " against server " + g + "...");
OrientVertexType t = g.createVertexType("Client" + s);
t.createProperty("name", OType.STRING).setMandatory(true);
System.out.println("Creating vertex class Knows" + s + " against server " + g + "...");
g.createEdgeType("Knows" + s);
} finally {
g.shutdown();
}
}
for (int s = 0; s < SERVERS; ++s) {
System.out.println("Checking vertices classes on server " + s + "...");
OrientGraphFactory factory = new OrientGraphFactory("plocal:target/server" + s + "/databases/" + getDatabaseName());
OrientGraphNoTx g = factory.getNoTx();
try {
for (int i = 0; i < SERVERS; ++i) {
Assert.assertNotNull(g.getVertexType("Client" + i));
Assert.assertNotNull(g.getEdgeType("Knows" + i));
}
} finally {
g.shutdown();
}
}
for (int s = 0; s < SERVERS; ++s) {
System.out.println("Add vertices on server " + s + "...");
OrientGraphFactory factory = new OrientGraphFactory("plocal:target/server" + s + "/databases/" + getDatabaseName());
OrientGraphNoTx g = factory.getNoTx();
try {
for (int i = 0; i < SERVERS; ++i) {
try {
final OrientVertex v = g.addVertex("class:" + "Client" + i);
Assert.assertTrue(false);
} catch (OValidationException e) {
// EXPECTED
}
}
} finally {
g.shutdown();
}
}
for (int s = 0; s < SERVERS; ++s) {
System.out.println("Add vertices in TX on server " + s + "...");
OrientGraphFactory factory = new OrientGraphFactory("plocal:target/server" + s + "/databases/" + getDatabaseName());
OrientGraph g = factory.getTx();
try {
for (int i = 0; i < SERVERS; ++i) {
try {
final OrientVertex v = g.addVertex("class:" + "Client" + i);
g.commit();
Assert.assertTrue(false);
} catch (ONeedRetryException e) {
// EXPECTED
} catch (OValidationException e) {
// EXPECTED
}
}
} finally {
g.shutdown();
}
}
}
Aggregations