use of com.palantir.atlasdb.timelock.BackupTimeLockServiceView in project atlasdb by palantir.
the class AtlasRestoreResource method completeRestoreAsync.
private ListenableFuture<Optional<Namespace>> completeRestoreAsync(Namespace namespace, CompletedBackup completedBackup) {
BackupTimeLockServiceView timelock = timelock(namespace);
timelock.fastForwardTimestamp(completedBackup.getBackupEndTimestamp());
return Futures.immediateFuture(Optional.of(namespace));
}
use of com.palantir.atlasdb.timelock.BackupTimeLockServiceView in project atlasdb by palantir.
the class TimeLockAgent method createAndRegisterResources.
private void createAndRegisterResources() {
registerTimeLockCorruptionJerseyFilter();
registerTimeLockCorruptionNotifiers();
registerPaxosResource();
registerExceptionMappers();
registerClientFeedbackService();
namespaces = new TimelockNamespaces(metricsManager, this::createInvalidatingTimeLockServices, Suppliers.compose(TimeLockRuntimeConfiguration::maxNumberOfClients, runtime::get), DisabledNamespaces.create(sqliteDataSource));
registerManagementResource();
// Finally, register the health check, and endpoints associated with the clients.
TimeLockResource resource = TimeLockResource.create(namespaces);
healthCheck = paxosResources.leadershipComponents().healthCheck(namespaces::getActiveClients);
registrar.accept(resource);
Function<String, LockService> lockServiceGetter = namespace -> namespaces.get(namespace).getLockService();
Function<String, AsyncTimelockService> asyncTimelockServiceGetter = namespace -> namespaces.get(namespace).getTimelockService();
Function<String, BackupTimeLockServiceView> backupTimeLockServiceViewGetter = namespace -> namespaces.getForRestore(namespace);
AuthHeaderValidator authHeaderValidator = getAuthHeaderValidator();
RedirectRetryTargeter redirectRetryTargeter = redirectRetryTargeter();
if (undertowRegistrar.isPresent()) {
Consumer<UndertowService> presentUndertowRegistrar = undertowRegistrar.get();
registerCorruptionHandlerWrappedService(presentUndertowRegistrar, ConjureTimelockResource.undertow(redirectRetryTargeter, asyncTimelockServiceGetter));
registerCorruptionHandlerWrappedService(presentUndertowRegistrar, ConjureLockWatchingResource.undertow(redirectRetryTargeter, asyncTimelockServiceGetter));
registerCorruptionHandlerWrappedService(presentUndertowRegistrar, ConjureLockV1Resource.undertow(redirectRetryTargeter, lockServiceGetter));
registerCorruptionHandlerWrappedService(presentUndertowRegistrar, TimeLockPaxosHistoryProviderResource.undertow(corruptionComponents.localHistoryLoader()));
registerCorruptionHandlerWrappedService(presentUndertowRegistrar, MultiClientConjureTimelockResource.undertow(redirectRetryTargeter, asyncTimelockServiceGetter));
registerCorruptionHandlerWrappedService(presentUndertowRegistrar, AtlasBackupResource.undertow(authHeaderValidator, redirectRetryTargeter, asyncTimelockServiceGetter));
registerCorruptionHandlerWrappedService(presentUndertowRegistrar, AtlasRestoreResource.undertow(authHeaderValidator, redirectRetryTargeter, backupTimeLockServiceViewGetter));
registerCorruptionHandlerWrappedService(presentUndertowRegistrar, DisabledNamespacesUpdaterResource.undertow(authHeaderValidator, redirectRetryTargeter, namespaces));
} else {
registrar.accept(ConjureTimelockResource.jersey(redirectRetryTargeter, asyncTimelockServiceGetter));
registrar.accept(ConjureLockWatchingResource.jersey(redirectRetryTargeter, asyncTimelockServiceGetter));
registrar.accept(ConjureLockV1Resource.jersey(redirectRetryTargeter, lockServiceGetter));
registrar.accept(TimeLockPaxosHistoryProviderResource.jersey(corruptionComponents.localHistoryLoader()));
registrar.accept(MultiClientConjureTimelockResource.jersey(redirectRetryTargeter, asyncTimelockServiceGetter));
registrar.accept(AtlasBackupResource.jersey(authHeaderValidator, redirectRetryTargeter, asyncTimelockServiceGetter));
registrar.accept(AtlasRestoreResource.jersey(authHeaderValidator, redirectRetryTargeter, backupTimeLockServiceViewGetter));
registrar.accept(DisabledNamespacesUpdaterResource.jersey(authHeaderValidator, redirectRetryTargeter, namespaces));
}
}
use of com.palantir.atlasdb.timelock.BackupTimeLockServiceView in project atlasdb by palantir.
the class AtlasBackupResource method prepareBackup.
private InProgressBackupToken prepareBackup(Namespace namespace) {
BackupTimeLockServiceView timelock = timelock(namespace);
LockImmutableTimestampResponse response = timelock.lockImmutableTimestamp(IdentifiedTimeLockRequest.create());
long timestamp = timelock.getFreshTimestamp();
return InProgressBackupToken.builder().namespace(namespace).lockToken(response.getLock()).immutableTimestamp(response.getImmutableTimestamp()).backupStartTimestamp(timestamp).build();
}
use of com.palantir.atlasdb.timelock.BackupTimeLockServiceView 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