airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shame...@apache.org
Subject airavata git commit: Simplified jobStatus parsing logic with Regex matching.
Date Thu, 14 May 2015 16:34:45 GMT
Repository: airavata
Updated Branches:
  refs/heads/master 5ee2559b4 -> cc19eed94


Simplified jobStatus parsing logic with Regex matching.


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

Branch: refs/heads/master
Commit: cc19eed947797706f151d4bce222ca9cb195b14d
Parents: 5ee2559
Author: shamrath <shameerainfo@gmail.com>
Authored: Thu May 14 12:34:43 2015 -0400
Committer: shamrath <shameerainfo@gmail.com>
Committed: Thu May 14 12:34:43 2015 -0400

----------------------------------------------------------------------
 .../gfac/ssh/provider/impl/SSHProvider.java     |  3 +-
 .../gsi/ssh/api/job/SlurmOutputParser.java      | 43 +++-----------------
 2 files changed, 8 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/cc19eed9/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/ssh/provider/impl/SSHProvider.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/ssh/provider/impl/SSHProvider.java
b/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/ssh/provider/impl/SSHProvider.java
index 415b632..e8e2dc3 100644
--- a/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/ssh/provider/impl/SSHProvider.java
+++ b/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/ssh/provider/impl/SSHProvider.java
@@ -220,7 +220,8 @@ public class SSHProvider extends AbstractProvider {
     }
 
     private boolean verifyJobSubmissionByJobId(Cluster cluster, String jobID) throws SSHApiException
{
-        return cluster.getJobStatus(jobID) != null;
+        JobStatus status = cluster.getJobStatus(jobID);
+        return status != null &&  status != JobStatus.U;
     }
 
     private String verifyJobSubmission(Cluster cluster, JobDetails jobDetails) {

http://git-wip-us.apache.org/repos/asf/airavata/blob/cc19eed9/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 b8a6b6d..1d6495b 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
@@ -34,6 +34,7 @@ import java.util.regex.Pattern;
 public class SlurmOutputParser implements OutputParser {
     private static final Logger log = LoggerFactory.getLogger(SlurmOutputParser.class);
     public static final int JOB_NAME_OUTPUT_LENGTH = 8;
+    public static final String STATUS = "status";
 
     public void parseSingleJob(JobDescriptor descriptor, String rawOutput) throws SSHApiException
{
         log.info(rawOutput);
@@ -110,44 +111,12 @@ public class SlurmOutputParser implements OutputParser {
 
     public JobStatus parseJobStatus(String jobID, String rawOutput) throws SSHApiException
{
         log.info(rawOutput);
-        String[] info = rawOutput.split("\n");
-        String lastString = info[info.length - 1];
-        if (lastString.contains("JOBID") || lastString.contains("PARTITION")) {
-            // because there's no state
-            return JobStatus.valueOf("U");
-        } else {
-            int column = 0;
-            for (String each : lastString.split(" ")) {
-                if (!each.trim().isEmpty()) {
-                    switch (column) {
-                        case 0:
-                            column++;
-                            break;
-                        case 1:
-                            column++;
-                            break;
-                        case 2:
-                            column++;
-                            break;
-                        case 3:
-                            column++;
-                            break;
-                        case 4:
-                            return JobStatus.valueOf((each));
-                        case 5:
-                            column++;
-                            break;
-                        case 6:
-                            column++;
-                            break;
-                        case 7:
-                            column++;
-                            break;
-                    }
-                }
-            }
+        Pattern pattern = Pattern.compile(jobID + "(?=\\s+\\S+\\s+\\S+\\s+\\S+\\s+(?<"
+ STATUS + ">\\w+))");
+        Matcher matcher = pattern.matcher(rawOutput);
+        if (matcher.find()) {
+            return JobStatus.valueOf(matcher.group(STATUS));
         }
-        return JobStatus.valueOf("U");
+        return null;
     }
 
     public void parseJobStatuses(String userName, Map<String, JobStatus> statusMap,
String rawOutput) throws SSHApiException {


Mime
View raw message