use of com.palantir.atlasdb.timelock.api.ConjureTimelockService in project atlasdb by palantir.
the class AtlasDbDialogueServiceProviderTest method canHaveTwoInstancesOfServicesTalkingToTheSameTimeLockServer.
@Test
public void canHaveTwoInstancesOfServicesTalkingToTheSameTimeLockServer() {
ConjureTimelockService sameTimelockService = provider.getConjureTimelockService();
assertTimestampRange(conjureTimelockService, FIRST_LOWER, FIRST_UPPER);
assertTimestampRange(sameTimelockService, FIRST_LOWER, FIRST_UPPER);
}
use of com.palantir.atlasdb.timelock.api.ConjureTimelockService 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.timelock.api.ConjureTimelockService in project atlasdb by palantir.
the class AtlasDbDialogueServiceProvider method getConjureTimelockService.
public ConjureTimelockService getConjureTimelockService() {
ConjureTimelockServiceBlocking longTimeoutService = dialogueClientFactory.get(ConjureTimelockServiceBlocking.class, TIMELOCK_LONG_TIMEOUT);
ConjureTimelockServiceBlocking shortTimeoutService = dialogueClientFactory.get(ConjureTimelockServiceBlocking.class, TIMELOCK_SHORT_TIMEOUT);
ConjureTimelockServiceBlockingMetrics conjureTimelockServiceBlockingMetrics = ConjureTimelockServiceBlockingMetrics.of(taggedMetricRegistry);
ShortAndLongTimeoutServices<ConjureTimelockService> shortAndLongTimeoutServices = ImmutableShortAndLongTimeoutServices.<ConjureTimelockServiceBlocking>builder().longTimeout(longTimeoutService).shortTimeout(shortTimeoutService).build().map(proxy -> wrapInProxy(ConjureTimelockServiceBlocking.class, proxy)).map(service -> AtlasDbMetrics.instrumentWithTaggedMetrics(taggedMetricRegistry, ConjureTimelockServiceBlocking.class, service)).map(instrumentedService -> new DialogueAdaptingConjureTimelockService(instrumentedService, conjureTimelockServiceBlockingMetrics));
return new TimeoutSensitiveConjureTimelockService(shortAndLongTimeoutServices);
}
use of com.palantir.atlasdb.timelock.api.ConjureTimelockService 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();
}
use of com.palantir.atlasdb.timelock.api.ConjureTimelockService in project atlasdb by palantir.
the class AtlasDbDialogueServiceProviderTest method canTalkToTwoDifferentTimeLockServers.
@Test
public void canTalkToTwoDifferentTimeLockServers() {
ConjureTimelockService secondTimelockService = getAtlasDbDialogueServiceProvider(secondServerPort).getConjureTimelockService();
assertTimestampRange(conjureTimelockService, FIRST_LOWER, FIRST_UPPER);
assertTimestampRange(secondTimelockService, SECOND_LOWER, SECOND_UPPER);
}
Aggregations