use of com.palantir.lock.LockRefreshToken in project atlasdb by palantir.
the class LockTokenConverterTest method throwsIfBigIntegerHasMoreThan127Bits.
@Test
public void throwsIfBigIntegerHasMoreThan127Bits() {
BigInteger bigInt = BigInteger.valueOf(2).pow(127);
LockRefreshToken token = new LockRefreshToken(bigInt, 0L);
assertThatThrownBy(() -> LockTokenConverter.toTokenV2(token)).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("too many bits");
}
use of com.palantir.lock.LockRefreshToken in project atlasdb by palantir.
the class AsyncTimelockServiceIntegrationTest method unlockAndFreezeDoesNotAllowRefreshes.
@Test
public void unlockAndFreezeDoesNotAllowRefreshes() throws InterruptedException {
HeldLocksToken token = lockWithFullResponse(requestForWriteLock(LOCK_A), TEST_CLIENT);
cluster.lockService().unlockAndFreeze(token);
Set<LockRefreshToken> lockRefreshTokens = cluster.lockService().refreshLockRefreshTokens(ImmutableList.of(token.getLockRefreshToken()));
assertThat(lockRefreshTokens).isEmpty();
}
use of com.palantir.lock.LockRefreshToken in project atlasdb by palantir.
the class AsyncTimelockServiceIntegrationTest method canPerformLockAndRefreshLock.
@Test
public void canPerformLockAndRefreshLock() throws InterruptedException {
HeldLocksToken token1 = lockWithFullResponse(requestForWriteLock(LOCK_A), TEST_CLIENT);
LockRefreshToken token = token1.getLockRefreshToken();
Set<LockRefreshToken> lockRefreshTokens = cluster.lockService().refreshLockRefreshTokens(ImmutableList.of(token));
assertThat(lockRefreshTokens).contains(token);
unlock(token1);
}
use of com.palantir.lock.LockRefreshToken in project atlasdb by palantir.
the class MultiNodePaxosTimeLockServerIntegrationTest method blockedLockRequestThrows503OnLeaderElectionForRemoteLock.
@Test
public void blockedLockRequestThrows503OnLeaderElectionForRemoteLock() throws InterruptedException {
LockRefreshToken lock = CLUSTER.remoteLock(CLIENT_1, BLOCKING_LOCK_REQUEST);
assertThat(lock).isNotNull();
TestableTimelockServer leader = CLUSTER.currentLeader();
CompletableFuture<LockRefreshToken> lockRefreshTokenCompletableFuture = CompletableFuture.supplyAsync(() -> {
try {
return leader.remoteLock(CLIENT_2, BLOCKING_LOCK_REQUEST);
} catch (InterruptedException e) {
return null;
}
});
Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS);
CLUSTER.nonLeaders().forEach(TestableTimelockServer::kill);
// Lock on leader so that AwaitingLeadershipProxy notices leadership loss.
assertThatThrownBy(() -> leader.remoteLock(CLIENT_3, BLOCKING_LOCK_REQUEST)).satisfies(ExceptionMatchers::isRetryableExceptionWhereLeaderCannotBeFound);
assertThat(catchThrowable(lockRefreshTokenCompletableFuture::get).getCause()).satisfies(ExceptionMatchers::isRetryableExceptionWhereLeaderCannotBeFound);
}
use of com.palantir.lock.LockRefreshToken in project atlasdb by palantir.
the class PaxosTimeLockServerIntegrationTest method lockServiceShouldNotAllowUsToRefreshLocksFromDifferentNamespaces.
@Test
public void lockServiceShouldNotAllowUsToRefreshLocksFromDifferentNamespaces() throws InterruptedException {
LockService lockService1 = getLockService(CLIENT_1);
LockService lockService2 = getLockService(CLIENT_2);
LockRefreshToken token = lockService1.lock(LOCK_CLIENT_NAME, com.palantir.lock.LockRequest.builder(LOCK_MAP).doNotBlock().build());
assertThat(token).isNotNull();
assertThat(lockService1.refreshLockRefreshTokens(ImmutableList.of(token))).isNotEmpty();
assertThat(lockService2.refreshLockRefreshTokens(ImmutableList.of(token))).isEmpty();
lockService1.unlock(token);
}
Aggregations