本文整理汇总了Java中com.thinkaurelius.titan.diskstorage.util.StandardBaseTransactionConfig.of方法的典型用法代码示例。如果您正苦于以下问题:Java StandardBaseTransactionConfig.of方法的具体用法?Java StandardBaseTransactionConfig.of怎么用?Java StandardBaseTransactionConfig.of使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.thinkaurelius.titan.diskstorage.util.StandardBaseTransactionConfig
的用法示例。
在下文中一共展示了StandardBaseTransactionConfig.of方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: simpleWriteAndQuery
import com.thinkaurelius.titan.diskstorage.util.StandardBaseTransactionConfig; //导入方法依赖的package包/类
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();
Thread.sleep(1500L); // Slightly longer than default 1s index.refresh_interval
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();
}
示例2: simpleWriteAndQuery
import com.thinkaurelius.titan.diskstorage.util.StandardBaseTransactionConfig; //导入方法依赖的package包/类
private void simpleWriteAndQuery(IndexProvider idx) throws BackendException, InterruptedException {
final Duration maxWrite = new StandardDuration(2000L, TimeUnit.MILLISECONDS);
final String storeName = "jvmlocal_test_store";
final KeyInformation.IndexRetriever indexRetriever = IndexProviderTest.getIndexRetriever(IndexProviderTest.getMapping(idx.getFeatures()));
BaseTransactionConfig txConfig = StandardBaseTransactionConfig.of(Timestamps.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();
Thread.sleep(1500L); // Slightly longer than default 1s index.refresh_interval
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();
}
示例3: testTimestampProvider
import com.thinkaurelius.titan.diskstorage.util.StandardBaseTransactionConfig; //导入方法依赖的package包/类
@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());
}
示例4: testTimestampProvider
import com.thinkaurelius.titan.diskstorage.util.StandardBaseTransactionConfig; //导入方法依赖的package包/类
@Test
public void testTimestampProvider() {
BaseTransactionConfig txcfg = StandardBaseTransactionConfig.of(Timestamps.NANO);
CassandraTransaction ct = new CassandraTransaction(txcfg);
assertEquals(Timestamps.NANO, ct.getConfiguration().getTimestampProvider());
txcfg = StandardBaseTransactionConfig.of(Timestamps.MICRO);
ct = new CassandraTransaction(txcfg);
assertEquals(Timestamps.MICRO, ct.getConfiguration().getTimestampProvider());
txcfg = StandardBaseTransactionConfig.of(Timestamps.MILLI);
ct = new CassandraTransaction(txcfg);
assertEquals(Timestamps.MILLI, ct.getConfiguration().getTimestampProvider());
}
示例5: getTxConfig
import com.thinkaurelius.titan.diskstorage.util.StandardBaseTransactionConfig; //导入方法依赖的package包/类
protected StandardBaseTransactionConfig getTxConfig() {
return StandardBaseTransactionConfig.of(times);
}
示例6: getConsistentTxConfig
import com.thinkaurelius.titan.diskstorage.util.StandardBaseTransactionConfig; //导入方法依赖的package包/类
protected StandardBaseTransactionConfig getConsistentTxConfig(StoreManager manager) {
return StandardBaseTransactionConfig.of(times,manager.getFeatures().getKeyConsistentTxConfig());
}
示例7: openTx
import com.thinkaurelius.titan.diskstorage.util.StandardBaseTransactionConfig; //导入方法依赖的package包/类
public IndexTransaction openTx() throws BackendException {
BaseTransactionConfig config = StandardBaseTransactionConfig.of(TimestampProviders.MILLI);
return new IndexTransaction(index, indexRetriever, config, Duration.ofMillis(2000L));
}
示例8: testLocksOnMultipleStores
import com.thinkaurelius.titan.diskstorage.util.StandardBaseTransactionConfig; //导入方法依赖的package包/类
@Test
public void testLocksOnMultipleStores() throws Exception {
final int numStores = 6;
Preconditions.checkState(numStores % 3 == 0);
final StaticBuffer key = BufferUtil.getLongBuffer(1);
final StaticBuffer col = BufferUtil.getLongBuffer(2);
final StaticBuffer val2 = BufferUtil.getLongBuffer(8);
// Create mocks
LockerProvider mockLockerProvider = createStrictMock(LockerProvider.class);
Locker mockLocker = createStrictMock(Locker.class);
// Create EVCSManager with mockLockerProvider
ExpectedValueCheckingStoreManager expManager =
new ExpectedValueCheckingStoreManager(manager[0], "multi_store_lock_mgr",
mockLockerProvider, Duration.ofMillis(100L));
// Begin EVCTransaction
BaseTransactionConfig txCfg = StandardBaseTransactionConfig.of(times);
ExpectedValueCheckingTransaction tx = expManager.beginTransaction(txCfg);
// openDatabase calls getLocker, and we do it numStores times
expect(mockLockerProvider.getLocker(anyObject(String.class))).andReturn(mockLocker).times(numStores);
// acquireLock calls writeLock, and we do it 2/3 * numStores times
mockLocker.writeLock(eq(new KeyColumn(key, col)), eq(tx.getConsistentTx()));
expectLastCall().times(numStores / 3 * 2);
// mutateMany calls checkLocks, and we do it 2/3 * numStores times
mockLocker.checkLocks(tx.getConsistentTx());
expectLastCall().times(numStores / 3 * 2);
replay(mockLockerProvider);
replay(mockLocker);
/*
* Acquire a lock on several distinct stores (numStores total distinct
* stores) and build mutations.
*/
ImmutableMap.Builder<String, Map<StaticBuffer, KCVMutation>> builder = ImmutableMap.builder();
for (int i = 0; i < numStores; i++) {
String storeName = "multi_store_lock_" + i;
KeyColumnValueStore s = expManager.openDatabase(storeName);
if (i % 3 < 2)
s.acquireLock(key, col, null, tx);
if (i % 3 > 0)
builder.put(storeName, ImmutableMap.of(key, new KCVMutation(ImmutableList.of(StaticArrayEntry.of(col, val2)), ImmutableList.<StaticBuffer>of())));
}
// Mutate
expManager.mutateMany(builder.build(), tx);
// Shutdown
expManager.close();
// Check the mocks
verify(mockLockerProvider);
verify(mockLocker);
}
示例9: openTx
import com.thinkaurelius.titan.diskstorage.util.StandardBaseTransactionConfig; //导入方法依赖的package包/类
public IndexTransaction openTx() throws BackendException {
BaseTransactionConfig config = StandardBaseTransactionConfig.of(Timestamps.MILLI);
return new IndexTransaction(index, indexRetriever, config, new StandardDuration(2000L, TimeUnit.MILLISECONDS));
}
示例10: testLocksOnMultipleStores
import com.thinkaurelius.titan.diskstorage.util.StandardBaseTransactionConfig; //导入方法依赖的package包/类
@Test
public void testLocksOnMultipleStores() throws Exception {
final int numStores = 6;
Preconditions.checkState(numStores % 3 == 0);
final StaticBuffer key = BufferUtil.getLongBuffer(1);
final StaticBuffer col = BufferUtil.getLongBuffer(2);
final StaticBuffer val2 = BufferUtil.getLongBuffer(8);
// Create mocks
LockerProvider mockLockerProvider = createStrictMock(LockerProvider.class);
Locker mockLocker = createStrictMock(Locker.class);
// Create EVCSManager with mockLockerProvider
ExpectedValueCheckingStoreManager expManager =
new ExpectedValueCheckingStoreManager(manager[0], "multi_store_lock_mgr",
mockLockerProvider, new StandardDuration(100L, TimeUnit.MILLISECONDS));
// Begin EVCTransaction
BaseTransactionConfig txCfg = StandardBaseTransactionConfig.of(times);
ExpectedValueCheckingTransaction tx = expManager.beginTransaction(txCfg);
// openDatabase calls getLocker, and we do it numStores times
expect(mockLockerProvider.getLocker(anyObject(String.class))).andReturn(mockLocker).times(numStores);
// acquireLock calls writeLock, and we do it 2/3 * numStores times
mockLocker.writeLock(eq(new KeyColumn(key, col)), eq(tx.getConsistentTx()));
expectLastCall().times(numStores / 3 * 2);
// mutateMany calls checkLocks, and we do it 2/3 * numStores times
mockLocker.checkLocks(tx.getConsistentTx());
expectLastCall().times(numStores / 3 * 2);
replay(mockLockerProvider);
replay(mockLocker);
/*
* Acquire a lock on several distinct stores (numStores total distinct
* stores) and build mutations.
*/
ImmutableMap.Builder<String, Map<StaticBuffer, KCVMutation>> builder = ImmutableMap.builder();
for (int i = 0; i < numStores; i++) {
String storeName = "multi_store_lock_" + i;
KeyColumnValueStore s = expManager.openDatabase(storeName);
if (i % 3 < 2)
s.acquireLock(key, col, null, tx);
if (i % 3 > 0)
builder.put(storeName, ImmutableMap.of(key, new KCVMutation(ImmutableList.of(StaticArrayEntry.of(col, val2)), ImmutableList.<StaticBuffer>of())));
}
// Mutate
expManager.mutateMany(builder.build(), tx);
// Shutdown
expManager.close();
// Check the mocks
verify(mockLockerProvider);
verify(mockLocker);
}