Search in sources :

Example 1 with ConsistentKeyLocker

use of com.thinkaurelius.titan.diskstorage.locking.consistentkey.ConsistentKeyLocker in project titan by thinkaurelius.

the class LockKeyColumnValueStoreTest method open.

public void open() throws BackendException {
    manager = new KeyColumnValueStoreManager[CONCURRENCY];
    tx = new StoreTransaction[CONCURRENCY][NUM_TX];
    store = new KeyColumnValueStore[CONCURRENCY];
    for (int i = 0; i < CONCURRENCY; i++) {
        manager[i] = openStorageManager(i);
        StoreFeatures storeFeatures = manager[i].getFeatures();
        store[i] = manager[i].openDatabase(DB_NAME);
        for (int j = 0; j < NUM_TX; j++) {
            tx[i][j] = manager[i].beginTransaction(getTxConfig());
            log.debug("Began transaction of class {}", tx[i][j].getClass().getCanonicalName());
        }
        ModifiableConfiguration sc = GraphDatabaseConfiguration.buildGraphConfiguration();
        sc.set(GraphDatabaseConfiguration.LOCK_LOCAL_MEDIATOR_GROUP, concreteClassName + i);
        sc.set(GraphDatabaseConfiguration.UNIQUE_INSTANCE_ID, "inst" + i);
        sc.set(GraphDatabaseConfiguration.LOCK_RETRY, 10);
        sc.set(GraphDatabaseConfiguration.LOCK_EXPIRE, Duration.ofMillis(EXPIRE_MS));
        if (!storeFeatures.hasLocking()) {
            Preconditions.checkArgument(storeFeatures.isKeyConsistent(), "Store needs to support some form of locking");
            KeyColumnValueStore lockerStore = manager[i].openDatabase(DB_NAME + "_lock_");
            ConsistentKeyLocker c = new ConsistentKeyLocker.Builder(lockerStore, manager[i]).fromConfig(sc).mediatorName(concreteClassName + i).build();
            store[i] = new ExpectedValueCheckingStore(store[i], c);
            for (int j = 0; j < NUM_TX; j++) tx[i][j] = new ExpectedValueCheckingTransaction(tx[i][j], manager[i].beginTransaction(getConsistentTxConfig(manager[i])), GraphDatabaseConfiguration.STORAGE_READ_WAITTIME.getDefaultValue());
        }
    }
}
Also used : ExpectedValueCheckingStore(com.thinkaurelius.titan.diskstorage.locking.consistentkey.ExpectedValueCheckingStore) ModifiableConfiguration(com.thinkaurelius.titan.diskstorage.configuration.ModifiableConfiguration) ConsistentKeyLocker(com.thinkaurelius.titan.diskstorage.locking.consistentkey.ConsistentKeyLocker) ExpectedValueCheckingTransaction(com.thinkaurelius.titan.diskstorage.locking.consistentkey.ExpectedValueCheckingTransaction)

Aggregations

ModifiableConfiguration (com.thinkaurelius.titan.diskstorage.configuration.ModifiableConfiguration)1 ConsistentKeyLocker (com.thinkaurelius.titan.diskstorage.locking.consistentkey.ConsistentKeyLocker)1 ExpectedValueCheckingStore (com.thinkaurelius.titan.diskstorage.locking.consistentkey.ExpectedValueCheckingStore)1 ExpectedValueCheckingTransaction (com.thinkaurelius.titan.diskstorage.locking.consistentkey.ExpectedValueCheckingTransaction)1