use of com.tinkerpop.blueprints.impls.orient.OrientVertexType in project orientdb by orientechnologies.
the class LuceneListIndexingTest method rname.
@Test
public void rname() throws Exception {
final OrientGraphNoTx graph = new OrientGraphNoTx(db);
final OrientVertexType c1 = graph.createVertexType("C1");
c1.createProperty("p1", OType.STRING);
final ODocument metadata = new ODocument();
metadata.field("default", "org.apache.lucene.analysis.en.EnglishAnalyzer");
c1.createIndex("p1", "FULLTEXT", null, metadata, "LUCENE", new String[] { "p1" });
final OrientVertex result = graph.addVertex("class:C1");
result.setProperty("p1", "testing");
graph.commit();
final Iterable search = db.command(new OSQLSynchQuery<ODocument>("SELECT from C1 WHERE p1 LUCENE \"tested\"")).execute();
assertThat(search).hasSize(1);
}
use of com.tinkerpop.blueprints.impls.orient.OrientVertexType 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.OrientVertexType 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);
}
}
}
use of com.tinkerpop.blueprints.impls.orient.OrientVertexType in project orientdb by orientechnologies.
the class TestShardingManualSync method executeTest.
@Override
protected void executeTest() throws Exception {
final OrientGraphFactory localFactoryEurope = new OrientGraphFactory("plocal:target/server0/databases/" + getDatabaseName());
OrientGraphFactory localFactoryUsa = new OrientGraphFactory("plocal:target/server1/databases/" + getDatabaseName());
final ORID v1Identity;
OrientGraphNoTx graphNoTxEurope = localFactoryEurope.getNoTx();
try {
final OrientVertexType clientType = graphNoTxEurope.createVertexType("Client-Type");
for (int i = 1; i < serverInstance.size(); ++i) {
final String serverName = serverInstance.get(i).getServerInstance().getDistributedManager().getLocalNodeName();
clientType.addCluster("client_" + serverName);
}
final OrientVertex v1 = graphNoTxEurope.addVertex("class:Client-Type");
v1Identity = v1.getIdentity();
log("Created vertex " + v1Identity + "...");
} finally {
graphNoTxEurope.shutdown();
}
OrientGraphNoTx graphNoTxUsa = localFactoryUsa.getNoTx();
try {
Assert.assertEquals(1, graphNoTxUsa.countVertices());
} finally {
graphNoTxUsa.shutdown();
localFactoryUsa.close();
}
final String clusterName;
graphNoTxEurope = localFactoryEurope.getNoTx();
try {
Assert.assertEquals(1, graphNoTxEurope.countVertices());
// CHANGE THE WRITE QUORUM = 1
final OModifiableDistributedConfiguration dCfg = serverInstance.get(0).server.getDistributedManager().getDatabaseConfiguration(getDatabaseName()).modify();
ODocument newCfg = dCfg.getDocument().field("writeQuorum", 1);
serverInstance.get(0).server.getDistributedManager().updateCachedDatabaseConfiguration(getDatabaseName(), dCfg, true);
// CREATE A NEW RECORD ON SERVER 0 BYPASSING REPLICATION
final ODocument v2 = new ODocument("Client");
((ORecordId) v2.getIdentity()).setClusterId(v1Identity.getClusterId());
((ORecordId) v2.getIdentity()).setClusterPosition(v1Identity.getClusterPosition() + 1);
final Object result = createRemoteRecord(0, v2, new String[] { serverInstance.get(0).getServerInstance().getDistributedManager().getLocalNodeName() });
Assert.assertFalse(result instanceof Throwable);
Assert.assertEquals(2, graphNoTxEurope.countVertices());
clusterName = graphNoTxEurope.getRawGraph().getClusterNameById(v2.getIdentity().getClusterId());
Assert.assertEquals(2, graphNoTxEurope.countVertices());
} finally {
graphNoTxEurope.shutdown();
}
// TEST SECOND VERTEX IS MISSING ON USA NODE
localFactoryUsa = new OrientGraphFactory("plocal:target/server1/databases/" + getDatabaseName());
graphNoTxUsa = localFactoryUsa.getNoTx();
try {
Assert.assertEquals(1, graphNoTxUsa.countVertices());
log("Manually syncing cluster client-type of node USA...");
graphNoTxUsa.command(new OCommandSQL("ha sync cluster `" + clusterName + "`")).execute();
Assert.assertEquals(2, graphNoTxUsa.countVertices());
} finally {
graphNoTxUsa.shutdown();
}
localFactoryEurope.close();
localFactoryUsa.close();
}
use of com.tinkerpop.blueprints.impls.orient.OrientVertexType in project orientdb by orientechnologies.
the class OEdgeTransformerTest method setUp.
@Override
public void setUp() {
super.setUp();
final OrientVertexType v1 = graph.createVertexType("V1");
final OrientVertexType v2 = graph.createVertexType("V2");
final OrientEdgeType edgeType = graph.createEdgeType("Friend");
edgeType.createProperty("in", OType.LINK, v2);
edgeType.createProperty("out", OType.LINK, v1);
// ASSURE NOT DUPLICATES
edgeType.createIndex("out_in", OClass.INDEX_TYPE.UNIQUE, "in", "out");
graph.addVertex("class:V2").setProperty("name", "Luca");
graph.commit();
}
Aggregations