1 package com.thinkaurelius.titan.diskstorage.cassandra;
3 import static com.thinkaurelius.titan.diskstorage.cassandra.AbstractCassandraStoreManager.CASSANDRA_READ_CONSISTENCY;
4 import static com.thinkaurelius.titan.diskstorage.cassandra.AbstractCassandraStoreManager.CASSANDRA_WRITE_CONSISTENCY;
6 import org.slf4j.Logger;
7 import org.slf4j.LoggerFactory;
9 import com.google.common.base.Preconditions;
10 import com.thinkaurelius.titan.diskstorage.BaseTransactionConfig;
11 import com.thinkaurelius.titan.diskstorage.common.AbstractStoreTransaction;
12 import com.thinkaurelius.titan.diskstorage.keycolumnvalue.StoreTransaction;
14 public class CassandraTransaction extends AbstractStoreTransaction {
16 private static final Logger log = LoggerFactory.getLogger(CassandraTransaction.class);
18 private final CLevel read;
19 private final CLevel write;
21 public CassandraTransaction(BaseTransactionConfig c) {
23 read = CLevel.parse(getConfiguration().getCustomOption(CASSANDRA_READ_CONSISTENCY));
24 write = CLevel.parse(getConfiguration().getCustomOption(CASSANDRA_WRITE_CONSISTENCY));
25 log.debug("Created {}", this.toString());
28 public CLevel getReadConsistencyLevel() {
32 public CLevel getWriteConsistencyLevel() {
36 public static CassandraTransaction getTx(StoreTransaction txh) {
37 Preconditions.checkArgument(txh != null);
38 Preconditions.checkArgument(txh instanceof CassandraTransaction, "Unexpected transaction type %s", txh.getClass().getName());
39 return (CassandraTransaction) txh;
42 public String toString() {
43 StringBuilder sb = new StringBuilder(64);
44 sb.append("CassandraTransaction@");
45 sb.append(Integer.toHexString(hashCode()));