@Test public void testJobLoadingWithSysPropsAndGlobalProps() throws Exception { Path path; Config pullFile; Properties sysProps = new Properties(); sysProps.put("key1", "sysProps1"); path = new Path(this.basePath, "ajob.pull"); pullFile = loader.loadPullFile(path, ConfigUtils.propertiesToConfig(sysProps), true); Assert.assertEquals(pullFile.getString("key1"), "rootValue1"); Assert.assertEquals(pullFile.getString("key2"), "aValue"); Assert.assertEquals(pullFile.getString("key10"), "aValue"); Assert.assertEquals(pullFile.getString("key3"), "rootValue3"); Assert.assertEquals(pullFile.getString(ConfigurationKeys.JOB_CONFIG_FILE_PATH_KEY), path.toString()); Assert.assertEquals(pullFile.entrySet().size(), 5); path = new Path(this.basePath, "dir1/job.pull"); pullFile = loader.loadPullFile(path, ConfigUtils.propertiesToConfig(sysProps), true); Assert.assertEquals(pullFile.getString("key1"), "jobValue1,jobValue2,jobValue3"); Assert.assertEquals(pullFile.getString("key2"), "jobValue2"); Assert.assertEquals(pullFile.getString("key2a"), "jobValue2"); Assert.assertEquals(pullFile.getString("key3"), "rootValue3"); Assert.assertEquals(pullFile.getString("key4"), "dir1Value4"); Assert.assertEquals(pullFile.getString(ConfigurationKeys.JOB_CONFIG_FILE_PATH_KEY), path.toString()); Assert.assertEquals(pullFile.entrySet().size(), 6); path = new Path(this.basePath, "dir1/job.conf"); pullFile = loader.loadPullFile(path, ConfigFactory.empty(), true); Assert.assertEquals(pullFile.getString("key1"), "jobValue1,jobValue2,jobValue3"); Assert.assertEquals(pullFile.getString("key2"), "dir1Value4"); Assert.assertEquals(pullFile.getString("key2a"), "dir1Value4"); Assert.assertEquals(pullFile.getString("key3"), "rootValue3"); Assert.assertEquals(pullFile.getString("key4"), "dir1Value4"); Assert.assertEquals(pullFile.getString("key10"), "jobValue2"); Assert.assertEquals(pullFile.getString(ConfigurationKeys.JOB_CONFIG_FILE_PATH_KEY), path.toString()); Assert.assertEquals(pullFile.entrySet().size(), 7); }
public Config loadPullFile(Path path, Config sysProps, boolean loadGlobalProperties, boolean resolve) throws IOException { Config fallback = loadGlobalProperties ? loadAncestorGlobalConfigs(path, sysProps) : sysProps; Config loadedConfig; if (this.javaPropsPullFileFilter.accept(path)) { loadedConfig = loadJavaPropsWithFallback(path, fallback); } else if (this.hoconPullFileFilter.accept(path)) { loadedConfig = loadHoconConfigAtPath(path).withFallback(fallback); } else { throw new IOException(String.format("Cannot load pull file %s due to unrecognized extension.", path)); } return resolve ? loadedConfig.resolve() : loadedConfig; }
PullFileLoader { public Config loadPullFile(Path path, Config sysProps, boolean loadGlobalProperties, boolean resolve) throws IOException { Config fallback = loadGlobalProperties ? loadAncestorGlobalConfigs(path, sysProps) : sysProps; Config loadedConfig; if (this.javaPropsPullFileFilter.accept(path)) { loadedConfig = loadJavaPropsWithFallback(path, fallback); } else if (this.hoconPullFileFilter.accept(path)) { loadedConfig = loadHoconConfigAtPath(path).withFallback(fallback); } else { throw new IOException(String.format("Cannot load pull file %s due to unrecognized extension.", path)); } return resolve ? loadedConfig.resolve() : loadedConfig; } }
PullFileLoader { public Config loadPullFile(Path path, Config sysProps, boolean loadGlobalProperties, boolean resolve) throws IOException { Config fallback = loadGlobalProperties ? loadAncestorGlobalConfigs(path, sysProps) : sysProps; Config loadedConfig; if (this.javaPropsPullFileFilter.accept(path)) { loadedConfig = loadJavaPropsWithFallback(path, fallback); } else if (this.hoconPullFileFilter.accept(path)) { loadedConfig = loadHoconConfigAtPath(path).withFallback(fallback); } else { throw new IOException(String.format("Cannot load pull file %s due to unrecognized extension.", path)); } return resolve ? loadedConfig.resolve() : loadedConfig; } PullFileLoader(Path rootDirectory, FileSystem fs, Collection<String> javaPropsPullFileExtensions,
      Collection<String> hoconPullFileExtensions); }
PullFileLoader { public Config loadPullFile(Path path, Config sysProps, boolean loadGlobalProperties, boolean resolve) throws IOException { Config fallback = loadGlobalProperties ? loadAncestorGlobalConfigs(path, sysProps) : sysProps; Config loadedConfig; if (this.javaPropsPullFileFilter.accept(path)) { loadedConfig = loadJavaPropsWithFallback(path, fallback); } else if (this.hoconPullFileFilter.accept(path)) { loadedConfig = loadHoconConfigAtPath(path).withFallback(fallback); } else { throw new IOException(String.format("Cannot load pull file %s due to unrecognized extension.", path)); } return resolve ? loadedConfig.resolve() : loadedConfig; } PullFileLoader(Path rootDirectory, FileSystem fs, Collection<String> javaPropsPullFileExtensions,
      Collection<String> hoconPullFileExtensions); Config loadPullFile(Path path, Config sysProps, boolean loadGlobalProperties, boolean resolve); Config loadPullFile(Path path, Config sysProps, boolean loadGlobalProperties); List<Config> loadPullFilesRecursively(Path path, Config sysProps, boolean loadGlobalProperties); List<Path> fetchJobFilesRecursively(Path path); }
PullFileLoader { public Config loadPullFile(Path path, Config sysProps, boolean loadGlobalProperties, boolean resolve) throws IOException { Config fallback = loadGlobalProperties ? loadAncestorGlobalConfigs(path, sysProps) : sysProps; Config loadedConfig; if (this.javaPropsPullFileFilter.accept(path)) { loadedConfig = loadJavaPropsWithFallback(path, fallback); } else if (this.hoconPullFileFilter.accept(path)) { loadedConfig = loadHoconConfigAtPath(path).withFallback(fallback); } else { throw new IOException(String.format("Cannot load pull file %s due to unrecognized extension.", path)); } return resolve ? loadedConfig.resolve() : loadedConfig; } PullFileLoader(Path rootDirectory, FileSystem fs, Collection<String> javaPropsPullFileExtensions,
      Collection<String> hoconPullFileExtensions); Config loadPullFile(Path path, Config sysProps, boolean loadGlobalProperties, boolean resolve); Config loadPullFile(Path path, Config sysProps, boolean loadGlobalProperties); List<Config> loadPullFilesRecursively(Path path, Config sysProps, boolean loadGlobalProperties); List<Path> fetchJobFilesRecursively(Path path); static final String GLOBAL_PROPS_EXTENSION; static final PathFilter GLOBAL_PROPS_PATH_FILTER; static final String GLOBAL_HOCON_EXTENSION; static final PathFilter GLOBAL_HOCON_PATH_FILTER; static final PathFilter GLOBAL_PATH_FILTER; static final Set<String> DEFAULT_JAVA_PROPS_PULL_FILE_EXTENSIONS; static final Set<String> DEFAULT_HOCON_PULL_FILE_EXTENSIONS; static final String PROPERTY_DELIMITER_PARSING_ENABLED_KEY; static final boolean DEFAULT_PROPERTY_DELIMITER_PARSING_ENABLED_KEY; }