airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dimuthu...@apache.org
Subject [airavata] branch staging updated: Handling exceptions when fetching job status
Date Thu, 10 Jan 2019 16:40:16 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/staging by this push:
     new e61bcbb  Handling exceptions when fetching job status
e61bcbb is described below

commit e61bcbb9d3f4786fb6d9005408483152f31ce815
Author: Dimuthu Wannipurage <dimuthu.upeksha2@gmail.com>
AuthorDate: Thu Jan 10 11:40:02 2019 -0500

    Handling exceptions when fetching job status
---
 .../task/submission/DefaultJobSubmissionTask.java  | 12 +++++--
 .../impl/task/submission/JobSubmissionTask.java    | 42 +++++++++++++++++-----
 2 files changed, 43 insertions(+), 11 deletions(-)

diff --git a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/submission/DefaultJobSubmissionTask.java
b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/submission/DefaultJobSubmissionTask.java
index bb7546e..95d16be 100644
--- a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/submission/DefaultJobSubmissionTask.java
+++ b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/submission/DefaultJobSubmissionTask.java
@@ -222,8 +222,14 @@ public class DefaultJobSubmissionTask extends JobSubmissionTask {
         }
     }
 
-    private boolean verifyJobSubmissionByJobId(AgentAdaptor agentAdaptor, String jobID) throws
Exception {
-        JobStatus status = getJobStatus(agentAdaptor, jobID);
+    private boolean verifyJobSubmissionByJobId(AgentAdaptor agentAdaptor, String jobID) {
+        JobStatus status = null;
+
+        try {
+            status = getJobStatus(agentAdaptor, jobID);
+        } catch (Exception e) {
+            logger.warn("Error while fetching the job status for id " + jobID);
+        }
         return status != null &&  status.getJobState() != JobState.UNKNOWN;
     }
 
@@ -232,7 +238,7 @@ public class DefaultJobSubmissionTask extends JobSubmissionTask {
         try {
             jobId  = getJobIdByJobName(agentAdaptor, jobName, userName);
         } catch (Exception e) {
-            logger.error("Error while verifying JobId from JobName " + jobName);
+            logger.warn("Error while verifying JobId from JobName " + jobName);
         }
         return jobId;
     }
diff --git a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/submission/JobSubmissionTask.java
b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/submission/JobSubmissionTask.java
index e36c726..5793e15 100644
--- a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/submission/JobSubmissionTask.java
+++ b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/submission/JobSubmissionTask.java
@@ -32,6 +32,7 @@ import org.apache.airavata.helix.impl.task.submission.config.JobFactory;
 import org.apache.airavata.helix.impl.task.submission.config.JobManagerConfiguration;
 import org.apache.airavata.helix.impl.task.submission.config.RawCommandInfo;
 import org.apache.airavata.messaging.core.MessageContext;
+import org.apache.airavata.model.appcatalog.computeresource.ResourceJobManager;
 import org.apache.airavata.model.job.JobModel;
 import org.apache.airavata.model.messaging.event.JobIdentifier;
 import org.apache.airavata.model.messaging.event.JobStatusChangeEvent;
@@ -40,7 +41,6 @@ import org.apache.airavata.model.status.JobStatus;
 import org.apache.commons.io.FileUtils;
 import org.apache.helix.HelixManager;
 import org.apache.thrift.TException;
-import org.apache.zookeeper.CreateMode;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -157,6 +157,7 @@ public abstract class JobSubmissionTask extends AiravataTask {
         return new File(outputPath + getProcessId());
     }
 
+    @SuppressWarnings("WeakerAccess")
     public boolean cancelJob(AgentAdaptor agentAdaptor, String jobId) throws Exception {
         JobManagerConfiguration jobManagerConfiguration = JobFactory.getJobManagerConfiguration(JobFactory.getResourceJobManager(
                 getRegistryServiceClient(), getTaskContext().getJobSubmissionProtocol(),
getTaskContext().getPreferredJobSubmissionInterface()));
@@ -165,19 +166,44 @@ public abstract class JobSubmissionTask extends AiravataTask {
     }
 
     @SuppressWarnings("WeakerAccess")
-    public JobStatus getJobStatus(AgentAdaptor agentAdaptor, String jobIc) throws Exception
{
-        JobManagerConfiguration jobManagerConfiguration = JobFactory.getJobManagerConfiguration(JobFactory.getResourceJobManager(
-                getRegistryServiceClient(), getTaskContext().getJobSubmissionProtocol(),
getTaskContext().getPreferredJobSubmissionInterface()));
-        CommandOutput commandOutput = agentAdaptor.executeCommand(jobManagerConfiguration.getMonitorCommand(jobIc).getRawCommand(),
null);
+    public JobStatus getJobStatus(AgentAdaptor agentAdaptor, String jobId) throws Exception
{
+
+        ResourceJobManager resourceJobManager = JobFactory.getResourceJobManager(
+                getRegistryServiceClient(), getTaskContext().getJobSubmissionProtocol(),
getTaskContext().getPreferredJobSubmissionInterface());
+
+        if (resourceJobManager == null) {
+            throw new Exception("Resource job manager can not be null for protocol " + getTaskContext().getJobSubmissionProtocol()
+ " and job id " + jobId);
+        }
+
+        JobManagerConfiguration jobManagerConfiguration = JobFactory.getJobManagerConfiguration(resourceJobManager);
+
+        if (jobManagerConfiguration == null) {
+            throw new Exception("Job manager configuration can not be null for protocol "
+ getTaskContext().getJobSubmissionProtocol() + " and job id " + jobId);
+        }
 
-        return jobManagerConfiguration.getParser().parseJobStatus(jobIc, commandOutput.getStdOut());
+        CommandOutput commandOutput = agentAdaptor.executeCommand(jobManagerConfiguration.getMonitorCommand(jobId).getRawCommand(),
null);
+
+        return jobManagerConfiguration.getParser().parseJobStatus(jobId, commandOutput.getStdOut());
 
     }
 
     @SuppressWarnings("WeakerAccess")
     public String getJobIdByJobName(AgentAdaptor agentAdaptor, String jobName, String userName)
throws Exception {
-        JobManagerConfiguration jobManagerConfiguration = JobFactory.getJobManagerConfiguration(JobFactory.getResourceJobManager(
-                getRegistryServiceClient(), getTaskContext().getJobSubmissionProtocol(),
getTaskContext().getPreferredJobSubmissionInterface()));
+
+        ResourceJobManager resourceJobManager = JobFactory.getResourceJobManager(
+                getRegistryServiceClient(), getTaskContext().getJobSubmissionProtocol(),
getTaskContext().getPreferredJobSubmissionInterface());
+
+        if (resourceJobManager == null) {
+            throw new Exception("Resource job manager can not be null for protocol " + getTaskContext().getJobSubmissionProtocol()
+                    + " and job name " + jobName + " and user " + userName);
+        }
+
+        JobManagerConfiguration jobManagerConfiguration = JobFactory.getJobManagerConfiguration(resourceJobManager);
+
+        if (jobManagerConfiguration == null) {
+            throw new Exception("Job manager configuration can not be null for protocol "
+                    + getTaskContext().getJobSubmissionProtocol() + " and job name " + jobName
+ " and user " + userName);
+        }
 
         RawCommandInfo jobIdMonitorCommand = jobManagerConfiguration.getJobIdMonitorCommand(jobName,
userName);
         CommandOutput commandOutput = agentAdaptor.executeCommand(jobIdMonitorCommand.getRawCommand(),
null);


Mime
View raw message