use of com.palantir.lock.v2.LockToken in project atlasdb by palantir.
the class AsyncLockServiceEteTest method canLockAndUnlock.
@Test
public void canLockAndUnlock() {
LockToken token = lockSynchronously(REQUEST_1, LOCK_A);
assertLocked(LOCK_A);
assertTrue(service.unlock(token));
assertNotLocked(LOCK_A);
}
use of com.palantir.lock.v2.LockToken in project atlasdb by palantir.
the class AsyncLockServiceEteTest method waitForLocksRequestsAreIdempotent.
@Test
public void waitForLocksRequestsAreIdempotent() {
LockToken token = lockSynchronously(REQUEST_1, LOCK_A);
AsyncResult<Void> request = service.waitForLocks(REQUEST_2, descriptors(LOCK_A), SHORT_TIMEOUT);
AsyncResult<Void> duplicate = service.waitForLocks(REQUEST_2, descriptors(LOCK_A), SHORT_TIMEOUT);
assertThat(request).isEqualTo(duplicate);
service.unlock(token);
assertThat(request.isCompletedSuccessfully()).isTrue();
assertThat(duplicate.isCompletedSuccessfully()).isTrue();
}
use of com.palantir.lock.v2.LockToken in project atlasdb by palantir.
the class AsyncLockServiceEteTest method waitingRequestGetsTheLockAfterItIsUnlocked.
@Test
public void waitingRequestGetsTheLockAfterItIsUnlocked() {
LockToken request1 = lockSynchronously(REQUEST_1, LOCK_A);
AsyncResult<LockToken> request2 = lock(REQUEST_2, LOCK_A);
assertThat(request2.isComplete()).isFalse();
service.unlock(request1);
assertThat(request2.isCompletedSuccessfully()).isTrue();
}
use of com.palantir.lock.v2.LockToken in project atlasdb by palantir.
the class AsyncLockServiceEteTest method canWaitForLock.
@Test
public void canWaitForLock() {
LockToken lockAHolder = lockSynchronously(REQUEST_1, LOCK_A);
AsyncResult<Void> waitResult = waitForLocks(REQUEST_2, LOCK_A);
assertThat(waitResult.isComplete()).isFalse();
service.unlock(lockAHolder);
assertThat(waitResult.isCompletedSuccessfully()).isTrue();
assertNotLocked(LOCK_A);
}
use of com.palantir.lock.v2.LockToken in project atlasdb by palantir.
the class AsyncLockServiceEteTest method waitingRequestGetsTheLockAfterItIsUnlockedWithMultipleLocks.
@Test
public void waitingRequestGetsTheLockAfterItIsUnlockedWithMultipleLocks() {
LockToken request1 = lockSynchronously(REQUEST_1, LOCK_A, LOCK_C);
AsyncResult<LockToken> request2 = lock(REQUEST_2, LOCK_A, LOCK_B, LOCK_C, LOCK_D);
assertThat(request2.isComplete()).isFalse();
service.unlock(request1);
assertThat(request2.isCompletedSuccessfully()).isTrue();
}
Aggregations