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);
}
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);
}
Aggregations