private static Supplier<ServerListConfig> getServerListConfigSupplierForTimeLock( AtlasDbConfig config, Supplier<AtlasDbRuntimeConfig> runtimeConfigSupplier) { Preconditions.checkState(!remoteTimestampAndLockOrLeaderBlocksPresent(config), "Cannot create raw services from timelock with another source of timestamps/locks configured!"); TimeLockClientConfig clientConfig = config.timelock().orElse(ImmutableTimeLockClientConfig.builder().build()); String resolvedClient = OptionalResolver.resolve(clientConfig.client(), config.namespace()); return () -> ServerListConfigs.parseInstallAndRuntimeConfigs( clientConfig, () -> runtimeConfigSupplier.get().timelockRuntime(), resolvedClient); }
@Test public void prioritisesRuntimeConfigIfAvailable() { ServerListConfig resolvedConfig = ServerListConfigs.parseInstallAndRuntimeConfigs( INSTALL_CONFIG, () -> Optional.of(RUNTIME_CONFIG), CLIENT); assertThat(resolvedConfig.servers()).containsExactlyInAnyOrder("one/client", "two/client"); }
@Test public void fallsBackToInstallConfigIfRuntimeConfigNotAvailable() { ServerListConfig resolvedConfig = ServerListConfigs.parseInstallAndRuntimeConfigs( INSTALL_CONFIG, Optional::empty, CLIENT); assertThat(resolvedConfig.servers()).containsExactlyInAnyOrder("one/client"); } }
@Test public void prioritisesRuntimeConfigEvenIfThatHasNoClients() { ServerListConfig resolvedConfig = ServerListConfigs.parseInstallAndRuntimeConfigs( INSTALL_CONFIG, () -> Optional.of(ImmutableTimeLockRuntimeConfig.builder().build()), CLIENT); assertThat(resolvedConfig.servers()).isEmpty(); }
private static Supplier<ServerListConfig> getServerListConfigSupplierForTimeLock( AtlasDbConfig config, Supplier<AtlasDbRuntimeConfig> runtimeConfigSupplier) { Preconditions.checkState(!remoteTimestampAndLockOrLeaderBlocksPresent(config), "Cannot create raw services from timelock with another source of timestamps/locks configured!"); TimeLockClientConfig clientConfig = config.timelock().orElse(ImmutableTimeLockClientConfig.builder().build()); String resolvedClient = OptionalResolver.resolve(clientConfig.client(), config.namespace()); return () -> ServerListConfigs.parseInstallAndRuntimeConfigs( clientConfig, () -> runtimeConfigSupplier.get().timelockRuntime(), resolvedClient); }