Search in sources :

Example 1 with PropertiesConfigLoaderFactory

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;
}
Also used : PropertiesConfigLoaderFactory(org.apache.samza.config.loaders.PropertiesConfigLoaderFactory) HashMap(java.util.HashMap) ApplicationConfig(org.apache.samza.config.ApplicationConfig) MapConfig(org.apache.samza.config.MapConfig) ZkConfig(org.apache.samza.config.ZkConfig) JobCoordinatorConfig(org.apache.samza.config.JobCoordinatorConfig) Config(org.apache.samza.config.Config) ConfigLoaderFactory(org.apache.samza.config.ConfigLoaderFactory) PropertiesConfigLoaderFactory(org.apache.samza.config.loaders.PropertiesConfigLoaderFactory) MapConfig(org.apache.samza.config.MapConfig) File(java.io.File)

Aggregations

File (java.io.File)1 HashMap (java.util.HashMap)1 ApplicationConfig (org.apache.samza.config.ApplicationConfig)1 Config (org.apache.samza.config.Config)1 ConfigLoaderFactory (org.apache.samza.config.ConfigLoaderFactory)1 JobCoordinatorConfig (org.apache.samza.config.JobCoordinatorConfig)1 MapConfig (org.apache.samza.config.MapConfig)1 ZkConfig (org.apache.samza.config.ZkConfig)1 PropertiesConfigLoaderFactory (org.apache.samza.config.loaders.PropertiesConfigLoaderFactory)1