Search in sources :

Example 1 with Backend

use of com.thinkaurelius.titan.diskstorage.Backend in project titan by thinkaurelius.

the class TitanGraphBaseTest method clearGraph.

public static void clearGraph(WriteConfiguration config) throws BackendException {
    ModifiableConfiguration adjustedConfig = new ModifiableConfiguration(GraphDatabaseConfiguration.ROOT_NS, config.copy(), BasicConfiguration.Restriction.NONE);
    adjustedConfig.set(GraphDatabaseConfiguration.LOCK_LOCAL_MEDIATOR_GROUP, "tmp");
    adjustedConfig.set(GraphDatabaseConfiguration.UNIQUE_INSTANCE_ID, "inst");
    Backend backend = new Backend(adjustedConfig);
    backend.initialize(adjustedConfig);
    backend.clearStorage();
}
Also used : Backend(com.thinkaurelius.titan.diskstorage.Backend)

Example 2 with Backend

use of com.thinkaurelius.titan.diskstorage.Backend in project titan by thinkaurelius.

the class TitanIndexTest 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();
    TitanVertex 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
    TitanTransaction vertexDeleter = graph.newTransaction();
    TitanTransaction 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();
}
Also used : TitanVertex(com.thinkaurelius.titan.core.TitanVertex) Backend(com.thinkaurelius.titan.diskstorage.Backend) TitanTransaction(com.thinkaurelius.titan.core.TitanTransaction) PropertyKey(com.thinkaurelius.titan.core.PropertyKey)

Example 3 with Backend

use of com.thinkaurelius.titan.diskstorage.Backend in project titan by thinkaurelius.

the class GraphDatabaseConfiguration method getBackend.

public Backend getBackend() {
    Configuration storageconfig = configuration.subset(STORAGE_NAMESPACE);
    Configuration metricsconfig = configuration.subset(METRICS_NAMESPACE);
    Backend backend = new Backend(storageconfig, metricsconfig);
    backend.initialize(storageconfig);
    storeFeatures = backend.getStoreFeatures();
    return backend;
}
Also used : Backend(com.thinkaurelius.titan.diskstorage.Backend) Configuration(org.apache.commons.configuration.Configuration) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) BaseConfiguration(org.apache.commons.configuration.BaseConfiguration)

Aggregations

Backend (com.thinkaurelius.titan.diskstorage.Backend)3 PropertyKey (com.thinkaurelius.titan.core.PropertyKey)1 TitanTransaction (com.thinkaurelius.titan.core.TitanTransaction)1 TitanVertex (com.thinkaurelius.titan.core.TitanVertex)1 BaseConfiguration (org.apache.commons.configuration.BaseConfiguration)1 Configuration (org.apache.commons.configuration.Configuration)1 PropertiesConfiguration (org.apache.commons.configuration.PropertiesConfiguration)1