Search in sources :

Example 1 with ConsistentKeyLocker

use of org.janusgraph.diskstorage.locking.consistentkey.ConsistentKeyLocker in project janusgraph by JanusGraph.

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++) {
        final 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));
        manager[i] = openStorageManager(i, sc);
        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());
        }
        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(org.janusgraph.diskstorage.locking.consistentkey.ExpectedValueCheckingStore) ModifiableConfiguration(org.janusgraph.diskstorage.configuration.ModifiableConfiguration) ConsistentKeyLocker(org.janusgraph.diskstorage.locking.consistentkey.ConsistentKeyLocker) ExpectedValueCheckingTransaction(org.janusgraph.diskstorage.locking.consistentkey.ExpectedValueCheckingTransaction)

Aggregations

ModifiableConfiguration (org.janusgraph.diskstorage.configuration.ModifiableConfiguration)1 ConsistentKeyLocker (org.janusgraph.diskstorage.locking.consistentkey.ConsistentKeyLocker)1 ExpectedValueCheckingStore (org.janusgraph.diskstorage.locking.consistentkey.ExpectedValueCheckingStore)1 ExpectedValueCheckingTransaction (org.janusgraph.diskstorage.locking.consistentkey.ExpectedValueCheckingTransaction)1