airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shame...@apache.org
Subject airavata git commit: Added UGE Email parser to email monitoring
Date Mon, 27 Apr 2015 19:08:43 GMT
Repository: airavata
Updated Branches:
  refs/heads/master 19d8e4954 -> ab2efea08


Added UGE Email parser to email monitoring


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

Branch: refs/heads/master
Commit: ab2efea082fdbbdd05697386b7b5351ba47f7488
Parents: 19d8e49
Author: shamrath <shameerainfo@gmail.com>
Authored: Mon Apr 27 15:08:39 2015 -0400
Committer: shamrath <shameerainfo@gmail.com>
Committed: Mon Apr 27 15:08:39 2015 -0400

----------------------------------------------------------------------
 .../gfac/monitor/email/EmailBasedMonitor.java   |  6 ++
 .../monitor/email/parser/UGEEmailParser.java    | 73 ++++++++++++++++++++
 2 files changed, 79 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/ab2efea0/modules/gfac/gfac-monitor/gfac-email-monitor/src/main/java/org/apache/airavata/gfac/monitor/email/EmailBasedMonitor.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/gfac-email-monitor/src/main/java/org/apache/airavata/gfac/monitor/email/EmailBasedMonitor.java
b/modules/gfac/gfac-monitor/gfac-email-monitor/src/main/java/org/apache/airavata/gfac/monitor/email/EmailBasedMonitor.java
index c7a3b27..97d3a3a 100644
--- a/modules/gfac/gfac-monitor/gfac-email-monitor/src/main/java/org/apache/airavata/gfac/monitor/email/EmailBasedMonitor.java
+++ b/modules/gfac/gfac-monitor/gfac-email-monitor/src/main/java/org/apache/airavata/gfac/monitor/email/EmailBasedMonitor.java
@@ -32,6 +32,7 @@ import org.apache.airavata.gfac.monitor.email.parser.EmailParser;
 import org.apache.airavata.gfac.monitor.email.parser.LSFEmailParser;
 import org.apache.airavata.gfac.monitor.email.parser.PBSEmailParser;
 import org.apache.airavata.gfac.monitor.email.parser.SLURMEmailParser;
+import org.apache.airavata.gfac.monitor.email.parser.UGEEmailParser;
 import org.apache.airavata.model.appcatalog.computeresource.ResourceJobManagerType;
 import org.apache.airavata.model.messaging.event.JobIdentifier;
 import org.apache.airavata.model.messaging.event.JobStatusChangeRequestEvent;
@@ -117,6 +118,9 @@ public class EmailBasedMonitor implements Runnable{
             case LSF:
                 emailParser = new LSFEmailParser();
                 break;
+            case UGE:
+                emailParser = new UGEEmailParser();
+                break;
             default:
                 throw new AiravataException("[EJM]: Un-handle resource job manager type:
" + jobMonitorType.toString() +" for email monitoring -->  " + addressStr);
         }
@@ -132,6 +136,8 @@ public class EmailBasedMonitor implements Runnable{
                 return ResourceJobManagerType.PBS;
             case "slurm@batch1.stampede.tacc.utexas.edu": // stampede
                 return ResourceJobManagerType.SLURM;
+            case "root <root@c341-203.ls4.tacc.utexas.edu>":
+                return ResourceJobManagerType.UGE;
 //            case "lsf":
 //                return ResourceJobManagerType.LSF;
             default:

http://git-wip-us.apache.org/repos/asf/airavata/blob/ab2efea0/modules/gfac/gfac-monitor/gfac-email-monitor/src/main/java/org/apache/airavata/gfac/monitor/email/parser/UGEEmailParser.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/gfac-email-monitor/src/main/java/org/apache/airavata/gfac/monitor/email/parser/UGEEmailParser.java
b/modules/gfac/gfac-monitor/gfac-email-monitor/src/main/java/org/apache/airavata/gfac/monitor/email/parser/UGEEmailParser.java
new file mode 100644
index 0000000..acbb485
--- /dev/null
+++ b/modules/gfac/gfac-monitor/gfac-email-monitor/src/main/java/org/apache/airavata/gfac/monitor/email/parser/UGEEmailParser.java
@@ -0,0 +1,73 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+package org.apache.airavata.gfac.monitor.email.parser;
+
+import org.apache.airavata.common.exception.AiravataException;
+import org.apache.airavata.gfac.monitor.email.JobStatusResult;
+import org.apache.airavata.model.workspace.experiment.JobState;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class UGEEmailParser implements EmailParser{
+
+    private static final Logger log = LoggerFactory.getLogger(UGEEmailParser.class);
+    private static final String REGEX = "[\\w]*[ ]*(?<"+ JOBID + ">[\\d]*)[ ]*\\((?<"
+ JOBNAME
+            + ">[a-zA-Z0-9]*)\\)[ ]*(?<" + STATUS + ">[a-zA-Z]*)";
+    public static final String STARTED = "Started";
+    public static final String COMPLETE = "Complete";
+    public static final String FAILED = "Failed";
+
+    @Override
+    public JobStatusResult parseEmail(Message message) throws MessagingException, AiravataException
{
+        JobStatusResult jobStatusResult = new JobStatusResult();
+
+        String subject = message.getSubject();
+        Pattern pattern = Pattern.compile(REGEX);
+        Matcher matcher = pattern.matcher(subject);
+        if (matcher.find()) {
+            jobStatusResult.setJobId(matcher.group(JOBID));
+            jobStatusResult.setJobName(matcher.group(JOBNAME));
+            jobStatusResult.setState(getJobState(matcher.group(STATUS)));
+        } else {
+            log.error("[EJM]: No matched found for subject => \n" + subject);
+        }
+        return jobStatusResult;
+    }
+
+    private JobState getJobState(String status) {
+        switch (status) {
+            case STARTED:
+                return JobState.ACTIVE;
+            case COMPLETE:
+                return JobState.COMPLETE;
+            case FAILED:
+                return JobState.FAILED;
+            default:
+                return JobState.UNKNOWN;
+
+        }
+    }
+}


Mime
View raw message