You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@gobblin.apache.org by GitBox <gi...@apache.org> on 2019/05/31 17:41:38 UTC

[GitHub] [incubator-gobblin] shirshanka commented on a change in pull request #2654: GOBBLIN-776: Add a utility method to return Helix WorflowId given a Gobblin job name.

shirshanka commented on a change in pull request #2654: GOBBLIN-776: Add a utility method to return Helix WorflowId given a Gobblin job name.
URL: https://github.com/apache/incubator-gobblin/pull/2654#discussion_r289472603
 
 

 ##########
 File path: gobblin-cluster/src/main/java/org/apache/gobblin/cluster/HelixUtils.java
 ##########
 @@ -251,4 +256,41 @@ private static void deleteStoppedHelixJob(HelixManager helixManager, String work
     new TaskDriver(helixManager).deleteAndWaitForCompletion(workFlowName, 10000L);
     log.info("Workflow deleted.");
   }
+
+  /**
+   * Returns the Helix Workflow Ids given {@link Iterable} of Gobblin job names. The method returns a
+   * {@link Map} from Gobblin job name to the corresponding Helix Workflow Id. This method iterates
+   * each Helix workflow, and obtains the jobs of each workflow from its jobDag.
+   * @param jobNames a list of Gobblin job names.
+   * @return a map from jobNames to their Helix Workflow Ids.
+   */
+  public static Map<String, String> getWorkflowIdsFromJobNames(HelixManager helixManager, Iterable<String> jobNames) {
+    Map<String, String> jobNameToWorkflowId = new HashMap<>();
+    TaskDriver taskDriver = new TaskDriver(helixManager);
+    Map<String, WorkflowConfig> workflowConfigMap = taskDriver.getWorkflows();
+    for (String workflow: workflowConfigMap.keySet()) {
+      WorkflowConfig workflowConfig = taskDriver.getWorkflowConfig(workflow);
+      Set<String> helixJobs = workflowConfig.getJobDag().getAllNodes();
+
+      for (String helixJob: helixJobs) {
+        Iterator<TaskConfig> taskConfigIterator = taskDriver.getJobConfig(helixJob).getTaskConfigMap().values().iterator();
+        if (taskConfigIterator.hasNext()) {
+          TaskConfig taskConfig = taskConfigIterator.next();
+          for (String jobName: jobNames) {
 
 Review comment:
   inner loop can be converted into contains check

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services