use of com.palantir.lock.v2.LockToken in project atlasdb by palantir.
the class AsyncLockServiceEteTest method requestsAreIdempotentAfterBeingAcquired.
@Test
public void requestsAreIdempotentAfterBeingAcquired() {
LockToken token = lockSynchronously(REQUEST_1, LOCK_A);
LockToken duplicate = lockSynchronously(REQUEST_1, LOCK_A);
assertThat(token).isEqualTo(duplicate);
}
use of com.palantir.lock.v2.LockToken in project atlasdb by palantir.
the class AsyncLockServiceEteTest method canUnlockAfterRefreshing.
@Test
public void canUnlockAfterRefreshing() {
LockToken token = lockSynchronously(REQUEST_1, LOCK_A);
service.refresh(token);
assertTrue(service.unlock(token));
}
use of com.palantir.lock.v2.LockToken in project atlasdb by palantir.
the class HeldLocksCollectionTest method mockFailedRequest.
private LockToken mockFailedRequest() {
LockToken request = LockToken.of(UUID.randomUUID());
AsyncResult failedLocks = new AsyncResult();
failedLocks.fail(new RuntimeException());
heldLocksCollection.getExistingOrAcquire(request.getRequestId(), () -> failedLocks);
return request;
}
use of com.palantir.lock.v2.LockToken in project atlasdb by palantir.
the class HeldLocksCollectionTest method refreshReturnsSubsetOfUnlockedLocks.
@Test
public void refreshReturnsSubsetOfUnlockedLocks() {
LockToken unlockableRequest = mockRefreshableRequest();
LockToken nonUnlockableRequest = mockNonRefreshableRequest();
Set<LockToken> expected = ImmutableSet.of(unlockableRequest);
Set<LockToken> actual = heldLocksCollection.refresh(ImmutableSet.of(unlockableRequest, nonUnlockableRequest));
assertThat(actual).isEqualTo(expected);
}
use of com.palantir.lock.v2.LockToken in project atlasdb by palantir.
the class HeldLocksCollectionTest method successfulUnlockRemovesHeldLocks.
@Test
public void successfulUnlockRemovesHeldLocks() {
LockToken token = mockRefreshableRequest();
heldLocksCollection.unlock(ImmutableSet.of(token));
assertThat(heldLocksCollection.heldLocksById.isEmpty()).isTrue();
}
Aggregations