Search in sources :

Example 1 with AtlasBackupClient

use of com.palantir.atlasdb.backup.api.AtlasBackupClient in project atlasdb by palantir.

the class AtlasBackupService method create.

public static AtlasBackupService create(AuthHeader authHeader, Refreshable<ServicesConfigBlock> servicesConfigBlock, String serviceName, Function<AtlasService, Path> backupFolderFactory, Function<AtlasService, KeyValueService> keyValueServiceFactory, int completeBackupNumThreads) {
    ReloadingFactory reloadingFactory = DialogueClients.create(servicesConfigBlock).withUserAgent(UserAgent.of(AtlasDbRemotingConstants.ATLASDB_HTTP_CLIENT_AGENT));
    AtlasBackupClient atlasBackupClient = new DialogueAdaptingAtlasBackupClient(reloadingFactory.get(AtlasBackupClientBlocking.class, serviceName));
    KvsRunner kvsRunner = KvsRunner.create(keyValueServiceFactory);
    return createAtlasBackupService(authHeader, atlasBackupClient, backupFolderFactory, kvsRunner, completeBackupNumThreads);
}
Also used : ReloadingFactory(com.palantir.dialogue.clients.DialogueClients.ReloadingFactory) AtlasBackupClientBlocking(com.palantir.atlasdb.backup.api.AtlasBackupClientBlocking) AtlasBackupClient(com.palantir.atlasdb.backup.api.AtlasBackupClient)

Example 2 with AtlasBackupClient

use of com.palantir.atlasdb.backup.api.AtlasBackupClient in project atlasdb by palantir.

the class AtlasBackupService method create.

public static AtlasBackupService create(AuthHeader authHeader, Refreshable<ServicesConfigBlock> servicesConfigBlock, String serviceName, Function<Namespace, Path> backupFolderFactory, Function<Namespace, KeyValueService> keyValueServiceFactory) {
    ReloadingFactory reloadingFactory = DialogueClients.create(servicesConfigBlock).withUserAgent(UserAgent.of(AtlasDbRemotingConstants.ATLASDB_HTTP_CLIENT_AGENT));
    AtlasBackupClient atlasBackupClient = new DialogueAdaptingAtlasBackupClient(reloadingFactory.get(AtlasBackupClientBlocking.class, serviceName));
    BackupPersister backupPersister = new ExternalBackupPersister(backupFolderFactory);
    KvsRunner kvsRunner = KvsRunner.create(keyValueServiceFactory);
    CoordinationServiceRecorder coordinationServiceRecorder = new CoordinationServiceRecorder(kvsRunner, backupPersister);
    return new AtlasBackupService(authHeader, atlasBackupClient, coordinationServiceRecorder, backupPersister);
}
Also used : ReloadingFactory(com.palantir.dialogue.clients.DialogueClients.ReloadingFactory) AtlasBackupClientBlocking(com.palantir.atlasdb.backup.api.AtlasBackupClientBlocking) AtlasBackupClient(com.palantir.atlasdb.backup.api.AtlasBackupClient)

Example 3 with AtlasBackupClient

use of com.palantir.atlasdb.backup.api.AtlasBackupClient in project atlasdb by palantir.

the class AtlasDbEteServer method createAndRegisterBackupAndRestoreResource.

private void createAndRegisterBackupAndRestoreResource(AtlasDbEteConfiguration config, Environment environment, TransactionManager txManager, TaggedMetricRegistry taggedMetrics) throws IOException {
    AuthHeader authHeader = AuthHeader.of(BearerToken.valueOf("test-auth"));
    URL localServer = new URL("https://localhost:1234");
    Path backupFolder = Paths.get("/var/data/backup");
    Files.createDirectories(backupFolder);
    Function<AtlasService, Path> backupFolderFactory = _unused -> backupFolder;
    ExternalBackupPersister externalBackupPersister = new ExternalBackupPersister(backupFolderFactory);
    Function<String, BackupTimeLockServiceView> timelockServices = _unused -> createBackupTimeLockServiceView(txManager);
    AuthHeaderValidator authHeaderValidator = new AuthHeaderValidator(() -> Optional.of(authHeader.getBearerToken()));
    RedirectRetryTargeter redirectRetryTargeter = RedirectRetryTargeter.create(localServer, ImmutableList.of(localServer));
    AtlasBackupClient atlasBackupClient = AtlasBackupResource.jersey(authHeaderValidator, redirectRetryTargeter, timelockServices);
    AtlasRestoreClient atlasRestoreClient = AtlasRestoreResource.jersey(authHeaderValidator, redirectRetryTargeter, timelockServices);
    Refreshable<ServerListConfig> serverListConfig = getServerListConfigForTimeLock(config);
    TimeLockManagementService timeLockManagementService = getRemoteTimeLockManagementService(serverListConfig, taggedMetrics);
    AtlasBackupService atlasBackupService = AtlasBackupService.createForTests(authHeader, atlasBackupClient, txManager, backupFolderFactory);
    Function<AtlasService, CassandraKeyValueServiceConfig> keyValueServiceConfigFactory = _unused -> (CassandraKeyValueServiceConfig) config.getAtlasDbConfig().keyValueService();
    Function<AtlasService, CassandraKeyValueServiceRuntimeConfig> runtimeConfigFactory = _unused -> (CassandraKeyValueServiceRuntimeConfig) config.getAtlasDbRuntimeConfig().flatMap(AtlasDbRuntimeConfig::keyValueService).orElseThrow();
    Function<AtlasService, CassandraClusterConfig> cassandraClusterConfigFactory = atlasService -> CassandraClusterConfig.of(keyValueServiceConfigFactory.apply(atlasService), runtimeConfigFactory.apply(atlasService));
    Function<AtlasService, Refreshable<CassandraServersConfig>> refreshableCassandraServersConfigFactory = runtimeConfigFactory.andThen(runtimeConfig -> Refreshable.only(runtimeConfig.servers()));
    AtlasRestoreService atlasRestoreService = AtlasRestoreService.createForTests(authHeader, atlasRestoreClient, timeLockManagementService, externalBackupPersister, txManager, cassandraClusterConfigFactory, refreshableCassandraServersConfigFactory);
    environment.jersey().register(new SimpleBackupAndRestoreResource(atlasBackupService, atlasRestoreService, externalBackupPersister));
}
Also used : TransactionService(com.palantir.atlasdb.transaction.service.TransactionService) ServerListConfigs(com.palantir.atlasdb.config.ServerListConfigs) NotInitializedExceptionMapper(com.palantir.atlasdb.http.NotInitializedExceptionMapper) LongSupplier(java.util.function.LongSupplier) SimpleLockResource(com.palantir.atlasdb.lock.SimpleLockResource) URL(java.net.URL) AtlasRestoreClient(com.palantir.atlasdb.backup.api.AtlasRestoreClient) SafeIllegalStateException(com.palantir.logsafe.exceptions.SafeIllegalStateException) ExceptionMapper(javax.ws.rs.ext.ExceptionMapper) AuthHeader(com.palantir.tokens.auth.AuthHeader) BlobSchema(com.palantir.atlasdb.blob.BlobSchema) TargetedSweepFollower(com.palantir.atlasdb.sweep.queue.TargetedSweepFollower) SimpleTodoResource(com.palantir.atlasdb.todo.SimpleTodoResource) RedirectRetryTargeter(com.palantir.atlasdb.http.RedirectRetryTargeter) AtlasBackupService(com.palantir.atlasdb.backup.AtlasBackupService) UserAgent(com.palantir.conjure.java.api.config.service.UserAgent) TransactionServices(com.palantir.atlasdb.transaction.service.TransactionServices) CoordinationServices(com.palantir.atlasdb.internalschema.persistence.CoordinationServices) SweepTaskRunner(com.palantir.atlasdb.sweep.SweepTaskRunner) Path(java.nio.file.Path) InternalSchemaMetadata(com.palantir.atlasdb.internalschema.InternalSchemaMetadata) CassandraServersConfig(com.palantir.atlasdb.cassandra.CassandraServersConfigs.CassandraServersConfig) Refreshable(com.palantir.refreshable.Refreshable) Application(io.dropwizard.Application) ImmutableSet(com.google.common.collect.ImmutableSet) TimestampManagementService(com.palantir.timestamp.TimestampManagementService) CoordinationService(com.palantir.atlasdb.coordination.CoordinationService) AtlasDbDialogueServiceProvider(com.palantir.atlasdb.factory.AtlasDbDialogueServiceProvider) BackupTimeLockServiceView(com.palantir.atlasdb.timelock.BackupTimeLockServiceView) SharedMetricRegistries(com.codahale.metrics.SharedMetricRegistries) TransactionManager(com.palantir.atlasdb.transaction.api.TransactionManager) Jdk8Module(com.fasterxml.jackson.datatype.jdk8.Jdk8Module) ServerListConfig(com.palantir.atlasdb.config.ServerListConfig) MetricsManagers(com.palantir.atlasdb.util.MetricsManagers) ServicesConfigBlock(com.palantir.conjure.java.api.config.service.ServicesConfigBlock) SimpleBackupAndRestoreResource(com.palantir.atlasdb.backup.SimpleBackupAndRestoreResource) Response(javax.ws.rs.core.Response) AtlasBackupResource(com.palantir.atlasdb.backup.AtlasBackupResource) AtlasRestoreService(com.palantir.atlasdb.backup.AtlasRestoreService) Optional(java.util.Optional) SpecialTimestampsSupplier(com.palantir.atlasdb.sweep.queue.SpecialTimestampsSupplier) SimpleEteTimestampResource(com.palantir.atlasdb.timestamp.SimpleEteTimestampResource) CassandraKeyValueServiceConfig(com.palantir.atlasdb.cassandra.CassandraKeyValueServiceConfig) TodoClient(com.palantir.atlasdb.todo.TodoClient) CassandraKeyValueServiceRuntimeConfig(com.palantir.atlasdb.cassandra.CassandraKeyValueServiceRuntimeConfig) SafeLoggerFactory(com.palantir.logsafe.logger.SafeLoggerFactory) AtlasBackupClient(com.palantir.atlasdb.backup.api.AtlasBackupClient) Bootstrap(io.dropwizard.setup.Bootstrap) Stopwatch(com.google.common.base.Stopwatch) TodoSchema(com.palantir.atlasdb.todo.TodoSchema) ExternalBackupPersister(com.palantir.atlasdb.backup.ExternalBackupPersister) Function(java.util.function.Function) Supplier(java.util.function.Supplier) TransactionManagers(com.palantir.atlasdb.factory.TransactionManagers) SafeLogger(com.palantir.logsafe.logger.SafeLogger) AtlasRestoreResource(com.palantir.atlasdb.backup.AtlasRestoreResource) TimeLockManagementService(com.palantir.atlasdb.timelock.api.management.TimeLockManagementService) BearerToken(com.palantir.tokens.auth.BearerToken) SubstitutingSourceProvider(io.dropwizard.configuration.SubstitutingSourceProvider) ImmutableList(com.google.common.collect.ImmutableList) EnvironmentVariableSubstitutor(io.dropwizard.configuration.EnvironmentVariableSubstitutor) TransactionSchemaVersionEnforcement(com.palantir.atlasdb.transaction.impl.TransactionSchemaVersionEnforcement) Suppliers(com.google.common.base.Suppliers) SimpleCoordinationResource(com.palantir.atlasdb.coordination.SimpleCoordinationResource) SharedTaggedMetricRegistries(com.palantir.tritium.metrics.registry.SharedTaggedMetricRegistries) Environment(io.dropwizard.setup.Environment) Files(java.nio.file.Files) CassandraClusterConfig(com.palantir.atlasdb.keyvalue.cassandra.async.client.creation.ClusterFactory.CassandraClusterConfig) TargetedSweeper(com.palantir.atlasdb.sweep.queue.TargetedSweeper) IOException(java.io.IOException) TransactionSchemaManager(com.palantir.atlasdb.internalschema.TransactionSchemaManager) TimelockService(com.palantir.lock.v2.TimelockService) TaggedMetricRegistry(com.palantir.tritium.metrics.registry.TaggedMetricRegistry) DelegatingBackupTimeLockServiceView(com.palantir.atlasdb.backup.DelegatingBackupTimeLockServiceView) TimeUnit(java.util.concurrent.TimeUnit) AtlasDbRuntimeConfig(com.palantir.atlasdb.config.AtlasDbRuntimeConfig) EmptyOptionalException(io.dropwizard.jersey.optional.EmptyOptionalException) Follower(com.palantir.atlasdb.cleaner.Follower) Paths(java.nio.file.Paths) KeyValueService(com.palantir.atlasdb.keyvalue.api.KeyValueService) ConjureJerseyFeature(com.palantir.conjure.java.server.jersey.ConjureJerseyFeature) AtlasDbRemotingConstants(com.palantir.atlasdb.http.AtlasDbRemotingConstants) CellsSweeper(com.palantir.atlasdb.sweep.CellsSweeper) AuthHeaderValidator(com.palantir.atlasdb.backup.AuthHeaderValidator) AtlasService(com.palantir.atlasdb.backup.api.AtlasService) DialogueClients(com.palantir.dialogue.clients.DialogueClients) Schema(com.palantir.atlasdb.table.description.Schema) CleanupFollower(com.palantir.atlasdb.cleaner.CleanupFollower) AtlasDbConfig(com.palantir.atlasdb.config.AtlasDbConfig) CassandraKeyValueServiceRuntimeConfig(com.palantir.atlasdb.cassandra.CassandraKeyValueServiceRuntimeConfig) AtlasService(com.palantir.atlasdb.backup.api.AtlasService) TimeLockManagementService(com.palantir.atlasdb.timelock.api.management.TimeLockManagementService) URL(java.net.URL) CassandraKeyValueServiceConfig(com.palantir.atlasdb.cassandra.CassandraKeyValueServiceConfig) Path(java.nio.file.Path) ExternalBackupPersister(com.palantir.atlasdb.backup.ExternalBackupPersister) SimpleBackupAndRestoreResource(com.palantir.atlasdb.backup.SimpleBackupAndRestoreResource) AuthHeader(com.palantir.tokens.auth.AuthHeader) BackupTimeLockServiceView(com.palantir.atlasdb.timelock.BackupTimeLockServiceView) DelegatingBackupTimeLockServiceView(com.palantir.atlasdb.backup.DelegatingBackupTimeLockServiceView) CassandraClusterConfig(com.palantir.atlasdb.keyvalue.cassandra.async.client.creation.ClusterFactory.CassandraClusterConfig) Refreshable(com.palantir.refreshable.Refreshable) AtlasRestoreClient(com.palantir.atlasdb.backup.api.AtlasRestoreClient) RedirectRetryTargeter(com.palantir.atlasdb.http.RedirectRetryTargeter) ServerListConfig(com.palantir.atlasdb.config.ServerListConfig) AuthHeaderValidator(com.palantir.atlasdb.backup.AuthHeaderValidator) AtlasBackupClient(com.palantir.atlasdb.backup.api.AtlasBackupClient) AtlasRestoreService(com.palantir.atlasdb.backup.AtlasRestoreService) AtlasBackupService(com.palantir.atlasdb.backup.AtlasBackupService) AtlasDbRuntimeConfig(com.palantir.atlasdb.config.AtlasDbRuntimeConfig)

Aggregations

AtlasBackupClient (com.palantir.atlasdb.backup.api.AtlasBackupClient)3 AtlasBackupClientBlocking (com.palantir.atlasdb.backup.api.AtlasBackupClientBlocking)2 SharedMetricRegistries (com.codahale.metrics.SharedMetricRegistries)1 Jdk8Module (com.fasterxml.jackson.datatype.jdk8.Jdk8Module)1 Stopwatch (com.google.common.base.Stopwatch)1 Suppliers (com.google.common.base.Suppliers)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 AtlasBackupResource (com.palantir.atlasdb.backup.AtlasBackupResource)1 AtlasBackupService (com.palantir.atlasdb.backup.AtlasBackupService)1 AtlasRestoreResource (com.palantir.atlasdb.backup.AtlasRestoreResource)1 AtlasRestoreService (com.palantir.atlasdb.backup.AtlasRestoreService)1 AuthHeaderValidator (com.palantir.atlasdb.backup.AuthHeaderValidator)1 DelegatingBackupTimeLockServiceView (com.palantir.atlasdb.backup.DelegatingBackupTimeLockServiceView)1 ExternalBackupPersister (com.palantir.atlasdb.backup.ExternalBackupPersister)1 SimpleBackupAndRestoreResource (com.palantir.atlasdb.backup.SimpleBackupAndRestoreResource)1 AtlasRestoreClient (com.palantir.atlasdb.backup.api.AtlasRestoreClient)1 AtlasService (com.palantir.atlasdb.backup.api.AtlasService)1 BlobSchema (com.palantir.atlasdb.blob.BlobSchema)1 CassandraKeyValueServiceConfig (com.palantir.atlasdb.cassandra.CassandraKeyValueServiceConfig)1