Search in sources :

Example 1 with WriteConfiguration

use of com.thinkaurelius.titan.diskstorage.configuration.WriteConfiguration in project titan by thinkaurelius.

the class AbstractTitanGraphProvider method clear.

//    @Override
//    public <ID> ID reconstituteGraphSONIdentifier(final Class<? extends Element> clazz, final Object id) {
//        if (Edge.class.isAssignableFrom(clazz)) {
//            // TitanGraphSONModule toStrings the edgeid - expect a String value for the id
//            if (!(id instanceof String)) throw new RuntimeException("Expected a String value for the RelationIdentifier");
//            return (ID) RelationIdentifier.parse((String) id);
//        } else {
//            return (ID) id;
//        }
//    }
@Override
public void clear(Graph g, final Configuration configuration) throws Exception {
    if (null != g) {
        while (g instanceof WrappedGraph) g = ((WrappedGraph<? extends Graph>) g).getBaseGraph();
        TitanGraph graph = (TitanGraph) g;
        if (graph.isOpen()) {
            if (g.tx().isOpen())
                g.tx().rollback();
            g.close();
        }
    }
    WriteConfiguration config = new CommonsConfiguration(configuration);
    BasicConfiguration readConfig = new BasicConfiguration(GraphDatabaseConfiguration.ROOT_NS, config, BasicConfiguration.Restriction.NONE);
    if (readConfig.has(GraphDatabaseConfiguration.STORAGE_BACKEND)) {
        TitanGraphBaseTest.clearGraph(config);
    }
}
Also used : StandardTitanGraph(com.thinkaurelius.titan.graphdb.database.StandardTitanGraph) TitanGraph(com.thinkaurelius.titan.core.TitanGraph) Graph(org.apache.tinkerpop.gremlin.structure.Graph) StandardTitanGraph(com.thinkaurelius.titan.graphdb.database.StandardTitanGraph) TitanGraph(com.thinkaurelius.titan.core.TitanGraph) WrappedGraph(org.apache.tinkerpop.gremlin.structure.util.wrapped.WrappedGraph) CommonsConfiguration(com.thinkaurelius.titan.diskstorage.configuration.backend.CommonsConfiguration) WriteConfiguration(com.thinkaurelius.titan.diskstorage.configuration.WriteConfiguration) BasicConfiguration(com.thinkaurelius.titan.diskstorage.configuration.BasicConfiguration) WrappedGraph(org.apache.tinkerpop.gremlin.structure.util.wrapped.WrappedGraph)

Example 2 with WriteConfiguration

use of com.thinkaurelius.titan.diskstorage.configuration.WriteConfiguration in project titan by thinkaurelius.

the class CassandraGraphTest method testGraphConfigUsedByThreadBoundTx.

@Test
public void testGraphConfigUsedByThreadBoundTx() {
    close();
    WriteConfiguration wc = getConfiguration();
    wc.set(ConfigElement.getPath(CASSANDRA_READ_CONSISTENCY), "ALL");
    wc.set(ConfigElement.getPath(CASSANDRA_WRITE_CONSISTENCY), "LOCAL_QUORUM");
    graph = (StandardTitanGraph) TitanFactory.open(wc);
    StandardTitanTx tx = (StandardTitanTx) graph.getCurrentThreadTx();
    assertEquals("ALL", tx.getTxHandle().getBaseTransactionConfig().getCustomOptions().get(AbstractCassandraStoreManager.CASSANDRA_READ_CONSISTENCY));
    assertEquals("LOCAL_QUORUM", tx.getTxHandle().getBaseTransactionConfig().getCustomOptions().get(AbstractCassandraStoreManager.CASSANDRA_WRITE_CONSISTENCY));
}
Also used : WriteConfiguration(com.thinkaurelius.titan.diskstorage.configuration.WriteConfiguration) StandardTitanTx(com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx) Test(org.junit.Test)

Example 3 with WriteConfiguration

use of com.thinkaurelius.titan.diskstorage.configuration.WriteConfiguration in project titan by thinkaurelius.

the class CassandraGraphTest method testGraphConfigUsedByTx.

@Test
public void testGraphConfigUsedByTx() {
    close();
    WriteConfiguration wc = getConfiguration();
    wc.set(ConfigElement.getPath(CASSANDRA_READ_CONSISTENCY), "TWO");
    wc.set(ConfigElement.getPath(CASSANDRA_WRITE_CONSISTENCY), "THREE");
    graph = (StandardTitanGraph) TitanFactory.open(wc);
    StandardTitanTx tx = (StandardTitanTx) graph.newTransaction();
    assertEquals("TWO", tx.getTxHandle().getBaseTransactionConfig().getCustomOptions().get(AbstractCassandraStoreManager.CASSANDRA_READ_CONSISTENCY));
    assertEquals("THREE", tx.getTxHandle().getBaseTransactionConfig().getCustomOptions().get(AbstractCassandraStoreManager.CASSANDRA_WRITE_CONSISTENCY));
    tx.rollback();
}
Also used : WriteConfiguration(com.thinkaurelius.titan.diskstorage.configuration.WriteConfiguration) StandardTitanTx(com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx) Test(org.junit.Test)

Example 4 with WriteConfiguration

use of com.thinkaurelius.titan.diskstorage.configuration.WriteConfiguration in project titan by thinkaurelius.

the class TitanOperationCountingTest method getConfiguration.

@Override
public WriteConfiguration getConfiguration() {
    WriteConfiguration config = getBaseConfiguration();
    ModifiableConfiguration mconf = new ModifiableConfiguration(GraphDatabaseConfiguration.ROOT_NS, config, BasicConfiguration.Restriction.NONE);
    mconf.set(BASIC_METRICS, true);
    mconf.set(METRICS_MERGE_STORES, false);
    mconf.set(PROPERTY_PREFETCHING, false);
    mconf.set(DB_CACHE, false);
    return config;
}
Also used : ModifiableConfiguration(com.thinkaurelius.titan.diskstorage.configuration.ModifiableConfiguration) WriteConfiguration(com.thinkaurelius.titan.diskstorage.configuration.WriteConfiguration)

Example 5 with WriteConfiguration

use of com.thinkaurelius.titan.diskstorage.configuration.WriteConfiguration in project titan by thinkaurelius.

the class TitanPartitionGraphTest method getConfiguration.

@Override
public WriteConfiguration getConfiguration() {
    WriteConfiguration config = getBaseConfiguration();
    ModifiableConfiguration mconf = new ModifiableConfiguration(GraphDatabaseConfiguration.ROOT_NS, config, BasicConfiguration.Restriction.NONE);
    // Let GraphDatabaseConfiguration's config freezer set CLUSTER_PARTITION
    //mconf.set(GraphDatabaseConfiguration.CLUSTER_PARTITION,true);
    mconf.set(GraphDatabaseConfiguration.CLUSTER_MAX_PARTITIONS, numPartitions);
    //uses SimpleBulkPlacementStrategy by default
    mconf.set(SimpleBulkPlacementStrategy.CONCURRENT_PARTITIONS, 3 * numPartitions);
    return config;
}
Also used : ModifiableConfiguration(com.thinkaurelius.titan.diskstorage.configuration.ModifiableConfiguration) WriteConfiguration(com.thinkaurelius.titan.diskstorage.configuration.WriteConfiguration)

Aggregations

WriteConfiguration (com.thinkaurelius.titan.diskstorage.configuration.WriteConfiguration)7 Test (org.junit.Test)4 StandardTitanTx (com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx)3 ModifiableConfiguration (com.thinkaurelius.titan.diskstorage.configuration.ModifiableConfiguration)2 TitanConfigurationException (com.thinkaurelius.titan.core.TitanConfigurationException)1 TitanGraph (com.thinkaurelius.titan.core.TitanGraph)1 BasicConfiguration (com.thinkaurelius.titan.diskstorage.configuration.BasicConfiguration)1 CommonsConfiguration (com.thinkaurelius.titan.diskstorage.configuration.backend.CommonsConfiguration)1 StandardTitanGraph (com.thinkaurelius.titan.graphdb.database.StandardTitanGraph)1 Duration (java.time.Duration)1 Graph (org.apache.tinkerpop.gremlin.structure.Graph)1 WrappedGraph (org.apache.tinkerpop.gremlin.structure.util.wrapped.WrappedGraph)1