use of com.palantir.lock.v2.LockToken in project atlasdb by palantir.
the class AsyncTimelockServiceIntegrationTest method canLockRefreshAndUnlock.
@Test
public void canLockRefreshAndUnlock() {
LockToken token = cluster.lock(requestFor(LOCK_A)).getToken();
boolean wasRefreshed = cluster.refreshLockLease(token);
boolean wasUnlocked = cluster.unlock(token);
assertTrue(wasRefreshed);
assertTrue(wasUnlocked);
}
use of com.palantir.lock.v2.LockToken in project atlasdb by palantir.
the class AsyncTimelockServiceIntegrationTest method locksAreExclusive.
@Test
public void locksAreExclusive() {
LockToken token = cluster.lock(requestFor(LOCK_A)).getToken();
Future<LockToken> futureToken = cluster.lockAsync(requestFor(LOCK_A)).thenApply(LockResponse::getToken);
assertNotYetLocked(futureToken);
cluster.unlock(token);
assertLockedAndUnlock(futureToken);
}
use of com.palantir.lock.v2.LockToken in project atlasdb by palantir.
the class AsyncTimelockServiceIntegrationTest method canWaitForLocks.
@Test
public void canWaitForLocks() {
LockToken token = cluster.lock(requestFor(LOCK_A, LOCK_B)).getToken();
CompletableFuture<WaitForLocksResponse> future = cluster.waitForLocksAsync(waitRequestFor(LOCK_A, LOCK_B));
assertNotDone(future);
cluster.unlock(token);
assertDone(future);
assertThat(future.join().wasSuccessful()).isTrue();
}
use of com.palantir.lock.v2.LockToken in project atlasdb by palantir.
the class AsyncTimelockServiceIntegrationTest method waitForLockRequestsAreIdempotent.
@Test
public void waitForLockRequestsAreIdempotent() {
if (isUsingSyncAdapter(cluster)) {
// legacy API does not support idempotence
return;
}
LockToken token = cluster.lock(requestFor(LOCK_A)).getToken();
WaitForLocksRequest request = waitRequestFor(LOCK_A);
CompletableFuture<WaitForLocksResponse> response = cluster.waitForLocksAsync(request);
CompletableFuture<WaitForLocksResponse> duplicateResponse = cluster.waitForLocksAsync(request);
cluster.unlock(token);
assertThat(response.join()).isEqualTo(duplicateResponse.join());
}
use of com.palantir.lock.v2.LockToken in project atlasdb by palantir.
the class MultiNodePaxosTimeLockServerIntegrationTest method locksAreInvalidatedAcrossFailures.
@Test
public void locksAreInvalidatedAcrossFailures() throws InterruptedException {
LockToken token = CLUSTER.lock(LockRequest.of(LOCKS, DEFAULT_LOCK_TIMEOUT_MS)).getToken();
for (int i = 0; i < 3; i++) {
CLUSTER.failoverToNewLeader();
assertThat(CLUSTER.unlock(token)).isFalse();
token = CLUSTER.lock(LockRequest.of(LOCKS, DEFAULT_LOCK_TIMEOUT_MS)).getToken();
}
}
Aggregations