use of org.janusgraph.diskstorage.Backend in project janusgraph by JanusGraph.
the class JanusGraphIndexTest method testNestedWrites.
private void testNestedWrites(String initialValue, String updatedValue) throws BackendException {
// This method touches a single vertex with multiple transactions,
// leading to deadlock under BDB and cascading test failures. Check for
// the hasTxIsolation() store feature, which is currently true for BDB
// but false for HBase/Cassandra. This is kind of a hack; a more robust
// approach might implement different methods/assertions depending on
// whether the store is capable of deadlocking or detecting conflicting
// writes and aborting a transaction.
Backend b = null;
try {
b = graph.getConfiguration().getBackend();
if (b.getStoreFeatures().hasTxIsolation()) {
log.info("Skipping " + getClass().getSimpleName() + "." + methodName.getMethodName());
return;
}
} finally {
if (null != b)
b.close();
}
final String propName = "foo";
// Write schema and one vertex
PropertyKey prop = makeKey(propName, String.class);
createExternalVertexIndex(prop, INDEX);
finishSchema();
JanusGraphVertex v = graph.addVertex();
if (null != initialValue)
v.property(VertexProperty.Cardinality.single, propName, initialValue);
graph.tx().commit();
Object id = v.id();
// Open two transactions and modify the same vertex
JanusGraphTransaction vertexDeleter = graph.newTransaction();
JanusGraphTransaction propDeleter = graph.newTransaction();
getV(vertexDeleter, id).remove();
if (null == updatedValue)
getV(propDeleter, id).property(propName).remove();
else
getV(propDeleter, id).property(VertexProperty.Cardinality.single, propName, updatedValue);
vertexDeleter.commit();
propDeleter.commit();
// The vertex must not exist after deletion
graph.tx().rollback();
assertEquals(null, getV(graph, id));
assertEmpty(graph.query().has(propName).vertices());
if (null != updatedValue)
assertEmpty(graph.query().has(propName, updatedValue).vertices());
graph.tx().rollback();
}
use of org.janusgraph.diskstorage.Backend in project janusgraph by JanusGraph.
the class JanusGraphIndexTest method testClearStorage.
/**
* Ensure clearing storage actually removes underlying graph and index databases.
* @throws Exception
*/
@Test
public void testClearStorage() throws Exception {
GraphOfTheGodsFactory.load(graph);
tearDown();
config.set(ConfigElement.getPath(GraphDatabaseConfiguration.DROP_ON_CLEAR), true);
final Backend backend = getBackend(config, false);
assertStorageExists(backend, true);
clearGraph(config);
try {
backend.close();
} catch (Exception e) {
/* Most backends do not support closing after clearing */
}
try (final Backend newBackend = getBackend(config, false)) {
assertStorageExists(newBackend, false);
}
}
Aggregations