Search in sources :

Example 1 with BaseTransactionConfig

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();
}
Also used : Duration(java.time.Duration) BaseTransactionConfig(com.thinkaurelius.titan.diskstorage.BaseTransactionConfig) StandardBaseTransactionConfig(com.thinkaurelius.titan.diskstorage.util.StandardBaseTransactionConfig)

Example 2 with BaseTransactionConfig

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());
}
Also used : StandardBaseTransactionConfig(com.thinkaurelius.titan.diskstorage.util.StandardBaseTransactionConfig) BaseTransactionConfig(com.thinkaurelius.titan.diskstorage.BaseTransactionConfig) Test(org.junit.Test)

Example 3 with BaseTransactionConfig

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;
}
Also used : MergedConfiguration(com.thinkaurelius.titan.diskstorage.configuration.MergedConfiguration) Configuration(com.thinkaurelius.titan.diskstorage.configuration.Configuration) MergedConfiguration(com.thinkaurelius.titan.diskstorage.configuration.MergedConfiguration) StandardBaseTransactionConfig(com.thinkaurelius.titan.diskstorage.util.StandardBaseTransactionConfig) BaseTransactionConfig(com.thinkaurelius.titan.diskstorage.BaseTransactionConfig)

Aggregations

BaseTransactionConfig (com.thinkaurelius.titan.diskstorage.BaseTransactionConfig)3 StandardBaseTransactionConfig (com.thinkaurelius.titan.diskstorage.util.StandardBaseTransactionConfig)3 Configuration (com.thinkaurelius.titan.diskstorage.configuration.Configuration)1 MergedConfiguration (com.thinkaurelius.titan.diskstorage.configuration.MergedConfiguration)1 Duration (java.time.Duration)1 Test (org.junit.Test)1