You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by la...@apache.org on 2014/03/31 15:54:39 UTC

[3/3] git commit: Fixing a NPE during error scenario and fixing the code to show proper error message

Fixing a NPE during error scenario and fixing the code to show proper error message


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/80cbc3e8
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/80cbc3e8
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/80cbc3e8

Branch: refs/heads/master
Commit: 80cbc3e884cbc4f0609d5ff216b59430fee0abaf
Parents: d68afe9
Author: lahiru <la...@apache.org>
Authored: Mon Mar 31 09:54:30 2014 -0400
Committer: lahiru <la...@apache.org>
Committed: Mon Mar 31 09:54:30 2014 -0400

----------------------------------------------------------------------
 .../monitor/impl/pull/qstat/QstatMonitor.java   | 26 +++++++++++++-------
 1 file changed, 17 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/80cbc3e8/tools/job-monitor/src/main/java/org/apache/airavata/job/monitor/impl/pull/qstat/QstatMonitor.java
----------------------------------------------------------------------
diff --git a/tools/job-monitor/src/main/java/org/apache/airavata/job/monitor/impl/pull/qstat/QstatMonitor.java b/tools/job-monitor/src/main/java/org/apache/airavata/job/monitor/impl/pull/qstat/QstatMonitor.java
index 1a098da..59de0f4 100644
--- a/tools/job-monitor/src/main/java/org/apache/airavata/job/monitor/impl/pull/qstat/QstatMonitor.java
+++ b/tools/job-monitor/src/main/java/org/apache/airavata/job/monitor/impl/pull/qstat/QstatMonitor.java
@@ -21,6 +21,7 @@
 package org.apache.airavata.job.monitor.impl.pull.qstat;
 
 import org.apache.airavata.common.utils.ServerSettings;
+import org.apache.airavata.commons.gfac.type.HostDescription;
 import org.apache.airavata.gsi.ssh.api.SSHApiException;
 import org.apache.airavata.job.monitor.HostMonitorData;
 import org.apache.airavata.job.monitor.MonitorID;
@@ -109,12 +110,14 @@ public class QstatMonitor extends PullMonitor {
         UserMonitorData take = null;
         JobStatus jobStatus = new JobStatus();
         MonitorID currentMonitorID = null;
+        HostDescription currentHostDescription = null;
         try {
             take = this.queue.take();
             List<MonitorID> completedJobs = new ArrayList<MonitorID>();
             List<HostMonitorData> hostMonitorData = take.getHostMonitorData();
             for (HostMonitorData iHostMonitorData : hostMonitorData) {
                 if (iHostMonitorData.getHost().getType() instanceof GsisshHostType) {
+                    currentHostDescription = iHostMonitorData.getHost();
                     GsisshHostType gsisshHostType = (GsisshHostType) iHostMonitorData.getHost().getType();
                     String hostName = gsisshHostType.getHostAddress();
                     ResourceConnection connection = null;
@@ -183,16 +186,21 @@ public class QstatMonitor extends PullMonitor {
             } else if (e.getMessage().contains("illegally formed job identifier")) {
                 logger.error("Wrong job ID is given so dropping the job from monitoring system");
             } else if (!this.queue.contains(take)) {   // we put the job back to the queue only if its state is not unknown
-                if (currentMonitorID.getFailedCount() < 2) {
-                    try {
-                        currentMonitorID.setFailedCount(currentMonitorID.getFailedCount() + 1);
-                        this.queue.put(take);
-                    } catch (InterruptedException e1) {
-                        e1.printStackTrace();
-                    }
+                if (currentMonitorID == null) {
+                    logger.error("Monitoring the jobs failed, for user: " + take.getUserName()
+                            + " in Host: " + currentHostDescription.getType().getHostAddress());
                 } else {
-                    logger.error(e.getMessage());
-                    logger.error("Tried to monitor the job 3 times, so dropping of the the Job with ID: " + currentMonitorID.getJobID());
+                    if (currentMonitorID.getFailedCount() < 2) {
+                        try {
+                            currentMonitorID.setFailedCount(currentMonitorID.getFailedCount() + 1);
+                            this.queue.put(take);
+                        } catch (InterruptedException e1) {
+                            e1.printStackTrace();
+                        }
+                    } else {
+                        logger.error(e.getMessage());
+                        logger.error("Tried to monitor the job 3 times, so dropping of the the Job with ID: " + currentMonitorID.getJobID());
+                    }
                 }
             }
             throw new AiravataMonitorException("Error retrieving the job status", e);