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