use of com.palantir.lock.v2.LockToken in project atlasdb by palantir.
the class AsyncLockServiceEteTest method canLockAndUnlockMultipleLocks.
@Test
public void canLockAndUnlockMultipleLocks() {
LockToken token = lockSynchronously(REQUEST_1, LOCK_A, LOCK_B, LOCK_C);
assertTrue(service.unlock(token));
assertNotLocked(LOCK_A);
assertNotLocked(LOCK_B);
assertNotLocked(LOCK_C);
}
use of com.palantir.lock.v2.LockToken in project atlasdb by palantir.
the class HeldLocksCollectionTest method unlockReturnsSubsetOfUnlockedLocks.
@Test
public void unlockReturnsSubsetOfUnlockedLocks() {
LockToken refreshableRequest = mockRefreshableRequest();
LockToken nonRefreshableRequest = mockNonRefreshableRequest();
Set<LockToken> expected = ImmutableSet.of(refreshableRequest);
Set<LockToken> actual = heldLocksCollection.unlock(ImmutableSet.of(refreshableRequest, nonRefreshableRequest));
assertThat(actual).isEqualTo(expected);
}
use of com.palantir.lock.v2.LockToken in project atlasdb by palantir.
the class HeldLocksCollectionTest method mockHeldLocksForNewRequest.
private LockToken mockHeldLocksForNewRequest(Consumer<HeldLocks> mockApplier) {
LockToken request = LockToken.of(UUID.randomUUID());
HeldLocks heldLocks = mock(HeldLocks.class);
mockApplier.accept(heldLocks);
AsyncResult<HeldLocks> completedResult = new AsyncResult<>();
completedResult.complete(heldLocks);
heldLocksCollection.getExistingOrAcquire(request.getRequestId(), () -> completedResult);
return request;
}
use of com.palantir.lock.v2.LockToken in project atlasdb by palantir.
the class HeldLocksCollectionTest method mockTimedOutRequest.
private LockToken mockTimedOutRequest() {
LockToken request = LockToken.of(UUID.randomUUID());
AsyncResult timedOutResult = new AsyncResult();
timedOutResult.timeout();
heldLocksCollection.getExistingOrAcquire(request.getRequestId(), () -> timedOutResult);
return request;
}
Aggregations