Search in sources :

Example 21 with LockRefreshToken

use of com.palantir.lock.LockRefreshToken in project atlasdb by palantir.

the class PaxosTimeLockServerIntegrationTest method lockServiceShouldAllowUsToTakeOutSameLockInDifferentNamespaces.

@Test
public void lockServiceShouldAllowUsToTakeOutSameLockInDifferentNamespaces() throws InterruptedException {
    LockService lockService1 = getLockService(CLIENT_1);
    LockService lockService2 = getLockService(CLIENT_2);
    LockRefreshToken token1 = lockService1.lock(LOCK_CLIENT_NAME, com.palantir.lock.LockRequest.builder(LOCK_MAP).doNotBlock().build());
    LockRefreshToken token2 = lockService2.lock(LOCK_CLIENT_NAME, com.palantir.lock.LockRequest.builder(LOCK_MAP).doNotBlock().build());
    assertThat(token1).isNotNull();
    assertThat(token2).isNotNull();
    lockService1.unlock(token1);
    lockService2.unlock(token2);
}
Also used : LockService(com.palantir.lock.LockService) LockRefreshToken(com.palantir.lock.LockRefreshToken) Test(org.junit.Test)

Example 22 with LockRefreshToken

use of com.palantir.lock.LockRefreshToken in project atlasdb by palantir.

the class AsyncTimelockServiceTransactionIntegrationTest method advisoryLocksCanFail.

@Test
public void advisoryLocksCanFail() throws ExecutionException, InterruptedException {
    ThrowableAssert.ThrowingCallable failingTxn = () -> txnManager.runTaskWithLocksWithRetry(() -> EXCLUSIVE_ADVISORY_LOCK_REQUEST, (txn, locks) -> {
        LockRefreshToken token = locks.iterator().next().getLockRefreshToken();
        txnManager.getLockService().unlock(token);
        txn.put(TABLE, ImmutableMap.of(CELL, DATA));
        return null;
    });
    assertThatThrownBy(failingTxn).isInstanceOf(TransactionLockTimeoutException.class);
}
Also used : ThrowableAssert(org.assertj.core.api.ThrowableAssert) LockRefreshToken(com.palantir.lock.LockRefreshToken) Test(org.junit.Test)

Aggregations

LockRefreshToken (com.palantir.lock.LockRefreshToken)22 Test (org.junit.Test)12 LockService (com.palantir.lock.LockService)6 LockDescriptor (com.palantir.lock.LockDescriptor)5 HeldLocksToken (com.palantir.lock.HeldLocksToken)4 LockRequest (com.palantir.lock.LockRequest)4 SimpleHeldLocksToken (com.palantir.lock.SimpleHeldLocksToken)3 StringLockDescriptor (com.palantir.lock.StringLockDescriptor)3 BigInteger (java.math.BigInteger)3 AtlasTimestampLockDescriptor (com.palantir.lock.AtlasTimestampLockDescriptor)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 GlobalClock (com.palantir.atlasdb.cleaner.GlobalClock)1 SingleBackendCliTestRunner (com.palantir.atlasdb.cli.runner.SingleBackendCliTestRunner)1 Cell (com.palantir.atlasdb.keyvalue.api.Cell)1 DaggerTestAtlasDbServices (com.palantir.atlasdb.services.test.DaggerTestAtlasDbServices)1 TestAtlasDbServices (com.palantir.atlasdb.services.test.TestAtlasDbServices)1 ExceptionMatchers (com.palantir.atlasdb.timelock.util.ExceptionMatchers)1 Clock (com.palantir.common.time.Clock)1 AtlasRowLockDescriptor (com.palantir.lock.AtlasRowLockDescriptor)1 LockClient (com.palantir.lock.LockClient)1