Search in sources :

Example 1 with StandardTitanTx

use of com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx 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 2 with StandardTitanTx

use of com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx 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 3 with StandardTitanTx

use of com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx in project titan by thinkaurelius.

the class TitanH1OutputFormat method abort.

void abort(TaskAttemptID id) {
    StandardTitanTx tx = transactions.remove(id);
    if (null == tx) {
        log.warn("Detected concurrency in task abort");
        return;
    }
    tx.rollback();
}
Also used : StandardTitanTx(com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx)

Example 4 with StandardTitanTx

use of com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx in project titan by thinkaurelius.

the class TitanH1OutputFormat method commit.

void commit(TaskAttemptID id) {
    StandardTitanTx tx = transactions.remove(id);
    if (null == tx) {
        log.warn("Detected concurrency in task commit");
        return;
    }
    tx.commit();
}
Also used : StandardTitanTx(com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx)

Example 5 with StandardTitanTx

use of com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx in project titan by thinkaurelius.

the class IndexRemoveJob method getQueries.

@Override
public List<SliceQuery> getQueries() {
    if (isGlobalGraphIndex()) {
        //Everything
        return ImmutableList.of(new SliceQuery(BufferUtil.zeroBuffer(1), BufferUtil.oneBuffer(128)));
    } else {
        RelationTypeIndexWrapper wrapper = (RelationTypeIndexWrapper) index;
        InternalRelationType wrappedType = wrapper.getWrappedType();
        Direction direction = null;
        for (Direction dir : Direction.values()) if (wrappedType.isUnidirected(dir))
            direction = dir;
        assert direction != null;
        StandardTitanTx tx = (StandardTitanTx) graph.get().buildTransaction().readOnly().start();
        try {
            QueryContainer qc = new QueryContainer(tx);
            qc.addQuery().type(wrappedType).direction(direction).relations();
            return qc.getSliceQueries();
        } finally {
            tx.rollback();
        }
    }
}
Also used : RelationTypeIndexWrapper(com.thinkaurelius.titan.graphdb.database.management.RelationTypeIndexWrapper) InternalRelationType(com.thinkaurelius.titan.graphdb.internal.InternalRelationType) Direction(org.apache.tinkerpop.gremlin.structure.Direction) StandardTitanTx(com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx) SliceQuery(com.thinkaurelius.titan.diskstorage.keycolumnvalue.SliceQuery) QueryContainer(com.thinkaurelius.titan.graphdb.olap.QueryContainer)

Aggregations

StandardTitanTx (com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx)21 Test (org.junit.Test)5 RelationType (com.thinkaurelius.titan.core.RelationType)3 TitanVertex (com.thinkaurelius.titan.core.TitanVertex)3 WriteConfiguration (com.thinkaurelius.titan.diskstorage.configuration.WriteConfiguration)3 InternalRelationType (com.thinkaurelius.titan.graphdb.internal.InternalRelationType)3 IOException (java.io.IOException)2 Map (java.util.Map)2 ExecutionException (java.util.concurrent.ExecutionException)2 Direction (org.apache.tinkerpop.gremlin.structure.Direction)2 TitanEdge (com.thinkaurelius.titan.core.TitanEdge)1 TitanElement (com.thinkaurelius.titan.core.TitanElement)1 TitanException (com.thinkaurelius.titan.core.TitanException)1 TitanGraph (com.thinkaurelius.titan.core.TitanGraph)1 TitanRelation (com.thinkaurelius.titan.core.TitanRelation)1 TitanTransaction (com.thinkaurelius.titan.core.TitanTransaction)1 TitanVertexProperty (com.thinkaurelius.titan.core.TitanVertexProperty)1 EntryList (com.thinkaurelius.titan.diskstorage.EntryList)1 StorageException (com.thinkaurelius.titan.diskstorage.StorageException)1 ModifiableConfiguration (com.thinkaurelius.titan.diskstorage.configuration.ModifiableConfiguration)1