Search in sources :

Example 31 with LockToken

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

the class AsyncTimelockServiceIntegrationTest method lockRequestCanTimeOut.

@Test
public void lockRequestCanTimeOut() {
    LockToken token = cluster.lock(requestFor(LOCK_A)).getToken();
    LockResponse token2 = cluster.lock(requestFor(SHORT_TIMEOUT, LOCK_A));
    assertThat(token2.wasSuccessful()).isFalse();
    cluster.unlock(token);
}
Also used : LockResponse(com.palantir.lock.v2.LockResponse) LockToken(com.palantir.lock.v2.LockToken) Test(org.junit.Test)

Example 32 with LockToken

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

the class MultiNodePaxosTimeLockServerIntegrationTest method leaderRespondsToRequests.

@Test
public void leaderRespondsToRequests() throws InterruptedException {
    CLUSTER.currentLeader().getFreshTimestamp();
    LockToken token = CLUSTER.currentLeader().lock(LockRequest.of(LOCKS, DEFAULT_LOCK_TIMEOUT_MS)).getToken();
    CLUSTER.unlock(token);
}
Also used : LockToken(com.palantir.lock.v2.LockToken) Test(org.junit.Test)

Example 33 with LockToken

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

the class PaxosTimeLockServerIntegrationTest method asyncLockServiceShouldAllowUsToTakeOutLocks.

@Test
public void asyncLockServiceShouldAllowUsToTakeOutLocks() throws InterruptedException {
    TimelockService timelockService = getTimelockService(CLIENT_1);
    LockToken token = timelockService.lock(newLockV2Request(LOCK_1)).getToken();
    assertThat(timelockService.unlock(ImmutableSet.of(token))).contains(token);
}
Also used : TimelockService(com.palantir.lock.v2.TimelockService) LockToken(com.palantir.lock.v2.LockToken) Test(org.junit.Test)

Example 34 with LockToken

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

the class LockAndUnlockContendedBenchmark method performOneCall.

@Override
protected void performOneCall() {
    LockToken token = timelock.lock(nextRequest()).getToken();
    boolean wasUnlocked = timelock.unlock(ImmutableSet.of(token)).contains(token);
    Preconditions.checkState(wasUnlocked, "unlock returned false");
}
Also used : LockToken(com.palantir.lock.v2.LockToken)

Example 35 with LockToken

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

the class AsyncLockServiceEteTest method canLockAndUnlockImmutableTimestamp.

@Test
public void canLockAndUnlockImmutableTimestamp() {
    long timestamp = 123L;
    LockToken token = service.lockImmutableTimestamp(REQUEST_1, timestamp).get();
    assertThat(service.getImmutableTimestamp().get()).isEqualTo(123L);
    service.unlock(token);
    assertThat(service.getImmutableTimestamp()).isEqualTo(Optional.empty());
}
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