Search in sources :

Example 1 with KeyValueServiceMigrator

use of com.palantir.atlasdb.schema.KeyValueServiceMigrator in project atlasdb by palantir.

the class KvsMigrationCommand method execute.

public int execute(AtlasDbServices fromServices, AtlasDbServices toServices) {
    if (!setup && !migrate && !validate) {
        printer.error("At least one of --setup, --migrate, or --validate should be specified.");
        return 1;
    }
    KeyValueServiceMigrator migrator;
    try {
        migrator = getMigrator(fromServices, toServices);
    } catch (IOException e) {
        throw Throwables.rewrapAndThrowUncheckedException(e);
    }
    if (setup) {
        migrator.setup();
    }
    if (migrate) {
        migrator.migrate();
        migrator.cleanup();
    }
    if (validate) {
        KeyValueServiceValidator validator = new KeyValueServiceValidator(fromServices.getTransactionManager(), toServices.getTransactionManager(), fromServices.getKeyValueService(), threads, batchSize, ImmutableMap.of(), (String message, KeyValueServiceMigrator.KvsMigrationMessageLevel level) -> printer.info(level.toString() + ": " + message), ImmutableSet.of());
        validator.validate(true);
    }
    return 0;
}
Also used : KeyValueServiceMigrator(com.palantir.atlasdb.schema.KeyValueServiceMigrator) KeyValueServiceValidator(com.palantir.atlasdb.schema.KeyValueServiceValidator) IOException(java.io.IOException)

Example 2 with KeyValueServiceMigrator

use of com.palantir.atlasdb.schema.KeyValueServiceMigrator 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)

Aggregations

KeyValueServiceMigrator (com.palantir.atlasdb.schema.KeyValueServiceMigrator)2 KeyValueServiceValidator (com.palantir.atlasdb.schema.KeyValueServiceValidator)1 TaskProgress (com.palantir.atlasdb.schema.TaskProgress)1 AtlasDbServices (com.palantir.atlasdb.services.AtlasDbServices)1 TimestampManagementService (com.palantir.timestamp.TimestampManagementService)1 IOException (java.io.IOException)1