public static ServerListConfig parseInstallAndRuntimeConfigs(TimeLockClientConfig installClientConfig, Supplier<Optional<TimeLockRuntimeConfig>> runtimeConfig, String namespace) { ServerListConfig nonNamespacedConfig = runtimeConfig.get() .map(TimeLockRuntimeConfig::serversList) .orElse(installClientConfig.serversList()); return namespaceUris(nonNamespacedConfig, namespace); }
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); }
public ServerListConfig toNamespacedServerList() { return ServerListConfigs.namespaceUris(serversList(), getClientOrThrow()); }
@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 namespacingCanDealWithTrailingSlash() { ServerListConfig namespacedServersList = ServerListConfigs.namespaceUris(SERVERS_LIST_3, CLIENT); assertThat(namespacedServersList.servers()).containsExactlyInAnyOrder("three/client"); }
@Test public void fallsBackToInstallConfigIfRuntimeConfigNotAvailable() { ServerListConfig resolvedConfig = ServerListConfigs.parseInstallAndRuntimeConfigs( INSTALL_CONFIG, Optional::empty, CLIENT); assertThat(resolvedConfig.servers()).containsExactlyInAnyOrder("one/client"); } }
@Test public void namespacingAddsClientNameCorrectly() { ServerListConfig namespacedServersList = ServerListConfigs.namespaceUris(SERVERS_LIST_1, CLIENT); assertThat(namespacedServersList.servers()).containsExactly("one/client"); }
@Test public void prioritisesRuntimeConfigEvenIfThatHasNoClients() { ServerListConfig resolvedConfig = ServerListConfigs.parseInstallAndRuntimeConfigs( INSTALL_CONFIG, () -> Optional.of(ImmutableTimeLockRuntimeConfig.builder().build()), CLIENT); assertThat(resolvedConfig.servers()).isEmpty(); }
@Test public void namespacingAddsClientNameToAllServers() { ServerListConfig namespacedServersList = ServerListConfigs.namespaceUris(SERVERS_LIST_2, CLIENT); assertThat(namespacedServersList.servers()).containsExactlyInAnyOrder("one/client", "two/client"); }
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 namespacingCanDealWithServerListConfigsWithZeroNodes() { ServerListConfig namespacedServersList = ServerListConfigs.namespaceUris(SERVERS_LIST_EMPTY, CLIENT); assertThat(namespacedServersList.servers()).isEmpty(); }
public static ServerListConfig parseInstallAndRuntimeConfigs(TimeLockClientConfig installClientConfig, Supplier<Optional<TimeLockRuntimeConfig>> runtimeConfig, String namespace) { ServerListConfig nonNamespacedConfig = runtimeConfig.get() .map(TimeLockRuntimeConfig::serversList) .orElse(installClientConfig.serversList()); return namespaceUris(nonNamespacedConfig, namespace); }
public ServerListConfig toNamespacedServerList() { return ServerListConfigs.namespaceUris(serversList(), getClientOrThrow()); }