use of com.tinkerpop.blueprints.impls.orient.OrientVertex in project orientdb by orientechnologies.
the class TestAsyncReplMode2ServersOverflow method exec.
protected void exec(final String iClient) {
counter.countDown();
try {
counter.await();
} catch (InterruptedException e) {
e.printStackTrace();
}
OrientBaseGraph graph = new OrientGraphNoTx(getLocalURL());
try {
int i = 0;
for (; i < TOTAL; ++i) {
final OrientVertex v = graph.addVertex(null);
Assert.assertTrue(v.getIdentity().isPersistent());
}
} catch (Throwable e) {
if (exceptionInThread == null)
exceptionInThread = e;
} finally {
System.out.println("Shutting down");
graph.shutdown();
}
}
use of com.tinkerpop.blueprints.impls.orient.OrientVertex in project orientdb by orientechnologies.
the class TestDistributedDatabaseRepair method testNoWinner.
private void testNoWinner(OrientGraphFactory localFactory0, OrientGraphFactory localFactory1, OrientGraphFactory localFactory2) throws Exception {
OrientBaseGraph graph = localFactory0.getTx();
OrientVertex product;
try {
product = graph.addVertex("class:ProductType");
product.setProperty("status", "ok");
} finally {
graph.shutdown();
}
banner("CORRUPT A RECORD IN SERVER 0");
graph = localFactory0.getNoTx();
try {
final OrientVertex product2 = graph.getVertex(product.getIdentity());
product2.getRecord().field("status", "corrupted0");
final ODistributedResponse result = updateRemoteRecord(0, product2.getRecord(), new String[] { serverInstance.get(0).getServerInstance().getDistributedManager().getLocalNodeName() });
Assert.assertFalse(result.getPayload() instanceof Throwable);
} finally {
graph.shutdown();
}
banner("CORRUPT A RECORD IN SERVER 1");
graph = localFactory1.getNoTx();
try {
final OrientVertex product2 = graph.getVertex(product.getIdentity());
product2.getRecord().field("status", "corrupted1");
ODistributedResponse result = updateRemoteRecord(1, product2.getRecord(), new String[] { serverInstance.get(1).getServerInstance().getDistributedManager().getLocalNodeName() });
Assert.assertFalse(result.getPayload() instanceof Throwable);
} finally {
graph.shutdown();
}
serverInstance.get(0).getServerInstance().getDistributedManager().getMessageService().getDatabase(getDatabaseName()).getDatabaseRepairer().enqueueRepairRecord((ORecordId) product.getIdentity());
Thread.sleep(3000);
// TEST NOTHING IS CHANGED
graph = localFactory0.getNoTx();
try {
final OrientVertex product2 = graph.getVertex(product.getIdentity());
Assert.assertEquals("corrupted0", product2.getProperty("status"));
} finally {
graph.shutdown();
}
graph = localFactory1.getNoTx();
try {
final OrientVertex product2 = graph.getVertex(product.getIdentity());
Assert.assertEquals("corrupted1", product2.getProperty("status"));
} finally {
graph.shutdown();
}
graph = localFactory2.getNoTx();
try {
final OrientVertex product2 = graph.getVertex(product.getIdentity());
Assert.assertEquals("ok", product2.getProperty("status"));
} finally {
graph.shutdown();
}
}
use of com.tinkerpop.blueprints.impls.orient.OrientVertex in project orientdb by orientechnologies.
the class TestDistributedDatabaseRepair method testRepairClusters.
/**
* Breaks a cluster by creating new records only on certain servers
*/
private void testRepairClusters(OrientGraphFactory localFactory0, OrientGraphFactory localFactory1, OrientGraphFactory localFactory2) throws Exception {
Thread.sleep(2000);
OrientBaseGraph graph = localFactory0.getNoTx();
graph.createVertexType("Employee");
graph.shutdown();
final ODistributedConfiguration cfg = serverInstance.get(1).getServerInstance().getDistributedManager().getDatabaseConfiguration(getDatabaseName());
// FIND THE LOCAL CLUSTER
String localCluster = null;
final Set<String> owner = cfg.getClustersOwnedByServer(serverInstance.get(1).getServerInstance().getDistributedManager().getLocalNodeName());
for (String s : owner) {
if (s.toLowerCase().startsWith("employee")) {
localCluster = s;
break;
}
}
graph = localFactory1.getTx();
OrientVertex employee;
try {
employee = graph.addVertex("Employee", localCluster);
employee.setProperty("status", "ok");
} finally {
graph.shutdown();
}
banner("CREATE 10 RECORDS ONLY ON local (1) SERVER and 0");
graph = localFactory1.getTx();
try {
for (int i = 0; i < 10; ++i) {
OrientVertex v = graph.addVertex("Employee", localCluster);
v.setProperty("status", "onlyServer0and1");
graph.getRawGraph().getStorage().getUnderlying().createRecord((ORecordId) v.getRecord().getIdentity(), v.getRecord().toStream(), v.getRecord().getVersion(), ODocument.RECORD_TYPE, 0, null);
final ODistributedResponse result = createRemoteRecord(0, v.getRecord(), new String[] { serverInstance.get(0).getServerInstance().getDistributedManager().getLocalNodeName() });
Assert.assertFalse(result.getPayload() instanceof Throwable);
}
} finally {
graph.rollback();
}
banner("CREATE 10 RECORDS ONLY ON SERVER 0");
graph = localFactory1.getTx();
try {
for (int i = 0; i < 10; ++i) {
OrientVertex v = graph.addVertex("Employee", localCluster);
v.setProperty("status", "onlyServer0and1");
graph.getRawGraph().getStorage().getUnderlying().createRecord((ORecordId) v.getRecord().getIdentity(), v.getRecord().toStream(), v.getRecord().getVersion(), ODocument.RECORD_TYPE, 0, null);
}
} finally {
graph.rollback();
}
// TRY TO CREATE A RECORD TO START THE REPAIR
graph = localFactory1.getTx();
try {
OrientVertex v = graph.addVertex("Employee", localCluster);
v.setProperty("status", "check");
graph.commit();
} catch (ODistributedOperationException e) {
Assert.assertTrue(true);
} finally {
graph.shutdown();
}
Thread.sleep(5000);
banner("CHECK RECORDS...");
graph = localFactory0.getNoTx();
try {
Assert.assertEquals(21, graph.countVertices("Employee"));
} finally {
graph.shutdown();
}
graph = localFactory1.getNoTx();
try {
Assert.assertEquals(21, graph.countVertices("Employee"));
} finally {
graph.shutdown();
}
graph = localFactory2.getNoTx();
try {
Assert.assertEquals(21, graph.countVertices("Employee"));
} finally {
graph.shutdown();
}
}
use of com.tinkerpop.blueprints.impls.orient.OrientVertex in project orientdb by orientechnologies.
the class TestDistributedDatabaseRepair method testWinnerIsMajorityPlusVersion.
private void testWinnerIsMajorityPlusVersion(OrientGraphFactory localFactory0, OrientGraphFactory localFactory1, OrientGraphFactory localFactory2) throws Exception {
OrientBaseGraph graph = localFactory0.getTx();
OrientVertex product;
try {
product = graph.addVertex("class:ProductType");
product.setProperty("status", "ok");
} finally {
graph.shutdown();
}
banner("CORRUPT A RECORD IN SERVER 0");
graph = localFactory0.getNoTx();
try {
final OrientVertex product2 = graph.getVertex(product.getIdentity());
product2.getRecord().field("status", "corrupted0");
final ODistributedResponse result = updateRemoteRecord(0, product2.getRecord(), new String[] { serverInstance.get(0).getServerInstance().getDistributedManager().getLocalNodeName() });
Assert.assertFalse(result.getPayload() instanceof Throwable);
} finally {
graph.shutdown();
}
banner("CORRUPT A RECORD IN SERVER 1 WITH THE HIGHEST VERSION (=WINNER)");
graph = localFactory1.getNoTx();
try {
final OrientVertex product2 = graph.getVertex(product.getIdentity());
product2.getRecord().field("status", "thisIsTheMostRecent");
ORecordInternal.setVersion(product2.getRecord(), ORecordVersionHelper.setRollbackMode(1000));
ODistributedResponse result = updateRemoteRecord(1, product2.getRecord(), new String[] { serverInstance.get(1).getServerInstance().getDistributedManager().getLocalNodeName() });
Assert.assertFalse(result.getPayload() instanceof Throwable);
} finally {
graph.shutdown();
}
serverInstance.get(0).getServerInstance().getDistributedManager().getMessageService().getDatabase(getDatabaseName()).getDatabaseRepairer().enqueueRepairRecord((ORecordId) product.getIdentity());
Thread.sleep(3000);
banner("EXPECTING AUTO RECOVER ON ALL NODES...");
// TEST RECOVER IS CHANGED
graph = localFactory0.getNoTx();
try {
final OrientVertex product2 = graph.getVertex(product.getIdentity());
Assert.assertEquals("thisIsTheMostRecent", product2.getProperty("status"));
Assert.assertEquals(1000, product2.getRecord().getVersion());
} finally {
graph.shutdown();
}
graph = localFactory1.getNoTx();
try {
final OrientVertex product2 = graph.getVertex(product.getIdentity());
Assert.assertEquals("thisIsTheMostRecent", product2.getProperty("status"));
Assert.assertEquals(1000, product2.getRecord().getVersion());
} finally {
graph.shutdown();
}
graph = localFactory2.getNoTx();
try {
final OrientVertex product2 = graph.getVertex(product.getIdentity());
Assert.assertEquals("thisIsTheMostRecent", product2.getProperty("status"));
Assert.assertEquals(1000, product2.getRecord().getVersion());
} finally {
graph.shutdown();
}
}
use of com.tinkerpop.blueprints.impls.orient.OrientVertex in project orientdb by orientechnologies.
the class TestDistributedDatabaseRepair method testWinnerIsMajority.
private void testWinnerIsMajority(OrientGraphFactory localFactory0, OrientGraphFactory localFactory1, OrientGraphFactory localFactory2) throws Exception {
OrientBaseGraph graph = localFactory0.getTx();
OrientVertex product;
try {
product = graph.addVertex("class:ProductType");
product.setProperty("status", "ok");
} finally {
graph.shutdown();
}
banner("CORRUPT ONLY 1 RECORD IN SERVER 0");
graph = localFactory0.getNoTx();
try {
final OrientVertex product2 = graph.getVertex(product.getIdentity());
product2.getRecord().field("status", "corrupted0");
final ODistributedResponse result = updateRemoteRecord(0, product2.getRecord(), new String[] { serverInstance.get(0).getServerInstance().getDistributedManager().getLocalNodeName() });
Assert.assertFalse(result.getPayload() instanceof Throwable);
} finally {
graph.shutdown();
}
serverInstance.get(0).getServerInstance().getDistributedManager().getMessageService().getDatabase(getDatabaseName()).getDatabaseRepairer().enqueueRepairRecord((ORecordId) product.getIdentity());
Thread.sleep(3000);
banner("EXPECTING AUTO RECOVER ON ALL NODES...");
// TEST RECORD IS CHANGED
graph = localFactory0.getNoTx();
try {
final OrientVertex product2 = graph.getVertex(product.getIdentity());
Assert.assertEquals("ok", product2.getProperty("status"));
} finally {
graph.shutdown();
}
graph = localFactory1.getNoTx();
try {
final OrientVertex product2 = graph.getVertex(product.getIdentity());
Assert.assertEquals("ok", product2.getProperty("status"));
} finally {
graph.shutdown();
}
graph = localFactory2.getNoTx();
try {
final OrientVertex product2 = graph.getVertex(product.getIdentity());
Assert.assertEquals("ok", product2.getProperty("status"));
} finally {
graph.shutdown();
}
}
Aggregations