Search in sources :

Example 41 with LockToken

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);
}
Also used : LockToken(com.palantir.lock.v2.LockToken) Test(org.junit.Test)

Example 42 with LockToken

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);
}
Also used : LockToken(com.palantir.lock.v2.LockToken) Test(org.junit.Test)

Example 43 with LockToken

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;
}
Also used : LockToken(com.palantir.lock.v2.LockToken)

Example 44 with LockToken

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;
}
Also used : LockToken(com.palantir.lock.v2.LockToken)

Aggregations

LockToken (com.palantir.lock.v2.LockToken)42 Test (org.junit.Test)32 LockResponse (com.palantir.lock.v2.LockResponse)5 TimelockService (com.palantir.lock.v2.TimelockService)4 LockRequest (com.palantir.lock.v2.LockRequest)3 WaitForLocksResponse (com.palantir.lock.v2.WaitForLocksResponse)3 Timer (com.codahale.metrics.Timer)1 SafeAndUnsafeTableReferences (com.palantir.atlasdb.logging.LoggingArgs.SafeAndUnsafeTableReferences)1 TransactionLockAcquisitionTimeoutException (com.palantir.atlasdb.transaction.api.TransactionLockAcquisitionTimeoutException)1 TransactionLockTimeoutException (com.palantir.atlasdb.transaction.api.TransactionLockTimeoutException)1 ShouldRetry (com.palantir.flake.ShouldRetry)1 AtlasCellLockDescriptor (com.palantir.lock.AtlasCellLockDescriptor)1 AtlasRowLockDescriptor (com.palantir.lock.AtlasRowLockDescriptor)1 LockDescriptor (com.palantir.lock.LockDescriptor)1 LockRefreshToken (com.palantir.lock.LockRefreshToken)1 LockImmutableTimestampResponse (com.palantir.lock.v2.LockImmutableTimestampResponse)1 WaitForLocksRequest (com.palantir.lock.v2.WaitForLocksRequest)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1