当前位置: 首页>>代码示例>>Java>>正文


Java ExpectedValueCheckingStoreManager类代码示例

本文整理汇总了Java中com.thinkaurelius.titan.diskstorage.locking.consistentkey.ExpectedValueCheckingStoreManager的典型用法代码示例。如果您正苦于以下问题:Java ExpectedValueCheckingStoreManager类的具体用法?Java ExpectedValueCheckingStoreManager怎么用?Java ExpectedValueCheckingStoreManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ExpectedValueCheckingStoreManager类属于com.thinkaurelius.titan.diskstorage.locking.consistentkey包,在下文中一共展示了ExpectedValueCheckingStoreManager类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setupMocks

import com.thinkaurelius.titan.diskstorage.locking.consistentkey.ExpectedValueCheckingStoreManager; //导入依赖的package包/类
@Before
public void setupMocks() throws BackendException {

    // Initialize mock controller
    ctrl = EasyMock.createStrictControl();
    ctrl.checkOrder(true);

    // Setup some config mocks and objects
    backingManager = ctrl.createMock(KeyColumnValueStoreManager.class);
    lockerProvider = ctrl.createMock(LockerProvider.class);
    globalConfig = GraphDatabaseConfiguration.buildGraphConfiguration();
    localConfig = GraphDatabaseConfiguration.buildGraphConfiguration();
    defaultConfig = GraphDatabaseConfiguration.buildGraphConfiguration();
    // Set some properties on the configs, just so that global/local/default can be easily distinguished
    globalConfig.set(GraphDatabaseConfiguration.UNIQUE_INSTANCE_ID, "global");
    localConfig.set(GraphDatabaseConfiguration.UNIQUE_INSTANCE_ID, "local");
    defaultConfig.set(GraphDatabaseConfiguration.UNIQUE_INSTANCE_ID, "default");
    defaultTxConfig = new StandardBaseTransactionConfig.Builder().customOptions(defaultConfig).timestampProvider(TimestampProviders.MICRO).build();
    backingFeatures = new StandardStoreFeatures.Builder().keyConsistent(globalConfig, localConfig).build();


    // Setup behavior specification starts below this line


    // 1. Construct manager
    // The EVCSManager ctor retrieves the backing store's features and stores it in an instance field
    expect(backingManager.getFeatures()).andReturn(backingFeatures).once();

    // 2. Begin transaction
    // EVCTx begins two transactions on the backingManager: one with globalConfig and one with localConfig
    // The capture is used in the @After method to check the config
    txConfigCapture = new Capture<BaseTransactionConfig>(CaptureType.ALL);
    inconsistentTx = ctrl.createMock(StoreTransaction.class);
    consistentTx = ctrl.createMock(StoreTransaction.class);
    expect(backingManager.beginTransaction(capture(txConfigCapture))).andReturn(inconsistentTx);
    expect(backingManager.beginTransaction(capture(txConfigCapture))).andReturn(consistentTx);

    // 3. Open a database
    backingLocker = ctrl.createMock(Locker.class);
    backingStore = ctrl.createMock(KeyColumnValueStore.class);
    expect(backingManager.openDatabase(STORE_NAME)).andReturn(backingStore);
    expect(backingStore.getName()).andReturn(STORE_NAME);
    expect(lockerProvider.getLocker(LOCKER_NAME)).andReturn(backingLocker);

    // Carry out setup behavior against mocks
    ctrl.replay();
    // 1. Construct manager
    expectManager = new ExpectedValueCheckingStoreManager(backingManager, LOCK_SUFFIX, lockerProvider, Duration.ofSeconds(1L));
    // 2. Begin transaction
    expectTx = expectManager.beginTransaction(defaultTxConfig);
    // 3. Open a database
    expectStore = expectManager.openDatabase(STORE_NAME);

    // Verify behavior and reset the mocks for test methods to use
    ctrl.verify();
    ctrl.reset();
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:58,代码来源:ExpectedValueCheckingTest.java

示例2: testLocksOnMultipleStores

import com.thinkaurelius.titan.diskstorage.locking.consistentkey.ExpectedValueCheckingStoreManager; //导入依赖的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);
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:63,代码来源:LockKeyColumnValueStoreTest.java

示例3: Backend

import com.thinkaurelius.titan.diskstorage.locking.consistentkey.ExpectedValueCheckingStoreManager; //导入依赖的package包/类
public Backend(Configuration configuration) {
    this.configuration = configuration;

    KeyColumnValueStoreManager manager = getStorageManager(configuration);
    if (configuration.get(BASIC_METRICS)) {
        storeManager = new MetricInstrumentedStoreManager(manager,METRICS_STOREMANAGER_NAME,configuration.get(METRICS_MERGE_STORES),METRICS_MERGED_STORE);
    } else {
        storeManager = manager;
    }
    indexes = getIndexes(configuration);
    storeFeatures = storeManager.getFeatures();

    mgmtLogManager = getKCVSLogManager(MANAGEMENT_LOG);
    txLogManager = getKCVSLogManager(TRANSACTION_LOG);
    userLogManager = getLogManager(USER_LOG);


    cacheEnabled = !configuration.get(STORAGE_BATCH) && configuration.get(DB_CACHE);

    int bufferSizeTmp = configuration.get(BUFFER_SIZE);
    Preconditions.checkArgument(bufferSizeTmp > 0, "Buffer size must be positive");
    if (!storeFeatures.hasBatchMutation()) {
        bufferSize = Integer.MAX_VALUE;
    } else bufferSize = bufferSizeTmp;

    maxWriteTime = configuration.get(STORAGE_WRITE_WAITTIME);
    maxReadTime = configuration.get(STORAGE_READ_WAITTIME);

    if (!storeFeatures.hasLocking()) {
        Preconditions.checkArgument(storeFeatures.isKeyConsistent(),"Store needs to support some form of locking");
        storeManagerLocking = new ExpectedValueCheckingStoreManager(storeManager,LOCK_STORE_SUFFIX,this,maxReadTime);
    } else {
        storeManagerLocking = storeManager;
    }

    if (configuration.get(PARALLEL_BACKEND_OPS)) {
        int poolsize = Runtime.getRuntime().availableProcessors() * THREAD_POOL_SIZE_SCALE_FACTOR;
        threadPool = Executors.newFixedThreadPool(poolsize);
        log.info("Initiated backend operations thread pool of size {}", poolsize);
    } else {
        threadPool = null;
    }

    final String lockBackendName = configuration.get(LOCK_BACKEND);
    if (REGISTERED_LOCKERS.containsKey(lockBackendName)) {
        lockerCreator = REGISTERED_LOCKERS.get(lockBackendName);
    } else {
        throw new TitanConfigurationException("Unknown lock backend \"" +
                lockBackendName + "\".  Known lock backends: " +
                Joiner.on(", ").join(REGISTERED_LOCKERS.keySet()) + ".");
    }
    // Never used for backends that have innate transaction support, but we
    // want to maintain the non-null invariant regardless; it will default
    // to connsistentkey impl if none is specified
    Preconditions.checkNotNull(lockerCreator);

    scanner = new StandardScanner(storeManager);
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:59,代码来源:Backend.java

示例4: setupMocks

import com.thinkaurelius.titan.diskstorage.locking.consistentkey.ExpectedValueCheckingStoreManager; //导入依赖的package包/类
@Before
public void setupMocks() throws BackendException {

    // Initialize mock controller
    ctrl = EasyMock.createStrictControl();
    ctrl.checkOrder(true);

    // Setup some config mocks and objects
    backingManager = ctrl.createMock(KeyColumnValueStoreManager.class);
    lockerProvider = ctrl.createMock(LockerProvider.class);
    globalConfig = GraphDatabaseConfiguration.buildConfiguration();
    localConfig = GraphDatabaseConfiguration.buildConfiguration();
    defaultConfig = GraphDatabaseConfiguration.buildConfiguration();
    // Set some properties on the configs, just so that global/local/default can be easily distinguished
    globalConfig.set(GraphDatabaseConfiguration.UNIQUE_INSTANCE_ID, "global");
    localConfig.set(GraphDatabaseConfiguration.UNIQUE_INSTANCE_ID, "local");
    defaultConfig.set(GraphDatabaseConfiguration.UNIQUE_INSTANCE_ID, "default");
    defaultTxConfig = new StandardBaseTransactionConfig.Builder().customOptions(defaultConfig).timestampProvider(Timestamps.MICRO).build();
    backingFeatures = new StandardStoreFeatures.Builder().keyConsistent(globalConfig, localConfig).build();


    // Setup behavior specification starts below this line


    // 1. Construct manager
    // The EVCSManager ctor retrieves the backing store's features and stores it in an instance field
    expect(backingManager.getFeatures()).andReturn(backingFeatures).once();

    // 2. Begin transaction
    // EVCTx begins two transactions on the backingManager: one with globalConfig and one with localConfig
    // The capture is used in the @After method to check the config
    txConfigCapture = new Capture<BaseTransactionConfig>(CaptureType.ALL);
    inconsistentTx = ctrl.createMock(StoreTransaction.class);
    consistentTx = ctrl.createMock(StoreTransaction.class);
    expect(backingManager.beginTransaction(capture(txConfigCapture))).andReturn(inconsistentTx);
    expect(backingManager.beginTransaction(capture(txConfigCapture))).andReturn(consistentTx);

    // 3. Open a database
    backingLocker = ctrl.createMock(Locker.class);
    backingStore = ctrl.createMock(KeyColumnValueStore.class);
    expect(backingManager.openDatabase(STORE_NAME)).andReturn(backingStore);
    expect(backingStore.getName()).andReturn(STORE_NAME);
    expect(lockerProvider.getLocker(LOCKER_NAME)).andReturn(backingLocker);

    // Carry out setup behavior against mocks
    ctrl.replay();
    // 1. Construct manager
    expectManager = new ExpectedValueCheckingStoreManager(backingManager, LOCK_SUFFIX, lockerProvider, new StandardDuration(1L, TimeUnit.SECONDS));
    // 2. Begin transaction
    expectTx = expectManager.beginTransaction(defaultTxConfig);
    // 3. Open a database
    expectStore = expectManager.openDatabase(STORE_NAME);

    // Verify behavior and reset the mocks for test methods to use
    ctrl.verify();
    ctrl.reset();
}
 
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:58,代码来源:ExpectedValueCheckingTest.java

示例5: testLocksOnMultipleStores

import com.thinkaurelius.titan.diskstorage.locking.consistentkey.ExpectedValueCheckingStoreManager; //导入依赖的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);
}
 
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:63,代码来源:LockKeyColumnValueStoreTest.java

示例6: Backend

import com.thinkaurelius.titan.diskstorage.locking.consistentkey.ExpectedValueCheckingStoreManager; //导入依赖的package包/类
public Backend(Configuration configuration) {
    this.configuration = configuration;

    KeyColumnValueStoreManager manager = getStorageManager(configuration);
    if (configuration.get(BASIC_METRICS)) {
        storeManager = new MetricInstrumentedStoreManager(manager,METRICS_STOREMANAGER_NAME,configuration.get(METRICS_MERGE_STORES),METRICS_MERGED_STORE);
    } else {
        storeManager = manager;
    }
    indexes = getIndexes(configuration);
    storeFeatures = storeManager.getFeatures();

    mgmtLogManager = getKCVSLogManager(MANAGEMENT_LOG);
    txLogManager = getKCVSLogManager(TRANSACTION_LOG);
    userLogManager = getLogManager(USER_LOG);


    cacheEnabled = !configuration.get(STORAGE_BATCH) && configuration.get(DB_CACHE);

    int bufferSizeTmp = configuration.get(BUFFER_SIZE);
    Preconditions.checkArgument(bufferSizeTmp > 0, "Buffer size must be positive");
    if (!storeFeatures.hasBatchMutation()) {
        bufferSize = Integer.MAX_VALUE;
    } else bufferSize = bufferSizeTmp;

    maxWriteTime = configuration.get(STORAGE_WRITE_WAITTIME);
    maxReadTime = configuration.get(STORAGE_READ_WAITTIME);

    if (!storeFeatures.hasLocking()) {
        Preconditions.checkArgument(storeFeatures.isKeyConsistent(),"Store needs to support some form of locking");
        storeManagerLocking = new ExpectedValueCheckingStoreManager(storeManager,LOCK_STORE_SUFFIX,this,maxReadTime);
    } else {
        storeManagerLocking = storeManager;
    }

    if (configuration.get(PARALLEL_BACKEND_OPS)) {
        int poolsize = Runtime.getRuntime().availableProcessors() * THREAD_POOL_SIZE_SCALE_FACTOR;
        threadPool = Executors.newFixedThreadPool(poolsize);
        log.info("Initiated backend operations thread pool of size {}", poolsize);
    } else {
        threadPool = null;
    }

    final String lockBackendName = configuration.get(LOCK_BACKEND);
    if (REGISTERED_LOCKERS.containsKey(lockBackendName)) {
        lockerCreator = REGISTERED_LOCKERS.get(lockBackendName);
    } else {
        throw new TitanConfigurationException("Unknown lock backend \"" +
                lockBackendName + "\".  Known lock backends: " +
                Joiner.on(", ").join(REGISTERED_LOCKERS.keySet()) + ".");
    }
    // Never used for backends that have innate transaction support, but we
    // want to maintain the non-null invariant regardless; it will default
    // to connsistentkey impl if none is specified
    Preconditions.checkNotNull(lockerCreator);


}
 
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:59,代码来源:Backend.java


注:本文中的com.thinkaurelius.titan.diskstorage.locking.consistentkey.ExpectedValueCheckingStoreManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。