airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lah...@apache.org
Subject git commit: Adding more graceful shutdown operations to airavata - AIRAVATA-1072
Date Wed, 12 Mar 2014 04:55:49 GMT
Repository: airavata
Updated Branches:
  refs/heads/master 3a38bdfc3 -> 6d1797d2c


Adding more graceful shutdown operations to airavata - AIRAVATA-1072


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

Branch: refs/heads/master
Commit: 6d1797d2ca9e8841cafa26f9b256508e54df8d1f
Parents: 3a38bdf
Author: lahiru <lahiru@apache.org>
Authored: Wed Mar 12 00:55:37 2014 -0400
Committer: lahiru <lahiru@apache.org>
Committed: Wed Mar 12 00:55:37 2014 -0400

----------------------------------------------------------------------
 .../org/apache/airavata/job/monitor/MonitorID.java     |  4 +++-
 .../job/monitor/impl/pull/qstat/QstatMonitor.java      | 13 ++++++++++++-
 .../monitor/impl/pull/qstat/ResourceConnection.java    |  8 ++++++++
 .../java/org/apache/airavata/gsi/ssh/api/Cluster.java  |  6 ++++++
 .../airavata/gsi/ssh/api/job/PBSOutputParser.java      |  6 +++---
 .../airavata/gsi/ssh/api/job/SlurmOutputParser.java    |  6 +++---
 .../airavata/gsi/ssh/impl/GSISSHAbstractCluster.java   |  3 +++
 7 files changed, 38 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/6d1797d2/modules/airavata-job-monitor/src/main/java/org/apache/airavata/job/monitor/MonitorID.java
----------------------------------------------------------------------
diff --git a/modules/airavata-job-monitor/src/main/java/org/apache/airavata/job/monitor/MonitorID.java
b/modules/airavata-job-monitor/src/main/java/org/apache/airavata/job/monitor/MonitorID.java
index ffa904c..d7c3da4 100644
--- a/modules/airavata-job-monitor/src/main/java/org/apache/airavata/job/monitor/MonitorID.java
+++ b/modules/airavata-job-monitor/src/main/java/org/apache/airavata/job/monitor/MonitorID.java
@@ -181,7 +181,9 @@ public class MonitorID {
     }
 
     public void setStatus(JobState status) {
-        if (getFailedCount() > 0)
+        // this logic is going to be useful for fast finishing jobs
+        // because in some machines job state vanishes quicckly when the job is done
+        // during that case job state comes as unknown.so we handle it here.
             if (this.state != null && status.equals(JobState.UNKNOWN)) {
                 if (getFailedCount() > 2) {
                     switch (this.state) {

http://git-wip-us.apache.org/repos/asf/airavata/blob/6d1797d2/modules/airavata-job-monitor/src/main/java/org/apache/airavata/job/monitor/impl/pull/qstat/QstatMonitor.java
----------------------------------------------------------------------
diff --git a/modules/airavata-job-monitor/src/main/java/org/apache/airavata/job/monitor/impl/pull/qstat/QstatMonitor.java
b/modules/airavata-job-monitor/src/main/java/org/apache/airavata/job/monitor/impl/pull/qstat/QstatMonitor.java
index 49bae32..232d14d 100644
--- a/modules/airavata-job-monitor/src/main/java/org/apache/airavata/job/monitor/impl/pull/qstat/QstatMonitor.java
+++ b/modules/airavata-job-monitor/src/main/java/org/apache/airavata/job/monitor/impl/pull/qstat/QstatMonitor.java
@@ -70,7 +70,7 @@ public class QstatMonitor extends PullMonitor {
         monitoring
          */
         this.startPulling = true;
-        while (this.startPulling || !ServerSettings.isStopAllThreads()) {
+        while (this.startPulling && !ServerSettings.isStopAllThreads()) {
             try {
                 startPulling();
                 // After finishing one iteration of the full queue this thread sleeps 1 second
@@ -83,6 +83,17 @@ public class QstatMonitor extends PullMonitor {
                 logger.error(e.getMessage());
             }
         }
+        // thread is going to return so we close all the connections
+        Iterator<String> iterator = connections.keySet().iterator();
+        while(iterator.hasNext()){
+            String next = iterator.next();
+            ResourceConnection resourceConnection = connections.get(next);
+            try {
+                resourceConnection.getCluster().disconnect();
+            } catch (SSHApiException e) {
+                e.printStackTrace();  //To change body of catch statement use File | Settings
| File Templates.
+            }
+        }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/airavata/blob/6d1797d2/modules/airavata-job-monitor/src/main/java/org/apache/airavata/job/monitor/impl/pull/qstat/ResourceConnection.java
----------------------------------------------------------------------
diff --git a/modules/airavata-job-monitor/src/main/java/org/apache/airavata/job/monitor/impl/pull/qstat/ResourceConnection.java
b/modules/airavata-job-monitor/src/main/java/org/apache/airavata/job/monitor/impl/pull/qstat/ResourceConnection.java
index 6463583..821cd19 100644
--- a/modules/airavata-job-monitor/src/main/java/org/apache/airavata/job/monitor/impl/pull/qstat/ResourceConnection.java
+++ b/modules/airavata-job-monitor/src/main/java/org/apache/airavata/job/monitor/impl/pull/qstat/ResourceConnection.java
@@ -97,4 +97,12 @@ public class ResourceConnection {
         }
         return JobState.UNKNOWN;
     }
+
+    public PBSCluster getCluster() {
+        return cluster;
+    }
+
+    public void setCluster(PBSCluster cluster) {
+        this.cluster = cluster;
+    }
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/6d1797d2/tools/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/Cluster.java
----------------------------------------------------------------------
diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/Cluster.java b/tools/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/Cluster.java
index edea8aa..ee5dcf7 100644
--- a/tools/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/Cluster.java
+++ b/tools/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/Cluster.java
@@ -102,5 +102,11 @@ public interface Cluster {
     public JobStatus getJobStatus(String jobID) throws SSHApiException;
 
 
+    /**
+     * This method can be used to close the connections initialized
+     * to handle graceful shutdown of the system
+     * @throws SSHApiException
+     */
+    public void disconnect() throws SSHApiException;
 
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/6d1797d2/tools/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/job/PBSOutputParser.java
----------------------------------------------------------------------
diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/job/PBSOutputParser.java
b/tools/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/job/PBSOutputParser.java
index 335bbf2..1a4fb21 100644
--- a/tools/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/job/PBSOutputParser.java
+++ b/tools/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/job/PBSOutputParser.java
@@ -31,7 +31,7 @@ public class PBSOutputParser implements OutputParser {
     private static final Logger log = LoggerFactory.getLogger(PBSOutputParser.class);
 
     public void parse(JobDescriptor jobDescriptor, String rawOutput) {
-        log.info(rawOutput);
+        log.debug(rawOutput);
         String[] info = rawOutput.split("\n");
         String[] line;
         for (int i = 0; i < info.length; i++) {
@@ -117,13 +117,13 @@ public class PBSOutputParser implements OutputParser {
     }
 
     public String parse(String rawOutput) {
-        log.info(rawOutput);
+        log.debug(rawOutput);
         return rawOutput;  //In PBS stdout is going to be directly the jobID
     }
 
     public JobStatus parse(String jobID, String rawOutput) {
         boolean jobFount = false;
-        log.info(rawOutput);
+        log.debug(rawOutput);
         String[] info = rawOutput.split("\n");
         String[] line = null;
         int index = 0;

http://git-wip-us.apache.org/repos/asf/airavata/blob/6d1797d2/tools/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/job/SlurmOutputParser.java
----------------------------------------------------------------------
diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/job/SlurmOutputParser.java
b/tools/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/job/SlurmOutputParser.java
index 4fffc32..69b64c0 100644
--- a/tools/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/job/SlurmOutputParser.java
+++ b/tools/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/job/SlurmOutputParser.java
@@ -30,7 +30,7 @@ import java.util.Map;
 public class SlurmOutputParser implements OutputParser {
     private static final Logger log = LoggerFactory.getLogger(PBSOutputParser.class);
     public void parse(JobDescriptor descriptor, String rawOutput) {
-        log.info(rawOutput);
+        log.debug(rawOutput);
         String[] info = rawOutput.split("\n");
         String lastString = info[info.length -1];
         if (lastString.contains("JOB ID")) {
@@ -90,7 +90,7 @@ public class SlurmOutputParser implements OutputParser {
      * @return
      */
     public String parse(String rawOutput) {
-        log.info(rawOutput);
+        log.debug(rawOutput);
         String[] info = rawOutput.split("\n");
         for (String anInfo : info) {
             if (anInfo.contains("Submitted batch job")) {
@@ -102,7 +102,7 @@ public class SlurmOutputParser implements OutputParser {
     }
 
     public JobStatus parse(String jobID, String rawOutput) {
-        log.info(rawOutput);
+        log.debug(rawOutput);
         String[] info = rawOutput.split("\n");
         String lastString = info[info.length -1];
         if (lastString.contains("JOBID") || lastString.contains("PARTITION")) {

http://git-wip-us.apache.org/repos/asf/airavata/blob/6d1797d2/tools/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/GSISSHAbstractCluster.java
----------------------------------------------------------------------
diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/GSISSHAbstractCluster.java
b/tools/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/GSISSHAbstractCluster.java
index 1bd68d9..c6866c0 100644
--- a/tools/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/GSISSHAbstractCluster.java
+++ b/tools/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/GSISSHAbstractCluster.java
@@ -414,4 +414,7 @@ public class GSISSHAbstractCluster implements Cluster {
         return stdOutputString;
     }
 
+    public void disconnect() throws SSHApiException {
+        getSession().disconnect();
+    }
 }


Mime
View raw message