arjun4084346 commented on a change in pull request #3403:
URL: https://github.com/apache/gobblin/pull/3403#discussion_r743147800



##########
File path: 
gobblin-runtime/src/main/java/org/apache/gobblin/service/monitoring/JobStatusRetriever.java
##########
@@ -218,4 +228,42 @@ public static boolean 
isFlowStatus(org.apache.gobblin.service.monitoring.JobStat
     return jobStatus.getJobName() != null && jobStatus.getJobGroup() != null
         && jobStatus.getJobName().equals(JobStatusRetriever.NA_KEY) && 
jobStatus.getJobGroup().equals(JobStatusRetriever.NA_KEY);
   }
+
+  public static ExecutionStatus getFlowStatusFromJobStatuses(boolean 
dagManagerEnabled, Iterator<JobStatus> jobStatusIterator) {
+    ExecutionStatus flowExecutionStatus = ExecutionStatus.$UNKNOWN;
+
+    if (dagManagerEnabled) {
+      while (jobStatusIterator.hasNext()) {
+        JobStatus jobStatus = jobStatusIterator.next();
+        // Check if this is the flow status instead of a single job status
+        if (JobStatusRetriever.isFlowStatus(jobStatus)) {
+          flowExecutionStatus = 
ExecutionStatus.valueOf(jobStatus.getEventName());
+        }
+      }
+    } else {
+      Set<ExecutionStatus> jobStatuses = new HashSet<>();
+      while (jobStatusIterator.hasNext()) {
+        JobStatus jobStatus = jobStatusIterator.next();
+        // because in absence of DagManager we do not get all flow level 
events, we will ignore the flow level events
+        // we actually get and purely calculate flow status based on flow 
statuses.
+        if (!JobStatusRetriever.isFlowStatus(jobStatus)) {
+          jobStatuses.add(ExecutionStatus.valueOf(jobStatus.getEventName()));
+        }
+      }
+
+      if (jobStatuses.contains(ExecutionStatus.FAILED)) {
+        flowExecutionStatus = ExecutionStatus.FAILED;
+      } else if (jobStatuses.contains(ExecutionStatus.CANCELLED)) {
+        flowExecutionStatus = ExecutionStatus.CANCELLED;
+      } else if (jobStatuses.contains(ExecutionStatus.ORCHESTRATED)) {
+        flowExecutionStatus = ExecutionStatus.ORCHESTRATED;
+      } else if (jobStatuses.contains(ExecutionStatus.RUNNING)) {
+        flowExecutionStatus = ExecutionStatus.RUNNING;
+      } else if (jobStatuses.contains(ExecutionStatus.COMPLETE)) {
+        flowExecutionStatus = ExecutionStatus.COMPLETE;

Review comment:
       Yes, `KafkaJobStatusMonitor` should update the job status




-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to