vjagadish1989 commented on a change in pull request #938: SAMZA-1531: Support 
run.id in standalone for batch processing.
URL: https://github.com/apache/samza/pull/938#discussion_r286733736
 
 

 ##########
 File path: 
samza-core/src/main/java/org/apache/samza/runtime/LocalApplicationRunner.java
 ##########
 @@ -77,20 +93,74 @@
    */
   public LocalApplicationRunner(SamzaApplication app, Config config) {
     this.appDesc = ApplicationDescriptorUtil.getAppDescriptor(app, config);
-    this.planner = new LocalJobPlanner(appDesc);
+    isAppModeBatch = new ApplicationConfig(config).getAppMode() == 
ApplicationConfig.ApplicationMode.BATCH;
+    coordinationUtils = getCoordinationUtils(config);
   }
 
   /**
    * Constructor only used in unit test to allow injection of {@link 
LocalJobPlanner}
    */
   @VisibleForTesting
-  LocalApplicationRunner(ApplicationDescriptorImpl<? extends 
ApplicationDescriptor> appDesc, LocalJobPlanner planner) {
+  LocalApplicationRunner(ApplicationDescriptorImpl<? extends 
ApplicationDescriptor> appDesc, Optional<CoordinationUtils> coordinationUtils) {
     this.appDesc = appDesc;
-    this.planner = planner;
+    isAppModeBatch = new ApplicationConfig(appDesc.getConfig()).getAppMode() 
== ApplicationConfig.ApplicationMode.BATCH;
+    this.coordinationUtils = coordinationUtils;
+  }
+
+  private Optional<CoordinationUtils> getCoordinationUtils(Config config) {
+    if (!isAppModeBatch) {
+      return Optional.empty();
+    }
+    JobCoordinatorConfig jcConfig = new JobCoordinatorConfig(config);
+    CoordinationUtils coordinationUtils = 
jcConfig.getCoordinationUtilsFactory().getCoordinationUtils(CoordinationConstants.APPLICATION_RUNNER_PATH_SUFFIX,
 PROCESSOR_ID, config);
+    return Optional.ofNullable(coordinationUtils);
+  }
+
+  /**
+   * @return LocalJobPlanner created
+   */
+  @VisibleForTesting
+  LocalJobPlanner getPlanner() {
+    boolean isAppModeBatch = new 
ApplicationConfig(appDesc.getConfig()).getAppMode() == 
ApplicationConfig.ApplicationMode.BATCH;
+    if (!isAppModeBatch) {
+      return new LocalJobPlanner(appDesc, PROCESSOR_ID);
+    }
+    CoordinationUtils coordinationUtils = this.coordinationUtils.orElse(null);
+    String runId = this.runId.orElse(null);
+    return new LocalJobPlanner(appDesc, coordinationUtils, PROCESSOR_ID, 
runId);
+  }
+
+
+  private void initializeRunId() {
 
 Review comment:
   make the function stateless by return "getRunId()" instead of mutating 
class-state

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to