use of com.palantir.atlasdb.http.RedirectRetryTargeter in project atlasdb by palantir.
the class InMemoryTimelockServices method createHelperServices.
private void createHelperServices(MetricsManager metricsManager) {
helperServices = TimeLockHelperServices.create(client, metricsManager, ImmutableSet.of(), delegate.getTimelockService(), LockWatchCachingConfig.builder().build(), Optional::empty);
RedirectRetryTargeter redirectRetryTargeter = timeLockAgent.redirectRetryTargeter();
ConjureTimelockService conjureTimelockService = ConjureTimelockResource.jersey(redirectRetryTargeter, _unused -> delegate.getTimelockService());
namespacedConjureTimelockService = new NamespacedConjureTimelockServiceImpl(conjureTimelockService, client);
lockLeaseService = LockLeaseService.create(namespacedConjureTimelockService, new LegacyLeaderTimeGetter(namespacedConjureTimelockService));
}
use of com.palantir.atlasdb.http.RedirectRetryTargeter 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.http.RedirectRetryTargeter in project atlasdb by palantir.
the class TimeLockManagementResourceTest method setup.
@Before
public void setup() throws MalformedURLException {
URL testUrl = new URL("http", "host", "file");
RedirectRetryTargeter redirectRetryTargeter = RedirectRetryTargeter.create(testUrl, ImmutableList.of(testUrl));
Path rootFolderPath = tempFolder.getRoot().toPath();
PersistentNamespaceContext persistentNamespaceContext = PersistentNamespaceContexts.timestampBoundPaxos(rootFolderPath, SqliteConnections.getDefaultConfiguredPooledDataSource(rootFolderPath));
DisabledNamespaces disabledNamespaces = mock(DisabledNamespaces.class);
TimelockNamespaces namespaces = new TimelockNamespaces(metricsManager, serviceFactory, maxNumberOfClientsSupplier, disabledNamespaces);
when(authHeaderValidator.suppliedHeaderMatchesConfig(AUTH_HEADER)).thenReturn(true);
when(authHeaderValidator.suppliedHeaderMatchesConfig(WRONG_AUTH_HEADER)).thenReturn(false);
timeLockManagementResource = TimeLockManagementResource.create(persistentNamespaceContext, namespaces, allNodesDisabledNamespacesUpdater, authHeaderValidator, redirectRetryTargeter, new ServiceLifecycleController(serviceStopper, PTExecutors.newSingleThreadScheduledExecutor()));
createDirectoryForLeaderForEachClientUseCase(NAMESPACE_1);
createDirectoryInRootDataDirectory(NAMESPACE_2);
}
use of com.palantir.atlasdb.http.RedirectRetryTargeter 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