Search in sources :

Example 1 with NoOpPersistentLockService

use of com.palantir.atlasdb.persistentlock.NoOpPersistentLockService in project atlasdb by palantir.

the class PersistentLockManagerTest method noOpPersistentLockCanLockTwice.

@Test
public void noOpPersistentLockCanLockTwice() {
    PersistentLockManager noOpManager = new PersistentLockManager(new NoOpPersistentLockService(), 0L);
    assertTrue("NoOpPersistentLockService should return true when acquiring lock", noOpManager.tryAcquirePersistentLock());
    assertTrue("NoOpPersistentLockService should return true when acquiring lock for the second time", noOpManager.tryAcquirePersistentLock());
}
Also used : NoOpPersistentLockService(com.palantir.atlasdb.persistentlock.NoOpPersistentLockService) Test(org.junit.Test)

Example 2 with NoOpPersistentLockService

use of com.palantir.atlasdb.persistentlock.NoOpPersistentLockService in project atlasdb by palantir.

the class TransactionManagers method createAndRegisterPersistentLockService.

private static PersistentLockService createAndRegisterPersistentLockService(KeyValueService kvs, Consumer<Object> env, boolean initializeAsync) {
    if (!kvs.supportsCheckAndSet()) {
        return new NoOpPersistentLockService();
    }
    PersistentLockService pls = KvsBackedPersistentLockService.create(kvs, initializeAsync);
    env.accept(pls);
    env.accept(new CheckAndSetExceptionMapper());
    return pls;
}
Also used : CheckAndSetExceptionMapper(com.palantir.atlasdb.persistentlock.CheckAndSetExceptionMapper) NoOpPersistentLockService(com.palantir.atlasdb.persistentlock.NoOpPersistentLockService) KvsBackedPersistentLockService(com.palantir.atlasdb.persistentlock.KvsBackedPersistentLockService) PersistentLockService(com.palantir.atlasdb.persistentlock.PersistentLockService) NoOpPersistentLockService(com.palantir.atlasdb.persistentlock.NoOpPersistentLockService)

Example 3 with NoOpPersistentLockService

use of com.palantir.atlasdb.persistentlock.NoOpPersistentLockService in project atlasdb by palantir.

the class PersistentLockManagerTest method noOpPersistentLockDoesNotThrow.

@Test
public void noOpPersistentLockDoesNotThrow() {
    PersistentLockManager noOpManager = new PersistentLockManager(new NoOpPersistentLockService(), 0L);
    assertTrue("NoOpPersistentLockService should return true when acquiring lock", noOpManager.tryAcquirePersistentLock());
    noOpManager.releasePersistentLock();
}
Also used : NoOpPersistentLockService(com.palantir.atlasdb.persistentlock.NoOpPersistentLockService) Test(org.junit.Test)

Aggregations

NoOpPersistentLockService (com.palantir.atlasdb.persistentlock.NoOpPersistentLockService)3 Test (org.junit.Test)2 CheckAndSetExceptionMapper (com.palantir.atlasdb.persistentlock.CheckAndSetExceptionMapper)1 KvsBackedPersistentLockService (com.palantir.atlasdb.persistentlock.KvsBackedPersistentLockService)1 PersistentLockService (com.palantir.atlasdb.persistentlock.PersistentLockService)1