@Override public long getFreshTimestamp() { return timestampService.getFreshTimestamp(); }
private static TimestampRange getFreshTimestampsFromDelegate(TimestampService timestampService, int timestamps) { if (timestamps == 1) { long timestamp = timestampService.getFreshTimestamp(); return TimestampRange.createInclusiveRange(timestamp, timestamp); } return timestampService.getFreshTimestamps(timestamps); }
@Override public boolean isInitialized() { return timestampService.isInitialized(); }
@Test public void syncInitTimestampServiceSynchronous() { TimestampService timestampService = factory.createTimestampService(null, Optional.empty(), false); assertThat(timestampService.isInitialized()).isTrue(); assertThat(timestampService.getFreshTimestamp()).isEqualTo(1L); }
@Override public TimestampRange getFreshTimestamps(int numTimestampsRequested) { return timestampService.getFreshTimestamps(numTimestampsRequested); }
@Test public void syncInitTimestampServiceSynchronous() { TimestampService timestampService = factory.createTimestampService(null, Optional.empty(), false); assertThat(timestampService.isInitialized()).isTrue(); assertThat(timestampService.getFreshTimestamp()).isEqualTo(1L); }
@Override public TimestampRange getFreshTimestamps(int numTimestampsRequested) { return decoratedTimestamps.getFreshTimestamps(numTimestampsRequested); }
@Override public long getFreshTimestamp() { return decoratedTimestamps.getFreshTimestamp(); }
@Test public void canRequestMoreTimestampsThanAreAllocatedAtOnce() { for (int i = 0; i < ONE_MILLION / ONE_THOUSAND; i++) { timestampService.getFreshTimestamps(ONE_THOUSAND); } Assertions.assertThat(timestampService.getFreshTimestamp()).isGreaterThanOrEqualTo(ONE_MILLION + 1); }
@Test public void asyncInitTimestampServiceSynchronous() { KeyValueService kvs = createRawKeyValueService(true); TimestampService timestampService = factory.createTimestampService(kvs, Optional.empty(), true); assertThat(timestampService.isInitialized()).isTrue(); assertThat(timestampService.getFreshTimestamp()).isEqualTo(1L); }
public TimestampRange getFreshTimestamps(int num) { return timestampService.getFreshTimestamps(num); }
@Override public boolean isInitialized() { return delegate.isInitialized(); }
@Override public long getFreshTimestamp() { return timestampService.getFreshTimestamp(); }
private static TimestampRange getFreshTimestampsFromDelegate(TimestampService timestampService, int timestamps) { if (timestamps == 1) { long timestamp = timestampService.getFreshTimestamp(); return TimestampRange.createInclusiveRange(timestamp, timestamp); } return timestampService.getFreshTimestamps(timestamps); }
@Test public void asyncInitTimestampServiceWithReadyKvsSynchronous() { KeyValueService kvs = createRawKeyValueService(false); TimestampService timestampService = factory.createTimestampService(kvs, Optional.empty(), true); assertThat(timestampService.isInitialized()).isTrue(); assertThat(timestampService.getFreshTimestamp()).isEqualTo(1L); }
@Override public TimestampRange getFreshTimestamps(@QueryParam("number") int numTimestampsRequested) { return timestampService.getFreshTimestamps(numTimestampsRequested); }
@Override public boolean isInitialized() { return timestampService.isInitialized(); }
@Override public long getFreshTimestamp() { return timestampService.getFreshTimestamp(); }
private void runAndVerifyCli(Verifier verifier) throws Exception { try (SingleBackendCliTestRunner runner = makeRunner(cliArgs.toArray(new String[0]))) { TestAtlasDbServices services = runner.connect(moduleFactory); LockService lockService = services.getLockService(); TimestampService tss = services.getTimestampService(); LockClient client = services.getTestLockClient(); Clock clock = GlobalClock.create(lockService); long prePunch = clock.getTimeMillis(); punch(services, tss, clock); long postPunch = clock.getTimeMillis(); long immutableTs = tss.getFreshTimestamp(); LockRequest request = LockRequest.builder(ImmutableSortedMap.of(lock, LockMode.WRITE)) .withLockedInVersionId(immutableTs) .doNotBlock() .build(); LockRefreshToken token = lockService.lock(client.getClientId(), request); long lastFreshTs = tss.getFreshTimestamps(1000).getUpperBound(); verifier.verify(runner, tss, immutableTs, prePunch, postPunch, lastFreshTs, true); lockService.unlock(token); lastFreshTs = tss.getFreshTimestamps(1000).getUpperBound(); // there are no locks so we now expect immutable to just be a fresh runner.freshCommand(); verifier.verify(runner, tss, immutableTs, prePunch, postPunch, lastFreshTs, false); } }
@Test public void asyncInitTimestampServiceWithAsyncKvsAsynchronous() { KeyValueService kvs = createRawKeyValueService(true); TimestampService timestampService = factory.createTimestampService(kvs, Optional.empty(), true); assertThat(timestampService.isInitialized()).isFalse(); assertThatThrownBy(timestampService::getFreshTimestamp).isInstanceOf(NotInitializedException.class); Awaitility.await().atMost(3, TimeUnit.SECONDS).until(timestampService::isInitialized); assertThat(timestampService.getFreshTimestamp()).isEqualTo(1L); }