@Test public void registersLocks() { LockRequest request = LockRequest.of(LOCKS, TIMEOUT); when(delegate.lock(request)).thenReturn(LockResponse.successful(TOKEN_1)); timelock.lock(request); verify(refresher).registerLocks(ImmutableSet.of(TOKEN_1)); }
@Override public LockResponse lock(LockRequest request) { LockResponse response = executeOnTimeLock(() -> delegate.lock(request)); if (response.wasSuccessful()) { lockRefresher.registerLocks(ImmutableSet.of(response.getToken())); } return response; }
TimeLockClient implements AutoCloseable, TimelockService { @Override public LockResponse lock(LockRequest request) { LockResponse response = executeOnTimeLock(() -> delegate.lock(request)); if (response.wasSuccessful()) { lockRefresher.registerLocks(ImmutableSet.of(response.getToken())); } return response; } }
TimeLockClient implements AutoCloseable, TimelockService { @Override public LockResponse lock(LockRequest request) { LockResponse response = executeOnTimeLock(() -> delegate.lock(request)); if (response.wasSuccessful()) { lockRefresher.registerLocks(ImmutableSet.of(response.getToken())); } return response; } @VisibleForTesting  TimeLockClient(TimelockService delegate, CloseableTimestampService timestampService,
            LockRefresher lockRefresher, TimeLockUnlocker unlocker); }
TimeLockClient implements AutoCloseable, TimelockService { @Override public LockResponse lock(LockRequest request) { LockResponse response = executeOnTimeLock(() -> delegate.lock(request)); if (response.wasSuccessful()) { lockRefresher.registerLocks(ImmutableSet.of(response.getToken())); } return response; } @VisibleForTesting  TimeLockClient(TimelockService delegate, CloseableTimestampService timestampService,
            LockRefresher lockRefresher, TimeLockUnlocker unlocker); static TimeLockClient createDefault(TimelockService timelockService); static TimeLockClient withSynchronousUnlocker(TimelockService timelockService); @Override boolean isInitialized(); @Override long getFreshTimestamp(); @Override long getCommitTimestamp(long startTs, LockToken commitLocksToken); @Override TimestampRange getFreshTimestamps(int numTimestampsRequested); @Override LockImmutableTimestampResponse lockImmutableTimestamp(); @Override List<StartIdentifiedAtlasDbTransactionResponse> startIdentifiedAtlasDbTransactionBatch(int count); @Override long getImmutableTimestamp(); @Override LockResponse lock(LockRequest request); @Override WaitForLocksResponse waitForLocks(WaitForLocksRequest request); @Override Set<LockToken> refreshLockLeases(Set<LockToken> tokens); @Override Set<LockToken> unlock(Set<LockToken> tokens); @Override void tryUnlock(Set<LockToken> tokens); @Override long currentTimeMillis(); @Override void close(); }
TimeLockClient implements AutoCloseable, TimelockService { @Override public LockResponse lock(LockRequest request) { LockResponse response = executeOnTimeLock(() -> delegate.lock(request)); if (response.wasSuccessful()) { lockRefresher.registerLocks(ImmutableSet.of(response.getToken())); } return response; } @VisibleForTesting  TimeLockClient(TimelockService delegate, CloseableTimestampService timestampService,
            LockRefresher lockRefresher, TimeLockUnlocker unlocker); static TimeLockClient createDefault(TimelockService timelockService); static TimeLockClient withSynchronousUnlocker(TimelockService timelockService); @Override boolean isInitialized(); @Override long getFreshTimestamp(); @Override long getCommitTimestamp(long startTs, LockToken commitLocksToken); @Override TimestampRange getFreshTimestamps(int numTimestampsRequested); @Override LockImmutableTimestampResponse lockImmutableTimestamp(); @Override List<StartIdentifiedAtlasDbTransactionResponse> startIdentifiedAtlasDbTransactionBatch(int count); @Override long getImmutableTimestamp(); @Override LockResponse lock(LockRequest request); @Override WaitForLocksResponse waitForLocks(WaitForLocksRequest request); @Override Set<LockToken> refreshLockLeases(Set<LockToken> tokens); @Override Set<LockToken> unlock(Set<LockToken> tokens); @Override void tryUnlock(Set<LockToken> tokens); @Override long currentTimeMillis(); @Override void close();  }