Search in sources :

Example 26 with HeldLocksToken

use of com.palantir.lock.HeldLocksToken in project atlasdb by palantir.

the class AsyncTimelockServiceIntegrationTest method getMinLockedInVersionIdReturnsValidValuesForAnonymousClient.

@Test
public void getMinLockedInVersionIdReturnsValidValuesForAnonymousClient() throws InterruptedException {
    HeldLocksToken token1 = lockWithFullResponse(requestForReadLock(LOCK_A, 10L), LockClient.ANONYMOUS);
    HeldLocksToken token2 = lockWithFullResponse(requestForReadLock(LOCK_B, 12L), LockClient.ANONYMOUS);
    assertThat(cluster.lockService().getMinLockedInVersionId()).isEqualTo(10L);
    unlock(token1, token2);
}
Also used : HeldLocksToken(com.palantir.lock.HeldLocksToken) SimpleHeldLocksToken(com.palantir.lock.SimpleHeldLocksToken) Test(org.junit.Test)

Example 27 with HeldLocksToken

use of com.palantir.lock.HeldLocksToken in project atlasdb by palantir.

the class AsyncTimelockServiceIntegrationTest method getMinLockedInVersionIdReturnsNullIfNoVersionIdsAreSpecified.

@Test
public void getMinLockedInVersionIdReturnsNullIfNoVersionIdsAreSpecified() throws InterruptedException {
    HeldLocksToken token = lockWithFullResponse(requestForReadLock(LOCK_A), TEST_CLIENT);
    assertThat(cluster.lockService().getMinLockedInVersionId(TEST_CLIENT)).isNull();
    unlock(token);
}
Also used : HeldLocksToken(com.palantir.lock.HeldLocksToken) SimpleHeldLocksToken(com.palantir.lock.SimpleHeldLocksToken) Test(org.junit.Test)

Example 28 with HeldLocksToken

use of com.palantir.lock.HeldLocksToken in project atlasdb by palantir.

the class AsyncTimelockServiceIntegrationTest method canPerformLockAndUnlock.

@Test
public void canPerformLockAndUnlock() throws InterruptedException {
    HeldLocksToken token1 = lockWithFullResponse(requestForWriteLock(LOCK_A), TEST_CLIENT);
    cluster.lockService().unlock(token1);
    HeldLocksToken token2 = lockWithFullResponse(requestForWriteLock(LOCK_A), TEST_CLIENT);
    cluster.lockService().unlockSimple(SimpleHeldLocksToken.fromHeldLocksToken(token2));
}
Also used : HeldLocksToken(com.palantir.lock.HeldLocksToken) SimpleHeldLocksToken(com.palantir.lock.SimpleHeldLocksToken) Test(org.junit.Test)

Example 29 with HeldLocksToken

use of com.palantir.lock.HeldLocksToken in project atlasdb by palantir.

the class AsyncTimelockServiceIntegrationTest method getMinLockedInVersionIdReturnsValidValues.

@Test
public void getMinLockedInVersionIdReturnsValidValues() throws InterruptedException {
    HeldLocksToken token1 = lockWithFullResponse(requestForReadLock(LOCK_A, 10L), TEST_CLIENT);
    HeldLocksToken token2 = lockWithFullResponse(requestForReadLock(LOCK_B, 12L), TEST_CLIENT);
    assertThat(cluster.lockService().getMinLockedInVersionId(TEST_CLIENT)).isEqualTo(10L);
    unlock(token1, token2);
}
Also used : HeldLocksToken(com.palantir.lock.HeldLocksToken) SimpleHeldLocksToken(com.palantir.lock.SimpleHeldLocksToken) Test(org.junit.Test)

Aggregations

HeldLocksToken (com.palantir.lock.HeldLocksToken)29 SimpleHeldLocksToken (com.palantir.lock.SimpleHeldLocksToken)19 Test (org.junit.Test)13 LockDescriptor (com.palantir.lock.LockDescriptor)8 Nullable (javax.annotation.Nullable)8 StringLockDescriptor (com.palantir.lock.StringLockDescriptor)7 HeldLocksGrant (com.palantir.lock.HeldLocksGrant)5 LockClient (com.palantir.lock.LockClient)5 LockRefreshToken (com.palantir.lock.LockRefreshToken)5 ImmutableSet (com.google.common.collect.ImmutableSet)4 LockResponse (com.palantir.lock.LockResponse)4 BigInteger (java.math.BigInteger)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 LockMode (com.palantir.lock.LockMode)3 SimpleTimeDuration (com.palantir.lock.SimpleTimeDuration)3 ImmutableSortedMap (com.google.common.collect.ImmutableSortedMap)2 LockRequest (com.palantir.lock.LockRequest)2 TimeDuration (com.palantir.lock.TimeDuration)2 Set (java.util.Set)2 ImmutableList (com.google.common.collect.ImmutableList)1