@Override public void fastForwardTimestamp(@QueryParam("currentTimestamp") long currentTimestamp) { timestampManagementService.fastForwardTimestamp(currentTimestamp); }
@Override @SuppressWarnings({"CheckReturnValue", "ResultOfMethodCallIgnored"}) // errorprone doesn't pick up "when=NEVER" protected synchronized void tryInitialize() { try { destination.ping(); } catch (Exception e) { throw new AtlasDbDependencyException("Could not contact the Timelock Server.", e); } long currentTimestamp = source.backupAndInvalidate(); destination.fastForwardTimestamp(currentTimestamp); }
@Override public String ping() { return timestampManagementService.ping(); } }
@Override public String ping() { return timestampManagementService.ping(); } }
@Override public void fastForwardTimestamp(long currentTimestamp) { transactionManager.getTimestampManagementService().fastForwardTimestamp(currentTimestamp); }
@Override @SuppressWarnings({"CheckReturnValue", "ResultOfMethodCallIgnored"}) // errorprone doesn't pick up "when=NEVER" protected synchronized void tryInitialize() { try { destination.ping(); } catch (Exception e) { throw new AtlasDbDependencyException("Could not contact the Timelock Server.", e); } long currentTimestamp = source.backupAndInvalidate(); destination.fastForwardTimestamp(currentTimestamp); }
@Test public void willDoNothingWhenFastForwardToEarlierTimestamp() { timestampManagementService.fastForwardTimestamp(TWO_MILLION); long ts1 = timestampService.getFreshTimestamp(); timestampManagementService.fastForwardTimestamp(ONE_MILLION); long ts2 = timestampService.getFreshTimestamp(); Assertions.assertThat(ts2).isGreaterThan(TWO_MILLION); Assertions.assertThat(ts2).isGreaterThan(ts1); }
@Test public void willNotHandOutTimestampsEarlierThanAFastForward() { timestampManagementService.fastForwardTimestamp(TWO_MILLION); Assertions.assertThat(timestampService.getFreshTimestamp()).isGreaterThan(TWO_MILLION); }
@Before public void advanceTimestamp() { ((TimestampManagementService) timestampService).fastForwardTimestamp(ONE_BILLION); }
@Test public void testFastForwardTimestampDefersToTimestampManagementService() { managedTimestampService.fastForwardTimestamp(LEADING_PI_DIGITS); verify(timestampManagementService, times(1)).fastForwardTimestamp(eq(LEADING_PI_DIGITS)); }
@Override protected int executeTimestampCommand(AtlasDbServices services) { printer.warn( "This CLI has been deprecated. Please use the timestamp-management/fast-forward endpoint instead."); TimestampService ts = services.getTimestampService(); if (!(ts instanceof TimestampManagementService)) { printer.error("Timestamp service must be of type {}, but yours is {}. Exiting.", SafeArg.of("expected type", TimestampManagementService.class.toString()), SafeArg.of("found type", ts.getClass().toString())); return 1; } TimestampManagementService tms = (TimestampManagementService) ts; tms.fastForwardTimestamp(timestamp); printer.info("Timestamp successfully fast-forwarded to {}", SafeArg.of("timestamp", timestamp)); return 0; } }
@Test(expected = IllegalArgumentException.class) public void shouldRejectFastForwardToTheSentinelValue() { getTimestampManagementService().fastForwardTimestamp(TimestampManagementService.SENTINEL_TIMESTAMP); }
@Test public void shouldExposeATimestampManagementServer() { TimestampService timestampClient = EteSetup.createClientToAllNodes(TimestampService.class); TimestampManagementService timestampManagementClient = EteSetup.createClientToAllNodes(TimestampManagementService.class); assertThat(timestampClient.getFreshTimestamp(), is(not(nullValue()))); long newts = timestampClient.getFreshTimestamp() + 10000000; timestampManagementClient.fastForwardTimestamp(newts); assertThat(timestampClient.getFreshTimestamp(), is(greaterThan(newts))); } }
@Test public void setupMigratorFastForwardsTimestamp() { KeyValueServiceMigrators.getTimestampManagementService(fromServices).fastForwardTimestamp(FUTURE_TIMESTAMP); assertThat(toServices.getTimestampService().getFreshTimestamp()).isLessThan(FUTURE_TIMESTAMP); KeyValueServiceMigrators.setupMigrator(migratorSpec); assertThat(toServices.getTimestampService().getFreshTimestamp()).isGreaterThanOrEqualTo(FUTURE_TIMESTAMP); }
TimestampManagementService toTimestampManagementService = getTimestampManagementService(toServices); toTimestampManagementService.fastForwardTimestamp(fromServices.getTimestampService().getFreshTimestamp() + 1); long migrationStartTimestamp = toServices.getTimestampService().getFreshTimestamp(); long migrationCommitTimestamp = toServices.getTimestampService().getFreshTimestamp();
@Override public void fastForwardTimestamp(@QueryParam("currentTimestamp") long currentTimestamp) { timestampManagementService.fastForwardTimestamp(currentTimestamp); }
@Test public void willDoNothingWhenFastForwardToEarlierTimestamp() { timestampManagementService.fastForwardTimestamp(TWO_MILLION); long ts1 = timestampService.getFreshTimestamp(); timestampManagementService.fastForwardTimestamp(ONE_MILLION); long ts2 = timestampService.getFreshTimestamp(); Assertions.assertThat(ts2).isGreaterThan(TWO_MILLION); Assertions.assertThat(ts2).isGreaterThan(ts1); }
@Test public void willNotHandOutTimestampsEarlierThanAFastForward() { timestampManagementService.fastForwardTimestamp(TWO_MILLION); Assertions.assertThat(timestampService.getFreshTimestamp()).isGreaterThan(TWO_MILLION); }
@Override protected int executeTimestampCommand(AtlasDbServices services) { printer.warn( "This CLI has been deprecated. Please use the timestamp-management/fast-forward endpoint instead."); TimestampService ts = services.getTimestampService(); if (!(ts instanceof TimestampManagementService)) { printer.error("Timestamp service must be of type {}, but yours is {}. Exiting.", SafeArg.of("expected type", TimestampManagementService.class.toString()), SafeArg.of("found type", ts.getClass().toString())); return 1; } TimestampManagementService tms = (TimestampManagementService) ts; tms.fastForwardTimestamp(timestamp); printer.info("Timestamp successfully fast-forwarded to {}", SafeArg.of("timestamp", timestamp)); return 0; } }
TimestampManagementService toTimestampManagementService = getTimestampManagementService(toServices); toTimestampManagementService.fastForwardTimestamp(fromServices.getTimestampService().getFreshTimestamp() + 1); long migrationStartTimestamp = toServices.getTimestampService().getFreshTimestamp(); long migrationCommitTimestamp = toServices.getTimestampService().getFreshTimestamp();