TransactionManagers { private static LockAndTimestampServices getLockAndTimestampServices( MetricsManager metricsManager, Refreshable<ServerListConfig> timelockServerListConfig, UserAgent userAgent, String timelockNamespace, Optional<LockDiagnosticComponents> lockDiagnosticComponents, DialogueClients.ReloadingFactory reloadingFactory) { 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(); ConjureTimelockService withDiagnosticsConjureTimelockService = lockDiagnosticComponents .<ConjureTimelockService>map(components -> new LockDiagnosticConjureTimelockService( conjureTimelockService, components.clientLockDiagnosticCollector(), components.localLockTracker())) .orElse(conjureTimelockService); NamespacedTimelockRpcClient namespacedTimelockRpcClient = new NamespacedTimelockRpcClient(timelockClient, timelockNamespace); NamespacedConjureTimelockService namespacedConjureTimelockService = new NamespacedConjureTimelockService(withDiagnosticsConjureTimelockService, timelockNamespace); LockWatchEventCache lockWatchEventCache = LockWatchEventCacheImpl.create(metricsManager); NamespacedConjureLockWatchingService lockWatchingService = new NamespacedConjureLockWatchingService( serviceProvider.getConjureLockWatchingService(), timelockNamespace); LockWatchManagerImpl lockWatchManager = new LockWatchManagerImpl(lockWatchEventCache, lockWatchingService); RemoteTimelockServiceAdapter remoteTimelockServiceAdapter = RemoteTimelockServiceAdapter .create(namespacedTimelockRpcClient, namespacedConjureTimelockService, lockWatchEventCache); TimestampManagementService timestampManagementService = new RemoteTimestampManagementAdapter( serviceProvider.getTimestampManagementRpcClient(), timelockNamespace); return ImmutableLockAndTimestampServices.builder() .lock(lockService) .timestamp(new TimelockTimestampServiceAdapter(remoteTimelockServiceAdapter)) .timestampManagement(timestampManagementService) .timelock(remoteTimelockServiceAdapter) .lockWatcher(lockWatchManager) .eventCache(lockWatchEventCache) .addResources(remoteTimelockServiceAdapter::close) .addResources(lockWatchManager::close) .build(); }  static ImmutableTransactionManagers.ConfigBuildStage builder(); static TransactionManager createInMemory(Schema schema); static TransactionManager createInMemory(Set<Schema> schemas); @JsonIgnore @Value.Derived TransactionManager serializable(); @Deprecated static LockAndTimestampServices createLockAndTimestampServicesForCli(
            MetricsManager metricsManager,
            AtlasDbConfig config,
            Refreshable<AtlasDbRuntimeConfig> runtimeConfigSupplier,
            Consumer<Object> env,
            Supplier<LockService> lock,
            Supplier<ManagedTimestampService> time,
            TimestampStoreInvalidator invalidator,
            String userAgent); static final LockClient LOCK_CLIENT; }
@Test public void remoteCallsStillMadeIfPingableLeader404s() throws IOException { setUpForRemoteServices(); setUpLeaderBlockInConfig(); TransactionManagers.LockAndTimestampServices lockAndTimestamp = getLockAndTimestampServices(); availableServer.verify(getRequestedFor(urlMatching(LEADER_UUID_PATH))); lockAndTimestamp.timelock().getFreshTimestamp(); lockAndTimestamp.lock().currentTimeMillis(); availableServer.verify(postRequestedFor(urlMatching(TIMESTAMP_PATH)) .withHeader(USER_AGENT_HEADER, WireMock.containing(EXPECTED_USER_AGENT_STRING))); availableServer.verify(postRequestedFor(urlMatching(LOCK_PATH)) .withHeader(USER_AGENT_HEADER, WireMock.containing(EXPECTED_USER_AGENT_STRING))); }
@Test public void remoteCallsElidedIfTalkingToLocalServer() throws IOException { setUpForLocalServices(); setUpLeaderBlockInConfig(); TransactionManagers.LockAndTimestampServices lockAndTimestamp = getLockAndTimestampServices(); availableServer.verify(getRequestedFor(urlMatching(LEADER_UUID_PATH))); lockAndTimestamp.timelock().getFreshTimestamp(); lockAndTimestamp.lock().currentTimeMillis(); availableServer.verify(0, postRequestedFor(urlMatching(TIMESTAMP_PATH)) .withHeader(USER_AGENT_HEADER, WireMock.equalTo(EXPECTED_USER_AGENT_STRING))); availableServer.verify(0, postRequestedFor(urlMatching(LOCK_PATH)) .withHeader(USER_AGENT_HEADER, WireMock.equalTo(EXPECTED_USER_AGENT_STRING))); }