Search in sources :

Example 1 with ConfigRewriter

use of org.apache.samza.config.ConfigRewriter in project samza by apache.

the class ConfigUtil method applyRewriter.

/**
 * Re-writes configuration using a ConfigRewriter, defined with the given rewriterName in config.
 * @param config the config to re-write
 * @param rewriterName the name of the rewriter to apply
 * @return the rewritten config
 */
public static Config applyRewriter(Config config, String rewriterName) {
    String rewriterClassName = new JobConfig(config).getConfigRewriterClass(rewriterName).orElseThrow(() -> new SamzaException(String.format("Unable to find class config for config rewriter %s.", rewriterName)));
    ConfigRewriter rewriter = ReflectionUtil.getObj(rewriterClassName, ConfigRewriter.class);
    LOG.info("Re-writing config with {}", rewriter);
    return rewriter.rewrite(rewriterName, config);
}
Also used : SamzaException(org.apache.samza.SamzaException) JobConfig(org.apache.samza.config.JobConfig) ConfigRewriter(org.apache.samza.config.ConfigRewriter)

Aggregations

SamzaException (org.apache.samza.SamzaException)1 ConfigRewriter (org.apache.samza.config.ConfigRewriter)1 JobConfig (org.apache.samza.config.JobConfig)1