Search in sources :

Example 6 with LockToken

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

the class MultiNodePaxosTimeLockServerIntegrationTest method canCreateNewClientsDynamically.

@Test
public void canCreateNewClientsDynamically() {
    for (int i = 0; i < 5; i++) {
        String client = UUID.randomUUID().toString();
        TimelockService timelock = CLUSTER.timelockServiceForClient(client);
        timelock.getFreshTimestamp();
        LockToken token = timelock.lock(LockRequest.of(LOCKS, DEFAULT_LOCK_TIMEOUT_MS)).getToken();
        CLUSTER.unlock(token);
    }
}
Also used : TimelockService(com.palantir.lock.v2.TimelockService) LockToken(com.palantir.lock.v2.LockToken) Test(org.junit.Test)

Example 7 with LockToken

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

the class PaxosTimeLockServerIntegrationTest method asyncLockServiceShouldNotAllowUsToRefreshLocksFromDifferentNamespaces.

@Test
public void asyncLockServiceShouldNotAllowUsToRefreshLocksFromDifferentNamespaces() throws InterruptedException {
    TimelockService lockService1 = getTimelockService(CLIENT_1);
    TimelockService lockService2 = getTimelockService(CLIENT_2);
    LockToken token = lockService1.lock(newLockV2Request(LOCK_1)).getToken();
    assertThat(lockService1.refreshLockLeases(ImmutableSet.of(token))).isNotEmpty();
    assertThat(lockService2.refreshLockLeases(ImmutableSet.of(token))).isEmpty();
    lockService1.unlock(ImmutableSet.of(token));
}
Also used : TimelockService(com.palantir.lock.v2.TimelockService) LockToken(com.palantir.lock.v2.LockToken) Test(org.junit.Test)

Example 8 with LockToken

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

the class PaxosTimeLockServerIntegrationTest method asyncLockServiceShouldAllowUsToTakeOutSameLockInDifferentNamespaces.

@Test
public void asyncLockServiceShouldAllowUsToTakeOutSameLockInDifferentNamespaces() throws InterruptedException {
    TimelockService lockService1 = getTimelockService(CLIENT_1);
    TimelockService lockService2 = getTimelockService(CLIENT_2);
    LockToken token1 = lockService1.lock(newLockV2Request(LOCK_1)).getToken();
    LockToken token2 = lockService2.lock(newLockV2Request(LOCK_1)).getToken();
    lockService1.unlock(ImmutableSet.of(token1));
    lockService2.unlock(ImmutableSet.of(token2));
}
Also used : TimelockService(com.palantir.lock.v2.TimelockService) LockToken(com.palantir.lock.v2.LockToken) Test(org.junit.Test)

Example 9 with LockToken

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

the class AsyncLockServiceEteTest method requestsAreIdempotentDuringAcquisitionPhase.

@Test
public void requestsAreIdempotentDuringAcquisitionPhase() {
    LockToken currentHolder = lockSynchronously(REQUEST_1, LOCK_A);
    AsyncResult<LockToken> tokenResult = lock(REQUEST_2, LOCK_A);
    AsyncResult<LockToken> duplicateResult = lock(REQUEST_2, LOCK_A);
    service.unlock(currentHolder);
    assertThat(tokenResult.isCompletedSuccessfully()).isTrue();
    assertThat(duplicateResult.isCompletedSuccessfully()).isTrue();
    assertThat(tokenResult.get()).isEqualTo(duplicateResult.get());
}
Also used : LockToken(com.palantir.lock.v2.LockToken) Test(org.junit.Test)

Example 10 with LockToken

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

the class AsyncLockServiceEteTest method assertNotLocked.

private void assertNotLocked(String lock) {
    LockToken token = lockSynchronously(UUID.randomUUID(), lock);
    assertTrue(service.unlock(token));
}
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