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);
}
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);
}
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));
}
Aggregations