use of com.palantir.timestamp.TimestampManagementService in project atlasdb by palantir.
the class KeyValueServiceMigrators method getTimestampManagementService.
@VisibleForTesting
static TimestampManagementService getTimestampManagementService(AtlasDbServices toServices) {
TimestampService toTimestampService = toServices.getTimestampService();
if (toTimestampService instanceof TimestampManagementService) {
return (TimestampManagementService) toTimestampService;
}
String errorMessage = String.format("Timestamp service must be of type %s, but yours is %s. Exiting.", TimestampManagementService.class.toString(), toTimestampService.getClass().toString());
printer.error(errorMessage);
throw new IllegalArgumentException(errorMessage);
}
use of com.palantir.timestamp.TimestampManagementService in project atlasdb by palantir.
the class DbBoundTimestampCreator method createTimestampService.
@Override
public Supplier<ManagedTimestampService> createTimestampService(String client, LeaderConfig leaderConfig) {
ServiceDiscoveringAtlasSupplier atlasFactory = new ServiceDiscoveringAtlasSupplier(kvsConfig, Optional.of(leaderConfig), Optional.empty(), Optional.of(AtlasDbConstants.TIMELOCK_TIMESTAMP_TABLE));
TimestampService timestampService = atlasFactory.getTimestampService();
Preconditions.checkArgument(TimestampManagementService.class.isInstance(timestampService), "The timestamp service is not a managed timestamp service.");
return () -> new DelegatingManagedTimestampService(timestampService, (TimestampManagementService) timestampService);
}
use of com.palantir.timestamp.TimestampManagementService in project atlasdb by palantir.
the class PaxosTimeLockServerIntegrationTest method fastForwardRespectsDistinctClients.
@Test
public void fastForwardRespectsDistinctClients() {
TimestampManagementService anotherClientTimestampManagementService = getTimestampManagementService(CLIENT_2);
long currentTimestamp = timestampService.getFreshTimestamp();
anotherClientTimestampManagementService.fastForwardTimestamp(currentTimestamp + ONE_MILLION);
assertThat(timestampService.getFreshTimestamp()).isBetween(currentTimestamp + 1, currentTimestamp + ONE_MILLION - 1);
}
use of com.palantir.timestamp.TimestampManagementService in project atlasdb by palantir.
the class KeyValueServiceMigrators method setupMigrator.
public static KeyValueServiceMigrator setupMigrator(MigratorSpec migratorSpec) {
AtlasDbServices fromServices = migratorSpec.fromServices();
long migrationStartTimestamp = fromServices.getTimestampService().getFreshTimestamp();
long migrationCommitTimestamp = fromServices.getTimestampService().getFreshTimestamp();
AtlasDbServices toServices = migratorSpec.toServices();
TimestampManagementService toTimestampManagementService = getTimestampManagementService(toServices);
toServices.getTransactionService().putUnlessExists(migrationStartTimestamp, migrationCommitTimestamp);
toTimestampManagementService.fastForwardTimestamp(migrationCommitTimestamp + 1);
return new KeyValueServiceMigrator(CHECKPOINT_NAMESPACE, fromServices.getTransactionManager(), toServices.getTransactionManager(), fromServices.getKeyValueService(), toServices.getKeyValueService(), Suppliers.ofInstance(migrationStartTimestamp), migratorSpec.threads(), migratorSpec.batchSize(), ImmutableMap.of(), (String message, KeyValueServiceMigrator.KvsMigrationMessageLevel level) -> printer.info(level.toString() + ": " + message), new TaskProgress() {
@Override
public void beginTask(String message, int tasks) {
printer.info(message);
}
@Override
public void subTaskComplete() {
//
}
@Override
public void taskComplete() {
//
}
}, ImmutableSet.of());
}
use of com.palantir.timestamp.TimestampManagementService in project atlasdb by palantir.
the class FastForwardTimestamp method executeTimestampCommand.
@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;
}
Aggregations