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);
}
}
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));
}
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));
}
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());
}
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));
}
Aggregations