You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by di...@apache.org on 2019/06/02 22:26:05 UTC

[airavata] branch master updated: Filtering the job with Job Name

This is an automated email from the ASF dual-hosted git repository.

dimuthuupe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata.git


The following commit(s) were added to refs/heads/master by this push:
     new 4fe013c  Filtering the job with Job Name
4fe013c is described below

commit 4fe013c389a8dc1ff77ab8eb2dc07f657a865a14
Author: Dimuthu Wannipurage <di...@gmail.com>
AuthorDate: Sun Jun 2 18:25:55 2019 -0400

    Filtering the job with Job Name
---
 .../helix/impl/workflow/PostWorkflowManager.java   | 25 +++++++++++++---------
 .../apache/airavata/monitor/AbstractMonitor.java   |  9 +++++++-
 2 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/workflow/PostWorkflowManager.java b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/workflow/PostWorkflowManager.java
index bd522f2..5bb9595 100644
--- a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/workflow/PostWorkflowManager.java
+++ b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/workflow/PostWorkflowManager.java
@@ -53,6 +53,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.util.*;
+import java.util.stream.Collectors;
 
 public class PostWorkflowManager extends WorkflowManager {
 
@@ -94,20 +95,24 @@ public class PostWorkflowManager extends WorkflowManager {
             logger.info("Processing job result of job id " + jobStatusResult.getJobId() + " sent by " + jobStatusResult.getPublisherName());
 
             List<JobModel> jobs = registryClient.getJobs("jobId", jobStatusResult.getJobId());
-            ProcessModel processModel = null;
-            ExperimentModel experimentModel = null;
-            JobModel jobModel = null;
-            ProcessStatus processStatus = null;
+
+            if (jobs.size() > 0) {
+                logger.info("Filtering total " + jobs.size() + " with target job name " + jobStatusResult.getJobName());
+                jobs = jobs.stream().filter(jm -> jm.getJobName().equals(jobStatusResult.getJobName())).collect(Collectors.toList());
+            }
 
             if (jobs.size() != 1) {
-                logger.error("More than one job for job id " + jobStatusResult.getJobId() + " in the registry. Count " + jobs.size());
-            } else  {
-                jobModel = jobs.get(0);
-                processModel =  registryClient.getProcess(jobModel.getProcessId());
-                experimentModel =  registryClient.getExperiment(processModel.getExperimentId());
-                processStatus = registryClient.getProcessStatus(processModel.getProcessId());
+                logger.error("Couldn't find exactly one job with id " + jobStatusResult.getJobId() + " and name " +
+                        jobStatusResult.getJobName() + " in the registry. Count " + jobs.size());
+                getRegistryClientPool().returnResource(registryClient);
+                return false;
             }
 
+            JobModel jobModel = jobs.get(0);
+            ProcessModel processModel = registryClient.getProcess(jobModel.getProcessId());
+            ExperimentModel experimentModel = registryClient.getExperiment(processModel.getExperimentId());
+            ProcessStatus processStatus = registryClient.getProcessStatus(processModel.getProcessId());
+
             getRegistryClientPool().returnResource(registryClient);
 
             if (processModel != null && experimentModel != null) {
diff --git a/modules/job-monitor/job-monitor-api/src/main/java/org/apache/airavata/monitor/AbstractMonitor.java b/modules/job-monitor/job-monitor-api/src/main/java/org/apache/airavata/monitor/AbstractMonitor.java
index 612c48f..92efa00 100644
--- a/modules/job-monitor/job-monitor-api/src/main/java/org/apache/airavata/monitor/AbstractMonitor.java
+++ b/modules/job-monitor/job-monitor-api/src/main/java/org/apache/airavata/monitor/AbstractMonitor.java
@@ -15,6 +15,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.util.List;
+import java.util.stream.Collectors;
 
 public class AbstractMonitor {
 
@@ -54,8 +55,14 @@ public class AbstractMonitor {
         try {
             List<JobModel> jobs = registryClient.getJobs("jobId", jobStatusResult.getJobId());
 
+            if (jobs.size() > 0) {
+                log.info("Filtering total " + jobs.size() + " with target job name " + jobStatusResult.getJobName());
+                jobs = jobs.stream().filter(jm -> jm.getJobName().equals(jobStatusResult.getJobName())).collect(Collectors.toList());
+            }
+
             if (jobs.size() != 1) {
-                log.error("More than one job for job id " + jobStatusResult.getJobId() + " in the registry. Count " + jobs.size());
+                log.error("Couldn't find exactly one job with id " + jobStatusResult.getJobId() + " and name " +
+                        jobStatusResult.getJobName() + " in the registry. Count " + jobs.size());
                 validated = false;
 
             } else  {