public static <T> T load(File configFile, Class<T> clazz) throws IOException { return load(configFile, ATLASDB_CONFIG_OBJECT_PATH, clazz); }
public static AtlasDbConfig addFallbackSslConfigurationToAtlasDbConfig( AtlasDbConfig config, Optional<SslConfiguration> sslConfiguration) { return ImmutableAtlasDbConfig.builder() .from(config) .leader(addFallbackSslConfigurationToLeader(config.leader(), sslConfiguration)) .lock(addFallbackSslConfigurationToServerList(config.lock(), sslConfiguration)) .timestamp(addFallbackSslConfigurationToServerList(config.timestamp(), sslConfiguration)) .timelock(addFallbackSslConfigurationToTimeLockClientConfig(config.timelock(), sslConfiguration)) .build(); }
private static Optional<ServerListConfig> addFallbackSslConfigurationToServerList( Optional<ServerListConfig> config, Optional<SslConfiguration> sslConfiguration) { return config.map(addSslConfigurationToServerListFunction(sslConfiguration)); }
private static <T> T getConfig(JsonNode node, @Nullable String configRoot, Class<T> clazz) throws IOException { JsonNode configNode = findRoot(node, configRoot); if (configNode == null) { throw new IllegalArgumentException("Could not find " + configRoot + " in input"); } return OBJECT_MAPPER.treeToValue(decryptConfigValues(configNode), clazz); }
public AtlasDbServices connectToServices() throws IOException { AtlasDbConfig toConfig = toConfigFile != null ? AtlasDbConfigs.load(toConfigFile, configRoot, AtlasDbConfig.class) : AtlasDbConfigs.loadFromString(inlineConfig, null, AtlasDbConfig.class); ServicesConfigModule scm = ServicesConfigModule.create( makeOfflineIfNecessary(toConfig), AtlasDbRuntimeConfig.withSweepDisabled()); return DaggerAtlasDbServices.builder().servicesConfigModule(scm).build(); }
public AtlasDbServices connectToServices() throws IOException { AtlasDbConfig toConfig = toConfigFile != null ? AtlasDbConfigs.load(toConfigFile, configRoot, AtlasDbConfig.class) : AtlasDbConfigs.loadFromString(inlineConfig, null, AtlasDbConfig.class); ServicesConfigModule scm = ServicesConfigModule.create( makeOfflineIfNecessary(toConfig), AtlasDbRuntimeConfig.withSweepDisabled()); return DaggerAtlasDbServices.builder().servicesConfigModule(scm).build(); }
private static <T> T getConfig(JsonNode node, @Nullable String configRoot, Class<T> clazz) throws IOException { JsonNode configNode = findRoot(node, configRoot); if (configNode == null) { throw new IllegalArgumentException("Could not find " + configRoot + " in input"); } return OBJECT_MAPPER.treeToValue(decryptConfigValues(configNode), clazz); }
private <T> T parseAtlasDbConfig(File confFile, Class<T> clazz, String confRoot) { try { return AtlasDbConfigs.load(confFile, confRoot, clazz); } catch (Exception e) { try { return AtlasDbConfigs.load(confFile, ALTERNATE_ATLASDB_CONFIG_OBJECT_PATH, clazz); } catch (Exception ex) { throw new RuntimeException("Failed to load the atlasdb config. One possibility" + " is that the AtlasDB block root in the config is not '/atlasdb' nor '/atlas'." + " You can specify a different config root by specifying the --config-root " + " and the --runtime-config-root options before the command (i.e. sweep, migrate).", ex); } } }
public static AtlasDbConfig addFallbackSslConfigurationToAtlasDbConfig( AtlasDbConfig config, Optional<SslConfiguration> sslConfiguration) { return ImmutableAtlasDbConfig.builder() .from(config) .leader(addFallbackSslConfigurationToLeader(config.leader(), sslConfiguration)) .lock(addFallbackSslConfigurationToServerList(config.lock(), sslConfiguration)) .timestamp(addFallbackSslConfigurationToServerList(config.timestamp(), sslConfiguration)) .timelock(addFallbackSslConfigurationToTimeLockClientConfig(config.timelock(), sslConfiguration)) .build(); }
private static Optional<TimeLockClientConfig> addFallbackSslConfigurationToTimeLockClientConfig( Optional<TimeLockClientConfig> config, Optional<SslConfiguration> sslConfiguration) { //noinspection ConstantConditions - function returns an existing ServerListConfig, maybe with different SSL. return config.map(clientConfig -> ImmutableTimeLockClientConfig.builder() .from(clientConfig) .serversList(addSslConfigurationToServerListFunction(sslConfiguration) .apply(clientConfig.serversList())) .build()); }
public static ServicesConfigModule create(File configFile, String configRoot, AtlasDbRuntimeConfig runtimeConfig) throws IOException { return ServicesConfigModule.create(AtlasDbConfigs.load(configFile, configRoot, AtlasDbConfig.class), runtimeConfig); }
private static Optional<ServerListConfig> addFallbackSslConfigurationToServerList( Optional<ServerListConfig> config, Optional<SslConfiguration> sslConfiguration) { return config.map(addSslConfigurationToServerListFunction(sslConfiguration)); }
private AtlasDbConfig getPostgresTestConfig() throws IOException { // Palantir internal runs this test from the jar rather than from source. This means that the resource // cannot be loaded as a file. Instead it must be loaded as a stream. try (InputStream stream = getClass().getClassLoader().getResourceAsStream("postgresTestConfig.yml")) { return AtlasDbConfigs.load(stream, AtlasDbConfig.class); } }
private static Optional<TimeLockClientConfig> addFallbackSslConfigurationToTimeLockClientConfig( Optional<TimeLockClientConfig> config, Optional<SslConfiguration> sslConfiguration) { //noinspection ConstantConditions - function returns an existing ServerListConfig, maybe with different SSL. return config.map(clientConfig -> ImmutableTimeLockClientConfig.builder() .from(clientConfig) .serversList(addSslConfigurationToServerListFunction(sslConfiguration) .apply(clientConfig.serversList())) .build()); }
@Test public void canDecryptValues() throws IOException { AtlasDbConfig config = AtlasDbConfigs.load( new File(AtlasDbConfigsTest.class.getResource("/encrypted-config.yml").getPath()), AtlasDbConfig.class); KeyValueServiceConfig kvsConfig = config.keyValueService(); assertThat(kvsConfig).isInstanceOf(InMemoryAtlasDbConfig.class); }
@Test public void canDeserializeMinimalAtlasDbConfig() throws IOException { AtlasDbConfig config = AtlasDbConfigs.load(MINIMAL_TEST_CONFIG_FILE, AtlasDbConfig.class); assertThat(config.namespace().isPresent()).isFalse(); assertThat(config.keyValueService()).isEqualTo(new InMemoryAtlasDbConfig()); assertThat(config.timelock().isPresent()).isFalse(); assertThat(config.leader().isPresent()).isFalse(); assertThat(config.enableSweep()).isEqualTo(AtlasDbConstants.DEFAULT_ENABLE_SWEEP); }
@Test public void canDeserializeAtlasDbConfig() throws IOException { AtlasDbConfig config = AtlasDbConfigs.load(TEST_CONFIG_FILE, AtlasDbConfig.class); assertThat(config.namespace().get()).isEqualTo("brian"); assertThat(config.keyValueService()).isEqualTo(new InMemoryAtlasDbConfig()); assertThat(config.timelock().isPresent()).isTrue(); assertTimeLockConfigDeserializedCorrectly(config.timelock().get()); assertThat(config.leader().isPresent()).isFalse(); assertThat(config.enableSweep()).isTrue(); }
public AtlasDbServices connectFromServices() throws IOException { AtlasDbConfig fromConfig = AtlasDbConfigs.load(fromConfigFile, configRoot, AtlasDbConfig.class); ServicesConfigModule scm = ServicesConfigModule.create( makeOfflineIfNecessary(fromConfig), AtlasDbRuntimeConfig.withSweepDisabled()); return DaggerAtlasDbServices.builder().servicesConfigModule(scm).build(); }
public static <T> T load(File configFile, Class<T> clazz) throws IOException { return load(configFile, ATLASDB_CONFIG_OBJECT_PATH, clazz); }
@Test public void daggerCanInstantiateAtlas() throws URISyntaxException, IOException { File config = new File(getResourcePath("simple_atlas_config.yml")); ServicesConfigModule servicesConfigModule = ServicesConfigModule.create( AtlasDbConfigs.load(config, AtlasDbConfig.class), AtlasDbRuntimeConfig.defaultRuntimeConfig()); DaggerAtlasDbServices.builder() .servicesConfigModule(servicesConfigModule) .build(); }