default boolean hasAtLeastOneServer() { return servers().size() >= 1; } }
public static ServerListConfig namespaceUris(ServerListConfig config, String namespace) { Set<String> serversWithNamespaces = config .servers() .stream() .map(serverAddress -> serverAddress.replaceAll("/$", "") + "/" + namespace) .collect(Collectors.toSet()); return ImmutableServerListConfig.builder() .from(config) .servers(serversWithNamespaces) .build(); } }
@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 namespacingAddsClientNameCorrectly() { ServerListConfig namespacedServersList = ServerListConfigs.namespaceUris(SERVERS_LIST_1, CLIENT); assertThat(namespacedServersList.servers()).containsExactly("one/client"); }
@Test public void namespacingAddsClientNameToAllServers() { ServerListConfig namespacedServersList = ServerListConfigs.namespaceUris(SERVERS_LIST_2, CLIENT); assertThat(namespacedServersList.servers()).containsExactlyInAnyOrder("one/client", "two/client"); }
@Test public void namespacingCanDealWithServerListConfigsWithZeroNodes() { ServerListConfig namespacedServersList = ServerListConfigs.namespaceUris(SERVERS_LIST_EMPTY, CLIENT); assertThat(namespacedServersList.servers()).isEmpty(); }
@Test public void fallsBackToInstallConfigIfRuntimeConfigNotAvailable() { ServerListConfig resolvedConfig = ServerListConfigs.parseInstallAndRuntimeConfigs( INSTALL_CONFIG, Optional::empty, CLIENT); assertThat(resolvedConfig.servers()).containsExactlyInAnyOrder("one/client"); } }
private void assertTimeLockConfigDeserializedCorrectly(TimeLockClientConfig timeLockClientConfig) { assertThat(timeLockClientConfig.getClientOrThrow()).isEqualTo("brian"); assertThat(timeLockClientConfig.serversList().servers()).containsExactlyInAnyOrder( "timelock1:8080", "timelock2:8080", "timelock3:8080"); assertThat(timeLockClientConfig.serversList().sslConfiguration().isPresent()).isTrue(); SslConfiguration sslConfiguration = timeLockClientConfig.serversList().sslConfiguration().get(); assertSslConfigDeserializedCorrectly(sslConfiguration); }
@Test public void prioritisesRuntimeConfigEvenIfThatHasNoClients() { ServerListConfig resolvedConfig = ServerListConfigs.parseInstallAndRuntimeConfigs( INSTALL_CONFIG, () -> Optional.of(ImmutableTimeLockRuntimeConfig.builder().build()), CLIENT); assertThat(resolvedConfig.servers()).isEmpty(); }
@Test public void canDeserializeRuntimeConfigWithZeroServers() throws IOException { AtlasDbRuntimeConfig runtimeConfig = AtlasDbConfigs.OBJECT_MAPPER.readValue(TEST_RUNTIME_CONFIG_NO_SERVERS_FILE, AtlasDbRuntimeConfig.class); assertThat(runtimeConfig.timestampClient().enableTimestampBatching()).isTrue(); assertThat(runtimeConfig.timelockRuntime()).isPresent(); assertThat(runtimeConfig.timelockRuntime().get().serversList().servers()).isEmpty(); assertThat(runtimeConfig.timelockRuntime().get().serversList().sslConfiguration()).isEmpty(); } }
@Test public void canGetNamespacedConfigsFromTimelockBlock() { ServerListConfig namespacedConfig = MULTIPLE_SERVER_CONFIG.toNamespacedServerList(); assertThat(namespacedConfig.servers(), hasItems(SERVER_1 + "/" + CLIENT, SERVER_2 + "/" + CLIENT)); }
@Test public void canDeserializeRuntimeConfig() throws IOException { AtlasDbRuntimeConfig runtimeConfig = AtlasDbConfigs.OBJECT_MAPPER.readValue(TEST_RUNTIME_CONFIG_FILE, AtlasDbRuntimeConfig.class); assertThat(runtimeConfig.timestampClient().enableTimestampBatching()).isTrue(); assertThat(runtimeConfig.timelockRuntime()).isPresent(); assertThat(runtimeConfig.timelockRuntime().get().serversList().servers()) .containsExactlyInAnyOrder( "https://foo1:12345", "https://foo2:8421", "https://foo3:9421"); assertThat(runtimeConfig.timelockRuntime().get().serversList().sslConfiguration()).satisfies( sslConfiguration -> sslConfiguration.ifPresent(this::assertSslConfigDeserializedCorrectly)); assertThat(runtimeConfig.streamStorePersistence()).satisfies( persistenceConfig -> { assertThat(persistenceConfig.numBlocksToWriteBeforePause()).isEqualTo(7); assertThat(persistenceConfig.writePauseDurationMillis()).isEqualTo(77); }); assertThat(runtimeConfig.sweep().sweepPriorityOverrides()).satisfies( overrides -> { assertThat(overrides.priorityTables()).containsExactlyInAnyOrder("atlas.mission_critical_table"); assertThat(overrides.blacklistTables()).containsExactlyInAnyOrder( "atlas.bad_table", "atlas2.immutable_log"); }); }
default boolean hasAtLeastOneServer() { return servers().size() >= 1; } }
serverListConfig.sslConfiguration().map(trustContextCreator), serverListConfig.proxyConfiguration().map(proxySelectorCreator), serverListConfig.servers(), feignConnectTimeout, feignReadTimeout,
public static ServerListConfig namespaceUris(ServerListConfig config, String namespace) { Set<String> serversWithNamespaces = config .servers() .stream() .map(serverAddress -> serverAddress.replaceAll("/$", "") + "/" + namespace) .collect(Collectors.toSet()); return ImmutableServerListConfig.builder() .from(config) .servers(serversWithNamespaces) .build(); } }
serverListConfig.sslConfiguration().map(trustContextCreator), serverListConfig.proxyConfiguration().map(proxySelectorCreator), serverListConfig.servers(), feignConnectTimeout, feignReadTimeout,