cameronlee314 commented on a change in pull request #1248: SAMZA-2410: Update 
ClusterBasedJobCoordinator config retrieval logic from loader.
URL: https://github.com/apache/samza/pull/1248#discussion_r367055407
 
 

 ##########
 File path: samza-core/src/main/java/org/apache/samza/util/ConfigUtil.java
 ##########
 @@ -67,4 +72,42 @@ public static Config applyRewriter(Config config, String 
rewriterName) {
     LOG.info("Re-writing config with {}", rewriter);
     return rewriter.rewrite(rewriterName, config);
   }
+
+  /**
+   * Load full job config with {@link ConfigLoaderFactory} when present.
+   *
+   * @param original config
+   * @return full job config
+   */
+  public static Config loadConfig(Config original) {
+    JobConfig jobConfig = new JobConfig(original);
+    Config fullConfig = original;
+
+    if (jobConfig.getConfigLoaderFactory().isPresent()) {
+      ConfigLoaderFactory factory = 
ReflectionUtil.getObj(jobConfig.getConfigLoaderFactory().get(), 
ConfigLoaderFactory.class);
+      ConfigLoader loader = 
factory.getLoader(original.subset(ConfigLoaderFactory.CONFIG_LOADER_PROPERTIES_PREFIX));
+      // overrides config loaded with original config, which may contain 
overridden values.
+      fullConfig = override(ConfigUtil.rewriteConfig(loader.getConfig()), 
original);
+    }
 
 Review comment:
   The method name `loadConfig` is a bit misleading if it just might return the 
config that is passed in. If you still prefer to allow this to succeed when 
`ConfigLoaderFactory` is not present, then maybe at least rename the method to 
help clarify what it might do, so that someone doesn't accidentally call it in 
an unexpected way.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to