Search in sources :

Example 1 with LockRpcClient

use of com.palantir.lock.LockRpcClient in project atlasdb by palantir.

the class AtlasDbDialogueServiceProvider method getLockRpcClient.

public LockRpcClient getLockRpcClient() {
    ConjureLockV1ServiceBlocking shortTimeoutDialogueService = dialogueClientFactory.get(ConjureLockV1ServiceBlocking.class, TIMELOCK_SHORT_TIMEOUT);
    ConjureLockV1ServiceBlocking longTimeoutDialogueService = dialogueClientFactory.get(ConjureLockV1ServiceBlocking.class, TIMELOCK_LONG_TIMEOUT);
    ShortAndLongTimeoutServices<LockRpcClient> legacyRpcClients = ImmutableShortAndLongTimeoutServices.<LockRpcClient>builder().shortTimeout(createDialogueProxyWithShortTimeout(LockRpcClient.class)).longTimeout(createDialogueProxyWithLongTimeout(LockRpcClient.class)).build();
    return new TimeoutSensitiveLockRpcClient(ImmutableShortAndLongTimeoutServices.<ConjureLockV1ServiceBlocking>builder().shortTimeout(shortTimeoutDialogueService).longTimeout(longTimeoutDialogueService).build().map(proxy -> wrapInProxy(ConjureLockV1ServiceBlocking.class, proxy)).map(service -> AtlasDbMetrics.instrumentWithTaggedMetrics(taggedMetricRegistry, ConjureLockV1ServiceBlocking.class, service)).zipWith(legacyRpcClients, DialogueComposingLockRpcClient::new));
}
Also used : ImmutableRemoteServiceConfiguration(com.palantir.atlasdb.http.v2.ImmutableRemoteServiceConfiguration) RemoteServiceConfiguration(com.palantir.atlasdb.http.v2.RemoteServiceConfiguration) AtlasDbMetrics(com.palantir.atlasdb.util.AtlasDbMetrics) AtlasDbHttpProtocolVersion(com.palantir.atlasdb.http.AtlasDbHttpProtocolVersion) ShortAndLongTimeoutServices(com.palantir.atlasdb.factory.timelock.ShortAndLongTimeoutServices) ConjureTimelockService(com.palantir.atlasdb.timelock.api.ConjureTimelockService) TimestampManagementRpcClient(com.palantir.timestamp.TimestampManagementRpcClient) TimeoutSensitiveLockRpcClient(com.palantir.atlasdb.factory.timelock.TimeoutSensitiveLockRpcClient) ClientConfiguration(com.palantir.conjure.java.client.config.ClientConfiguration) DialogueAdaptingTimeLockManagementService(com.palantir.atlasdb.backup.DialogueAdaptingTimeLockManagementService) ConjureTimelockServiceBlocking(com.palantir.atlasdb.timelock.api.ConjureTimelockServiceBlocking) TimeoutSensitiveConjureTimelockService(com.palantir.atlasdb.factory.timelock.TimeoutSensitiveConjureTimelockService) TimeLockManagementService(com.palantir.atlasdb.timelock.api.management.TimeLockManagementService) SafeArg(com.palantir.logsafe.SafeArg) NodeSelectionStrategy(com.palantir.conjure.java.client.config.NodeSelectionStrategy) ConjureLockWatchingServiceBlocking(com.palantir.atlasdb.timelock.lock.watch.ConjureLockWatchingServiceBlocking) UserAgent(com.palantir.conjure.java.api.config.service.UserAgent) Map(java.util.Map) AuxiliaryRemotingParameters(com.palantir.atlasdb.config.AuxiliaryRemotingParameters) TimelockRpcClient(com.palantir.lock.v2.TimelockRpcClient) DialogueAdaptingConjureTimelockService(com.palantir.lock.client.DialogueAdaptingConjureTimelockService) Refreshable(com.palantir.refreshable.Refreshable) MultiClientConjureTimelockServiceBlocking(com.palantir.atlasdb.timelock.api.MultiClientConjureTimelockServiceBlocking) ImmutableMap(com.google.common.collect.ImmutableMap) RetryOnSocketTimeoutExceptionProxy(com.palantir.atlasdb.http.v2.RetryOnSocketTimeoutExceptionProxy) ReloadingFactory(com.palantir.dialogue.clients.DialogueClients.ReloadingFactory) AtlasDbHttpClients(com.palantir.atlasdb.http.AtlasDbHttpClients) DialogueComposingLockRpcClient(com.palantir.lock.client.DialogueComposingLockRpcClient) Set(java.util.Set) FastFailoverProxy(com.palantir.atlasdb.http.v2.FastFailoverProxy) UnknownRemoteDebuggingProxy(com.palantir.atlasdb.http.v2.UnknownRemoteDebuggingProxy) Channel(com.palantir.dialogue.Channel) ConjureTimelockServiceBlockingMetrics(com.palantir.lock.client.ConjureTimelockServiceBlockingMetrics) TaggedMetricRegistry(com.palantir.tritium.metrics.registry.TaggedMetricRegistry) ServerListConfig(com.palantir.atlasdb.config.ServerListConfig) ConjureLockV1ServiceBlocking(com.palantir.lock.ConjureLockV1ServiceBlocking) LockRpcClient(com.palantir.lock.LockRpcClient) AtlasDbRemotingConstants(com.palantir.atlasdb.http.AtlasDbRemotingConstants) ImmutableShortAndLongTimeoutServices(com.palantir.atlasdb.factory.timelock.ImmutableShortAndLongTimeoutServices) DialogueClients(com.palantir.dialogue.clients.DialogueClients) TimeLockManagementServiceBlocking(com.palantir.atlasdb.timelock.api.management.TimeLockManagementServiceBlocking) DialogueClientOptions(com.palantir.atlasdb.http.v2.DialogueClientOptions) TimeoutSensitiveLockRpcClient(com.palantir.atlasdb.factory.timelock.TimeoutSensitiveLockRpcClient) TimeoutSensitiveLockRpcClient(com.palantir.atlasdb.factory.timelock.TimeoutSensitiveLockRpcClient) DialogueComposingLockRpcClient(com.palantir.lock.client.DialogueComposingLockRpcClient) LockRpcClient(com.palantir.lock.LockRpcClient) ConjureLockV1ServiceBlocking(com.palantir.lock.ConjureLockV1ServiceBlocking)

Example 2 with LockRpcClient

use of com.palantir.lock.LockRpcClient 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

AuxiliaryRemotingParameters (com.palantir.atlasdb.config.AuxiliaryRemotingParameters)2 ServerListConfig (com.palantir.atlasdb.config.ServerListConfig)2 AtlasDbHttpClients (com.palantir.atlasdb.http.AtlasDbHttpClients)2 ConjureTimelockService (com.palantir.atlasdb.timelock.api.ConjureTimelockService)2 AtlasDbMetrics (com.palantir.atlasdb.util.AtlasDbMetrics)2 UserAgent (com.palantir.conjure.java.api.config.service.UserAgent)2 ReloadingFactory (com.palantir.dialogue.clients.DialogueClients.ReloadingFactory)2 LockRpcClient (com.palantir.lock.LockRpcClient)2 Suppliers (com.google.common.base.Suppliers)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Iterables (com.google.common.collect.Iterables)1 Uninterruptibles (com.google.common.util.concurrent.Uninterruptibles)1 DialogueAdaptingTimeLockManagementService (com.palantir.atlasdb.backup.DialogueAdaptingTimeLockManagementService)1 AtlasDbConfig (com.palantir.atlasdb.config.AtlasDbConfig)1 AtlasDbRuntimeConfig (com.palantir.atlasdb.config.AtlasDbRuntimeConfig)1 ImmutableServerListConfig (com.palantir.atlasdb.config.ImmutableServerListConfig)1 LeaderConfig (com.palantir.atlasdb.config.LeaderConfig)1 RemotingClientConfigs (com.palantir.atlasdb.config.RemotingClientConfigs)1 ServerListConfigs (com.palantir.atlasdb.config.ServerListConfigs)1 TimeLockClientConfig (com.palantir.atlasdb.config.TimeLockClientConfig)1