Search in sources :

Example 1 with TimeLockClient

use of com.palantir.lock.client.TimeLockClient in project atlasdb by palantir.

the class TransactionManagers method createLockAndTimestampServicesForCli.

/**
 * This method should not be used directly. It remains here to support the AtlasDB-Dagger module and the CLIs, but
 * may be removed at some point in the future.
 *
 * @deprecated Not intended for public use outside of the AtlasDB CLIs
 */
@Deprecated
public static LockAndTimestampServices createLockAndTimestampServicesForCli(MetricsManager metricsManager, AtlasDbConfig config, Refreshable<AtlasDbRuntimeConfig> runtimeConfigSupplier, Consumer<Object> env, Supplier<LockService> lock, Supplier<ManagedTimestampService> time, TimestampStoreInvalidator invalidator, String userAgent) {
    LockAndTimestampServices lockAndTimestampServices = DefaultLockAndTimestampServiceFactory.createRawInstrumentedServices(metricsManager, config, runtimeConfigSupplier, env, lock, time, invalidator, UserAgents.tryParse(userAgent), Optional.empty(), newMinimalDialogueFactory(), Optional.empty(), Optional.empty(), ImmutableSet.of());
    TimeLockClient timeLockClient = TimeLockClient.withSynchronousUnlocker(lockAndTimestampServices.timelock());
    return ImmutableLockAndTimestampServices.builder().from(lockAndTimestampServices).timelock(timeLockClient).lock(LockRefreshingLockService.create(lockAndTimestampServices.lock())).addResources(timeLockClient::close).build();
}
Also used : TimeLockClient(com.palantir.lock.client.TimeLockClient)

Example 2 with TimeLockClient

use of com.palantir.lock.client.TimeLockClient in project atlasdb by palantir.

the class DefaultLockAndTimestampServiceFactory method withRefreshingLockService.

private static LockAndTimestampServices withRefreshingLockService(LockAndTimestampServices lockAndTimestampServices) {
    TimeLockClient timeLockClient = TimeLockClient.createDefault(lockAndTimestampServices.timelock());
    ProfilingTimelockService profilingService = ProfilingTimelockService.create(timeLockClient);
    return ImmutableLockAndTimestampServices.builder().from(lockAndTimestampServices).timestamp(new TimelockTimestampServiceAdapter(profilingService)).timelock(profilingService).lock(LockRefreshingLockService.create(lockAndTimestampServices.lock())).addResources(timeLockClient::close).addResources(profilingService::close).build();
}
Also used : TimeLockClient(com.palantir.lock.client.TimeLockClient) TimelockTimestampServiceAdapter(com.palantir.atlasdb.transaction.impl.TimelockTimestampServiceAdapter) ProfilingTimelockService(com.palantir.lock.client.ProfilingTimelockService)

Example 3 with TimeLockClient

use of com.palantir.lock.client.TimeLockClient in project atlasdb by palantir.

the class DefaultLockAndTimestampServiceFactory method getLockAndTimestampServices.

private static LockAndTimestampServices getLockAndTimestampServices(MetricsManager metricsManager, Refreshable<ServerListConfig> timelockServerListConfig, UserAgent userAgent, String timelockNamespace, Optional<LockDiagnosticComponents> lockDiagnosticComponents, ReloadingFactory reloadingFactory, Optional<TimeLockFeedbackBackgroundTask> timeLockFeedbackBackgroundTask, Optional<TimeLockRequestBatcherProviders> timelockRequestBatcherProviders, Set<Schema> schemas, LockWatchCachingConfig cachingConfig) {
    AtlasDbDialogueServiceProvider serviceProvider = AtlasDbDialogueServiceProvider.create(timelockServerListConfig, reloadingFactory, userAgent, metricsManager.getTaggedRegistry());
    LockRpcClient lockRpcClient = serviceProvider.getLockRpcClient();
    LockService lockService = AtlasDbMetrics.instrumentTimed(metricsManager.getRegistry(), LockService.class, RemoteLockServiceAdapter.create(lockRpcClient, timelockNamespace));
    ConjureTimelockService conjureTimelockService = serviceProvider.getConjureTimelockService();
    TimelockRpcClient timelockClient = serviceProvider.getTimelockRpcClient();
    // TODO(fdesouza): Remove this once PDS-95791 is resolved.
    ConjureTimelockService withDiagnosticsConjureTimelockService = lockDiagnosticComponents.<ConjureTimelockService>map(components -> new LockDiagnosticConjureTimelockService(conjureTimelockService, components.clientLockDiagnosticCollector(), components.localLockTracker())).orElse(conjureTimelockService);
    NamespacedTimelockRpcClient namespacedTimelockRpcClient = new DefaultNamespacedTimelockRpcClient(timelockClient, timelockNamespace);
    LeaderElectionReportingTimelockService leaderElectionReportingTimelockService = LeaderElectionReportingTimelockService.create(withDiagnosticsConjureTimelockService, timelockNamespace);
    timeLockFeedbackBackgroundTask.ifPresent(task -> task.registerLeaderElectionStatistics(leaderElectionReportingTimelockService));
    NamespacedConjureTimelockService namespacedConjureTimelockService = TimestampCorroboratingTimelockService.create(timelockNamespace, metricsManager.getTaggedRegistry(), leaderElectionReportingTimelockService);
    NamespacedConjureLockWatchingService lockWatchingService = new NamespacedConjureLockWatchingService(serviceProvider.getConjureLockWatchingService(), timelockNamespace);
    Supplier<InternalMultiClientConjureTimelockService> multiClientTimelockServiceSupplier = getMultiClientTimelockServiceSupplier(serviceProvider);
    Supplier<Optional<RequestBatchersFactory.MultiClientRequestBatchers>> requestBatcherProvider = () -> timelockRequestBatcherProviders.map(batcherProviders -> ImmutableMultiClientRequestBatchers.of(batcherProviders.commitTimestamps().getBatcher(multiClientTimelockServiceSupplier), batcherProviders.startTransactions().getBatcher(multiClientTimelockServiceSupplier)));
    TimeLockHelperServices timeLockHelperServices = TimeLockHelperServices.create(timelockNamespace, metricsManager, schemas, lockWatchingService, cachingConfig, requestBatcherProvider);
    LockWatchManagerInternal lockWatchManager = timeLockHelperServices.lockWatchManager();
    RemoteTimelockServiceAdapter remoteTimelockServiceAdapter = RemoteTimelockServiceAdapter.create(namespacedTimelockRpcClient, namespacedConjureTimelockService, getLeaderTimeGetter(timelockNamespace, timelockRequestBatcherProviders, namespacedConjureTimelockService, multiClientTimelockServiceSupplier), timeLockHelperServices.requestBatchersFactory());
    TimestampManagementService timestampManagementService = new RemoteTimestampManagementAdapter(serviceProvider.getTimestampManagementRpcClient(), timelockNamespace);
    return ImmutableLockAndTimestampServices.builder().lock(lockService).timestamp(new TimelockTimestampServiceAdapter(remoteTimelockServiceAdapter)).timestampManagement(timestampManagementService).timelock(remoteTimelockServiceAdapter).lockWatcher(lockWatchManager).addResources(remoteTimelockServiceAdapter::close).addResources(lockWatchManager::close).build();
}
Also used : ServerListConfigs(com.palantir.atlasdb.config.ServerListConfigs) SafeIllegalStateException(com.palantir.logsafe.exceptions.SafeIllegalStateException) AuthenticatedInternalMultiClientConjureTimelockService(com.palantir.lock.client.AuthenticatedInternalMultiClientConjureTimelockService) LeaderConfig(com.palantir.atlasdb.config.LeaderConfig) LockRefreshingLockService(com.palantir.lock.client.LockRefreshingLockService) ClientErrorException(javax.ws.rs.ClientErrorException) NamespacedConjureTimelockService(com.palantir.lock.client.NamespacedConjureTimelockService) TimelockTimestampServiceAdapter(com.palantir.atlasdb.transaction.impl.TimelockTimestampServiceAdapter) MetricsManager(com.palantir.atlasdb.util.MetricsManager) NamespacedTimelockRpcClient(com.palantir.lock.v2.NamespacedTimelockRpcClient) TimeLockRequestBatcherProviders(com.palantir.atlasdb.config.TimeLockRequestBatcherProviders) UserAgent(com.palantir.conjure.java.api.config.service.UserAgent) Duration(java.time.Duration) TimestampService(com.palantir.timestamp.TimestampService) TimelockRpcClient(com.palantir.lock.v2.TimelockRpcClient) Refreshable(com.palantir.refreshable.Refreshable) TimestampManagementService(com.palantir.timestamp.TimestampManagementService) LockDiagnosticComponents(com.palantir.atlasdb.debug.LockDiagnosticComponents) ReloadingFactory(com.palantir.dialogue.clients.DialogueClients.ReloadingFactory) AtlasDbHttpClients(com.palantir.atlasdb.http.AtlasDbHttpClients) TimeLockFeedbackBackgroundTask(com.palantir.lock.client.metrics.TimeLockFeedbackBackgroundTask) SafeIllegalArgumentException(com.palantir.logsafe.exceptions.SafeIllegalArgumentException) Set(java.util.Set) ServerListConfig(com.palantir.atlasdb.config.ServerListConfig) ReferenceTrackingWrapper(com.palantir.lock.client.ReferenceTrackingWrapper) LockRpcClient(com.palantir.lock.LockRpcClient) LeaderTimeCoalescingBatcher(com.palantir.lock.client.LeaderTimeCoalescingBatcher) LockWatchCachingConfig(com.palantir.atlasdb.keyvalue.api.LockWatchCachingConfig) NamespacedConjureLockWatchingService(com.palantir.lock.client.NamespacedConjureLockWatchingService) ImmutableMultiClientRequestBatchers(com.palantir.lock.client.ImmutableMultiClientRequestBatchers) TimestampRange(com.palantir.timestamp.TimestampRange) InternalMultiClientConjureTimelockService(com.palantir.lock.client.InternalMultiClientConjureTimelockService) Optional(java.util.Optional) TimeLockClientConfig(com.palantir.atlasdb.config.TimeLockClientConfig) InstrumentedTimelockService(com.palantir.atlasdb.transaction.impl.InstrumentedTimelockService) LockDiagnosticConjureTimelockService(com.palantir.atlasdb.debug.LockDiagnosticConjureTimelockService) RemotingClientConfigs(com.palantir.atlasdb.config.RemotingClientConfigs) ImmutableServerListConfig(com.palantir.atlasdb.config.ImmutableServerListConfig) LeadershipCoordinator(com.palantir.leader.proxy.LeadershipCoordinator) Iterables(com.google.common.collect.Iterables) SafeLoggerFactory(com.palantir.logsafe.logger.SafeLoggerFactory) ProfilingTimelockService(com.palantir.lock.client.ProfilingTimelockService) AtlasDbMetrics(com.palantir.atlasdb.util.AtlasDbMetrics) ConjureTimelockService(com.palantir.atlasdb.timelock.api.ConjureTimelockService) RequestBatchersFactory(com.palantir.lock.client.RequestBatchersFactory) RemoteTimestampManagementAdapter(com.palantir.timestamp.RemoteTimestampManagementAdapter) TimestampStoreInvalidator(com.palantir.timestamp.TimestampStoreInvalidator) CompletableFuture(java.util.concurrent.CompletableFuture) Supplier(java.util.function.Supplier) LeaderTimeGetter(com.palantir.lock.client.LeaderTimeGetter) SafeLogger(com.palantir.logsafe.logger.SafeLogger) RemoteTimelockServiceAdapter(com.palantir.lock.client.RemoteTimelockServiceAdapter) LegacyTimelockService(com.palantir.lock.impl.LegacyTimelockService) AuxiliaryRemotingParameters(com.palantir.atlasdb.config.AuxiliaryRemotingParameters) Suppliers(com.google.common.base.Suppliers) RemoteLockServiceAdapter(com.palantir.lock.client.RemoteLockServiceAdapter) OptionalResolver(com.palantir.util.OptionalResolver) TimestampCorroboratingTimelockService(com.palantir.lock.client.TimestampCorroboratingTimelockService) AwaitingLeadershipProxy(com.palantir.leader.proxy.AwaitingLeadershipProxy) NamespaceAgnosticLockRpcClient(com.palantir.lock.NamespaceAgnosticLockRpcClient) UnknownRemoteException(com.palantir.conjure.java.api.errors.UnknownRemoteException) Uninterruptibles(com.google.common.util.concurrent.Uninterruptibles) LockWatchManagerInternal(com.palantir.atlasdb.keyvalue.api.watch.LockWatchManagerInternal) TimelockService(com.palantir.lock.v2.TimelockService) Consumer(java.util.function.Consumer) AtlasDbRuntimeConfig(com.palantir.atlasdb.config.AtlasDbRuntimeConfig) TimeLockMigrator(com.palantir.atlasdb.factory.startup.TimeLockMigrator) LockService(com.palantir.lock.LockService) NamespacedCoalescingLeaderTimeGetter(com.palantir.lock.client.NamespacedCoalescingLeaderTimeGetter) TimeLockClient(com.palantir.lock.client.TimeLockClient) ManagedTimestampService(com.palantir.timestamp.ManagedTimestampService) DefaultNamespacedTimelockRpcClient(com.palantir.lock.v2.DefaultNamespacedTimelockRpcClient) LocalPaxosServices(com.palantir.atlasdb.factory.Leaders.LocalPaxosServices) LegacyLeaderTimeGetter(com.palantir.lock.client.LegacyLeaderTimeGetter) Schema(com.palantir.atlasdb.table.description.Schema) PingableLeader(com.palantir.leader.PingableLeader) LeaderElectionReportingTimelockService(com.palantir.lock.client.LeaderElectionReportingTimelockService) AtlasDbConfig(com.palantir.atlasdb.config.AtlasDbConfig) TimelockTimestampServiceAdapter(com.palantir.atlasdb.transaction.impl.TimelockTimestampServiceAdapter) AuthenticatedInternalMultiClientConjureTimelockService(com.palantir.lock.client.AuthenticatedInternalMultiClientConjureTimelockService) InternalMultiClientConjureTimelockService(com.palantir.lock.client.InternalMultiClientConjureTimelockService) RemoteTimestampManagementAdapter(com.palantir.timestamp.RemoteTimestampManagementAdapter) LockRefreshingLockService(com.palantir.lock.client.LockRefreshingLockService) LockService(com.palantir.lock.LockService) Optional(java.util.Optional) LockRpcClient(com.palantir.lock.LockRpcClient) NamespaceAgnosticLockRpcClient(com.palantir.lock.NamespaceAgnosticLockRpcClient) NamespacedTimelockRpcClient(com.palantir.lock.v2.NamespacedTimelockRpcClient) TimelockRpcClient(com.palantir.lock.v2.TimelockRpcClient) DefaultNamespacedTimelockRpcClient(com.palantir.lock.v2.DefaultNamespacedTimelockRpcClient) LockWatchManagerInternal(com.palantir.atlasdb.keyvalue.api.watch.LockWatchManagerInternal) RemoteTimelockServiceAdapter(com.palantir.lock.client.RemoteTimelockServiceAdapter) RequestBatchersFactory(com.palantir.lock.client.RequestBatchersFactory) NamespacedConjureLockWatchingService(com.palantir.lock.client.NamespacedConjureLockWatchingService) NamespacedTimelockRpcClient(com.palantir.lock.v2.NamespacedTimelockRpcClient) DefaultNamespacedTimelockRpcClient(com.palantir.lock.v2.DefaultNamespacedTimelockRpcClient) LockDiagnosticConjureTimelockService(com.palantir.atlasdb.debug.LockDiagnosticConjureTimelockService) NamespacedConjureTimelockService(com.palantir.lock.client.NamespacedConjureTimelockService) TimestampManagementService(com.palantir.timestamp.TimestampManagementService) AuthenticatedInternalMultiClientConjureTimelockService(com.palantir.lock.client.AuthenticatedInternalMultiClientConjureTimelockService) NamespacedConjureTimelockService(com.palantir.lock.client.NamespacedConjureTimelockService) InternalMultiClientConjureTimelockService(com.palantir.lock.client.InternalMultiClientConjureTimelockService) LockDiagnosticConjureTimelockService(com.palantir.atlasdb.debug.LockDiagnosticConjureTimelockService) ConjureTimelockService(com.palantir.atlasdb.timelock.api.ConjureTimelockService) DefaultNamespacedTimelockRpcClient(com.palantir.lock.v2.DefaultNamespacedTimelockRpcClient) LeaderElectionReportingTimelockService(com.palantir.lock.client.LeaderElectionReportingTimelockService)

Aggregations

TimeLockClient (com.palantir.lock.client.TimeLockClient)3 TimelockTimestampServiceAdapter (com.palantir.atlasdb.transaction.impl.TimelockTimestampServiceAdapter)2 ProfilingTimelockService (com.palantir.lock.client.ProfilingTimelockService)2 Suppliers (com.google.common.base.Suppliers)1 Iterables (com.google.common.collect.Iterables)1 Uninterruptibles (com.google.common.util.concurrent.Uninterruptibles)1 AtlasDbConfig (com.palantir.atlasdb.config.AtlasDbConfig)1 AtlasDbRuntimeConfig (com.palantir.atlasdb.config.AtlasDbRuntimeConfig)1 AuxiliaryRemotingParameters (com.palantir.atlasdb.config.AuxiliaryRemotingParameters)1 ImmutableServerListConfig (com.palantir.atlasdb.config.ImmutableServerListConfig)1 LeaderConfig (com.palantir.atlasdb.config.LeaderConfig)1 RemotingClientConfigs (com.palantir.atlasdb.config.RemotingClientConfigs)1 ServerListConfig (com.palantir.atlasdb.config.ServerListConfig)1 ServerListConfigs (com.palantir.atlasdb.config.ServerListConfigs)1 TimeLockClientConfig (com.palantir.atlasdb.config.TimeLockClientConfig)1 TimeLockRequestBatcherProviders (com.palantir.atlasdb.config.TimeLockRequestBatcherProviders)1 LockDiagnosticComponents (com.palantir.atlasdb.debug.LockDiagnosticComponents)1 LockDiagnosticConjureTimelockService (com.palantir.atlasdb.debug.LockDiagnosticConjureTimelockService)1 LocalPaxosServices (com.palantir.atlasdb.factory.Leaders.LocalPaxosServices)1 TimeLockMigrator (com.palantir.atlasdb.factory.startup.TimeLockMigrator)1