Search in sources :

Example 1 with TimestampManagementService

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);
}
Also used : TimestampManagementService(com.palantir.timestamp.TimestampManagementService) TimestampService(com.palantir.timestamp.TimestampService) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 2 with TimestampManagementService

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);
}
Also used : ServiceDiscoveringAtlasSupplier(com.palantir.atlasdb.factory.ServiceDiscoveringAtlasSupplier) TimestampManagementService(com.palantir.timestamp.TimestampManagementService) DelegatingManagedTimestampService(com.palantir.atlasdb.timelock.paxos.DelegatingManagedTimestampService) ManagedTimestampService(com.palantir.atlasdb.timelock.paxos.ManagedTimestampService) TimestampService(com.palantir.timestamp.TimestampService) DelegatingManagedTimestampService(com.palantir.atlasdb.timelock.paxos.DelegatingManagedTimestampService)

Example 3 with TimestampManagementService

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);
}
Also used : TimestampManagementService(com.palantir.timestamp.TimestampManagementService) Test(org.junit.Test)

Example 4 with TimestampManagementService

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());
}
Also used : KeyValueServiceMigrator(com.palantir.atlasdb.schema.KeyValueServiceMigrator) TimestampManagementService(com.palantir.timestamp.TimestampManagementService) AtlasDbServices(com.palantir.atlasdb.services.AtlasDbServices) TaskProgress(com.palantir.atlasdb.schema.TaskProgress)

Example 5 with TimestampManagementService

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;
}
Also used : TimestampManagementService(com.palantir.timestamp.TimestampManagementService) TimestampService(com.palantir.timestamp.TimestampService)

Aggregations

TimestampManagementService (com.palantir.timestamp.TimestampManagementService)5 TimestampService (com.palantir.timestamp.TimestampService)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ServiceDiscoveringAtlasSupplier (com.palantir.atlasdb.factory.ServiceDiscoveringAtlasSupplier)1 KeyValueServiceMigrator (com.palantir.atlasdb.schema.KeyValueServiceMigrator)1 TaskProgress (com.palantir.atlasdb.schema.TaskProgress)1 AtlasDbServices (com.palantir.atlasdb.services.AtlasDbServices)1 DelegatingManagedTimestampService (com.palantir.atlasdb.timelock.paxos.DelegatingManagedTimestampService)1 ManagedTimestampService (com.palantir.atlasdb.timelock.paxos.ManagedTimestampService)1 Test (org.junit.Test)1