use of com.palantir.atlasdb.timelock.TimelockNamespaces 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.TimelockNamespaces 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);
}
Aggregations