use of com.palantir.lock.client.LeaderElectionReportingTimelockService 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();
}
Aggregations