use of com.thinkaurelius.titan.diskstorage.BaseTransactionConfig in project titan by thinkaurelius.
the class ElasticSearchConfigTest method simpleWriteAndQuery.
private void simpleWriteAndQuery(IndexProvider idx) throws BackendException, InterruptedException {
final Duration maxWrite = Duration.ofMillis(2000L);
final String storeName = "jvmlocal_test_store";
final KeyInformation.IndexRetriever indexRetriever = IndexProviderTest.getIndexRetriever(IndexProviderTest.getMapping(idx.getFeatures()));
BaseTransactionConfig txConfig = StandardBaseTransactionConfig.of(TimestampProviders.MILLI);
IndexTransaction itx = new IndexTransaction(idx, indexRetriever, txConfig, maxWrite);
assertEquals(0, itx.query(new IndexQuery(storeName, PredicateCondition.of(IndexProviderTest.NAME, Text.PREFIX, "ali"))).size());
itx.add(storeName, "doc", IndexProviderTest.NAME, "alice", false);
itx.commit();
// Slightly longer than default 1s index.refresh_interval
Thread.sleep(1500L);
itx = new IndexTransaction(idx, indexRetriever, txConfig, maxWrite);
assertEquals(0, itx.query(new IndexQuery(storeName, PredicateCondition.of(IndexProviderTest.NAME, Text.PREFIX, "zed"))).size());
assertEquals(1, itx.query(new IndexQuery(storeName, PredicateCondition.of(IndexProviderTest.NAME, Text.PREFIX, "ali"))).size());
itx.rollback();
}
use of com.thinkaurelius.titan.diskstorage.BaseTransactionConfig in project titan by thinkaurelius.
the class CassandraTransactionTest method testTimestampProvider.
@Test
public void testTimestampProvider() {
BaseTransactionConfig txcfg = StandardBaseTransactionConfig.of(TimestampProviders.NANO);
CassandraTransaction ct = new CassandraTransaction(txcfg);
assertEquals(TimestampProviders.NANO, ct.getConfiguration().getTimestampProvider());
txcfg = StandardBaseTransactionConfig.of(TimestampProviders.MICRO);
ct = new CassandraTransaction(txcfg);
assertEquals(TimestampProviders.MICRO, ct.getConfiguration().getTimestampProvider());
txcfg = StandardBaseTransactionConfig.of(TimestampProviders.MILLI);
ct = new CassandraTransaction(txcfg);
assertEquals(TimestampProviders.MILLI, ct.getConfiguration().getTimestampProvider());
}
use of com.thinkaurelius.titan.diskstorage.BaseTransactionConfig in project titan by thinkaurelius.
the class ExpectedValueCheckingStoreManager method beginTransaction.
@Override
public ExpectedValueCheckingTransaction beginTransaction(BaseTransactionConfig configuration) throws BackendException {
// Get a transaction without any guarantees about strong consistency
StoreTransaction inconsistentTx = manager.beginTransaction(configuration);
// Get a transaction that provides global strong consistency
Configuration customOptions = new MergedConfiguration(storeFeatures.getKeyConsistentTxConfig(), configuration.getCustomOptions());
BaseTransactionConfig consistentTxCfg = new StandardBaseTransactionConfig.Builder(configuration).customOptions(customOptions).build();
StoreTransaction strongConsistentTx = manager.beginTransaction(consistentTxCfg);
// Return a wrapper around both the inconsistent and consistent store transactions
ExpectedValueCheckingTransaction wrappedTx = new ExpectedValueCheckingTransaction(inconsistentTx, strongConsistentTx, maxReadTime);
return wrappedTx;
}
Aggregations