/** * A version of {@link TimelockService#unlock(Set)} where one does not need to know whether the locks associated * with the provided tokens were successfully unlocked or not. * * In some implementations, this may be more performant than a standard unlock. * * @param tokens Tokens for which associated locks should be unlocked. */ default void tryUnlock(Set<LockToken> tokens) { unlock(tokens); }
static StartIdentifiedAtlasDbTransactionResponse of( LockImmutableTimestampResponse immutableTimestamp, TimestampAndPartition timestampAndPartition) { return ImmutableStartIdentifiedAtlasDbTransactionResponse.of(immutableTimestamp, timestampAndPartition); } }
@Override public TimestampRange getFreshTimestamps(int numTimestampsRequested) { return timelockService.getFreshTimestamps(numTimestampsRequested); } }
@Override public StartIdentifiedAtlasDbTransactionResponse startIdentifiedAtlasDbTransaction( StartIdentifiedAtlasDbTransactionRequest request) { return StartIdentifiedAtlasDbTransactionResponse.of( lockImmutableTimestamp(ImmutableIdentifiedTimeLockRequest.of(request.requestId())), TimestampAndPartition.of(getFreshTimestamp(), 0)); }
@Override public StartIdentifiedAtlasDbTransactionResponse startIdentifiedAtlasDbTransaction( StartIdentifiedAtlasDbTransactionRequest request) { return checkAndUpdateLowerBound(() -> delegate.startIdentifiedAtlasDbTransaction(request), r -> r.startTimestampAndPartition().timestamp(), r -> r.startTimestampAndPartition().timestamp()); }
@Override public StartIdentifiedAtlasDbTransactionResponse startIdentifiedAtlasDbTransaction( StartIdentifiedAtlasDbTransactionRequest request) { StartIdentifiedAtlasDbTransactionResponse response = executeOnTimeLock( () -> delegate.startIdentifiedAtlasDbTransaction(request)); lockRefresher.registerLock(response.immutableTimestamp().getLock()); return response; }
@Override public StartIdentifiedAtlasDbTransactionResponse startIdentifiedAtlasDbTransaction( StartIdentifiedAtlasDbTransactionRequest request) { return StartIdentifiedAtlasDbTransactionResponse.of( lockImmutableTimestamp(ImmutableIdentifiedTimeLockRequest.of(request.requestId())), getFreshTimestampForClient(request.requestorId())); }
@Override public StartAtlasDbTransactionResponse startAtlasDbTransaction(IdentifiedTimeLockRequest request) { StartAtlasDbTransactionResponse response = executeOnTimeLock(() -> delegate.startAtlasDbTransaction(request)); lockRefresher.registerLock(response.immutableTimestamp().getLock()); return response; }
@Override public long getFreshTimestamp() { return timelockService.getFreshTimestamp(); }
@Override public Set<LockToken> refresh(Set<LockToken> lockTokenV2s) throws InterruptedException { return timelockService.refreshLockLeases(lockTokenV2s); } }
@Override public boolean isInitialized() { return timelockService.isInitialized(); }
@Override public WaitForLocksResponse waitForLocks(WaitForLocksRequest request) { com.palantir.lock.LockRequest legacyRequest = toLegacyWaitForLocksRequest(request.getLockDescriptors()); // this blocks indefinitely, and can only fail if the connection fails (and throws an exception) lockAnonymous(legacyRequest); return WaitForLocksResponse.successful(); }
static StartAtlasDbTransactionResponse of(LockImmutableTimestampResponse response, long timestamp) { return ImmutableStartAtlasDbTransactionResponse.of(response, timestamp); } }
static TimestampAndPartition of(long timestamp, int partition) { return ImmutableTimestampAndPartition.of(timestamp, partition); } }
static LockImmutableTimestampResponse of(long timestamp, LockToken lock) { return ImmutableLockImmutableTimestampResponse.of(timestamp, lock); }
static LockToken of(UUID requestId) { return ImmutableLockToken.of(requestId); }
private static void tryGetFreshTimestamp(TimelockService service, int repetition) { for (int i = 0; i < repetition; i++) { try { service.getFreshTimestamp(); } catch (RuntimeException e) { // ignored - TODO(gsheasby): should assert exception message } } }
@Override public Set<LockToken> unlock(Set<LockToken> lockTokenV2s) throws InterruptedException { return timelockService.unlock(lockTokenV2s); }
@Override public TimestampRange getFreshTimestamps(int numTimestampsRequested) { return executeOnTimeLock(() -> delegate.getFreshTimestamps(numTimestampsRequested)); }
@Override public boolean isInitialized() { return timelockService.isInitialized(); }