Search in sources :

Example 36 with LockToken

use of com.palantir.lock.v2.LockToken in project atlasdb by palantir.

the class AsyncLockServiceEteTest method timedOutRequestDoesNotHoldLocks.

@Test
@ShouldRetry
public void timedOutRequestDoesNotHoldLocks() {
    LockToken lockBToken = lockSynchronously(REQUEST_1, LOCK_B);
    service.lock(REQUEST_2, descriptors(LOCK_A, LOCK_B), SHORT_TIMEOUT);
    waitForTimeout(SHORT_TIMEOUT);
    assertNotLocked(LOCK_A);
    service.unlock(lockBToken);
    assertNotLocked(LOCK_B);
}
Also used : LockToken(com.palantir.lock.v2.LockToken) Test(org.junit.Test) ShouldRetry(com.palantir.flake.ShouldRetry)

Example 37 with LockToken

use of com.palantir.lock.v2.LockToken in project atlasdb by palantir.

the class AsyncLockServiceEteTest method cannotUnlockAfterUnlocking.

@Test
public void cannotUnlockAfterUnlocking() {
    LockToken token = lockSynchronously(REQUEST_1, LOCK_A);
    service.unlock(token);
    assertFalse(service.unlock(token));
}
Also used : LockToken(com.palantir.lock.v2.LockToken) Test(org.junit.Test)

Example 38 with LockToken

use of com.palantir.lock.v2.LockToken in project atlasdb by palantir.

the class AsyncLockServiceEteTest method locksCanBeRefreshed.

@Test
public void locksCanBeRefreshed() {
    LockToken token = lockSynchronously(REQUEST_1, LOCK_A);
    assertTrue(service.refresh(token));
}
Also used : LockToken(com.palantir.lock.v2.LockToken) Test(org.junit.Test)

Example 39 with LockToken

use of com.palantir.lock.v2.LockToken in project atlasdb by palantir.

the class AsyncLockServiceEteTest method canWaitForMultipleLocks.

@Test
public void canWaitForMultipleLocks() {
    LockToken lockAHolder = lockSynchronously(REQUEST_1, LOCK_B, LOCK_C);
    AsyncResult<Void> waitResult = waitForLocks(REQUEST_2, LOCK_A, LOCK_B, LOCK_C);
    assertThat(waitResult.isComplete()).isFalse();
    assertNotLocked(LOCK_A);
    service.unlock(lockAHolder);
    assertThat(waitResult.isCompletedSuccessfully()).isTrue();
    assertNotLocked(LOCK_A);
    assertNotLocked(LOCK_C);
}
Also used : LockToken(com.palantir.lock.v2.LockToken) Test(org.junit.Test)

Example 40 with LockToken

use of com.palantir.lock.v2.LockToken in project atlasdb by palantir.

the class AsyncLockServiceEteTest method cannotRefreshAfterUnlocking.

@Test
public void cannotRefreshAfterUnlocking() {
    LockToken token = lockSynchronously(REQUEST_1, LOCK_A);
    service.unlock(token);
    assertFalse(service.refresh(token));
}
Also used : LockToken(com.palantir.lock.v2.LockToken) Test(org.junit.Test)

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