use of com.palantir.lock.v2.LockImmutableTimestampResponse in project atlasdb by palantir.
the class AsyncTimelockServiceIntegrationTest method canLockImmutableTimestamp.
@Test
public void canLockImmutableTimestamp() {
LockImmutableTimestampResponse response1 = cluster.timelockService().lockImmutableTimestamp(LockImmutableTimestampRequest.create());
LockImmutableTimestampResponse response2 = cluster.timelockService().lockImmutableTimestamp(LockImmutableTimestampRequest.create());
long immutableTs = cluster.timelockService().getImmutableTimestamp();
assertThat(immutableTs).isEqualTo(response1.getImmutableTimestamp());
cluster.unlock(response1.getLock());
assertThat(immutableTs).isEqualTo(response2.getImmutableTimestamp());
cluster.unlock(response2.getLock());
}
use of com.palantir.lock.v2.LockImmutableTimestampResponse in project atlasdb by palantir.
the class SnapshotTransactionManager method setupRunTaskWithConditionThrowOnConflict.
public RawTransaction setupRunTaskWithConditionThrowOnConflict(PreCommitCondition condition) {
LockImmutableTimestampResponse immutableTsResponse = timelockService.lockImmutableTimestamp(LockImmutableTimestampRequest.create());
try {
LockToken immutableTsLock = immutableTsResponse.getLock();
long immutableTs = immutableTsResponse.getImmutableTimestamp();
recordImmutableTimestamp(immutableTs);
Supplier<Long> startTimestampSupplier = getStartTimestampSupplier();
SnapshotTransaction transaction = createTransaction(immutableTs, startTimestampSupplier, immutableTsLock, condition);
return new RawTransaction(transaction, immutableTsLock);
} catch (Throwable e) {
timelockService.unlock(ImmutableSet.of(immutableTsResponse.getLock()));
throw Throwables.rewrapAndThrowUncheckedException(e);
}
}
use of com.palantir.lock.v2.LockImmutableTimestampResponse in project atlasdb by palantir.
the class LegacyTimelockServiceTest method lockImmutableTimestampLocksFreshTimestamp.
@Test
public void lockImmutableTimestampLocksFreshTimestamp() throws InterruptedException {
long immutableTs = 3L;
LockRefreshToken expectedToken = mockImmutableTsLockResponse();
mockMinLockedInVersionIdResponse(immutableTs);
LockImmutableTimestampResponse expectedResponse = LockImmutableTimestampResponse.of(immutableTs, toTokenV2(expectedToken));
assertEquals(expectedResponse, timelock.lockImmutableTimestamp(LockImmutableTimestampRequest.create()));
}
use of com.palantir.lock.v2.LockImmutableTimestampResponse in project atlasdb by palantir.
the class TimeLockClient method lockImmutableTimestamp.
@Override
public LockImmutableTimestampResponse lockImmutableTimestamp(LockImmutableTimestampRequest request) {
LockImmutableTimestampResponse response = executeOnTimeLock(() -> delegate.lockImmutableTimestamp(request));
lockRefresher.registerLock(response.getLock());
return response;
}
use of com.palantir.lock.v2.LockImmutableTimestampResponse in project atlasdb by palantir.
the class AsyncTimelockServiceImpl method lockImmutableTimestamp.
@Override
public LockImmutableTimestampResponse lockImmutableTimestamp(LockImmutableTimestampRequest request) {
long timestamp = timestampService.getFreshTimestamp();
// this will always return synchronously
LockToken token = lockService.lockImmutableTimestamp(request.getRequestId(), timestamp).get();
long immutableTs = lockService.getImmutableTimestamp().orElse(timestamp);
return LockImmutableTimestampResponse.of(immutableTs, token);
}
Aggregations