use of org.apache.samza.config.loaders.PropertiesConfigLoaderFactory in project beam by apache.
the class ConfigBuilder method createUserConfig.
private static Map<String, String> createUserConfig(SamzaPipelineOptions options) throws Exception {
final Map<String, String> config = new HashMap<>();
// apply user configs
final String configFilePath = options.getConfigFilePath();
// If user provides a config file, use it as base configs.
if (StringUtils.isNoneEmpty(configFilePath)) {
LOG.info("configFilePath: " + configFilePath);
final Config properties = new MapConfig(Collections.singletonMap("path", configFilePath));
final ConfigLoaderFactory configLoaderFactory = options.getConfigLoaderFactory().getDeclaredConstructor().newInstance();
LOG.info("configLoaderFactory: " + configLoaderFactory.getClass().getName());
// pass the command-line args through the containers
if (configLoaderFactory instanceof PropertiesConfigLoaderFactory) {
checkArgument(new File(configFilePath).exists(), "Config file %s does not exist", configFilePath);
}
config.putAll(configLoaderFactory.getLoader(properties).getConfig());
}
// Apply override on top
if (options.getConfigOverride() != null) {
config.putAll(options.getConfigOverride());
}
return config;
}
Aggregations