airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shame...@apache.org
Subject airavata git commit: identify Resource job monitor type by sender email address
Date Fri, 24 Apr 2015 04:19:25 GMT
Repository: airavata
Updated Branches:
  refs/heads/master 775122015 -> c22f21db4


identify Resource job monitor type by sender email address


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

Branch: refs/heads/master
Commit: c22f21db404c8e0f2d5d9ee4fbe84b6334465efb
Parents: 7751220
Author: shamrath <shameerainfo@gmail.com>
Authored: Fri Apr 24 00:19:23 2015 -0400
Committer: shamrath <shameerainfo@gmail.com>
Committed: Fri Apr 24 00:19:23 2015 -0400

----------------------------------------------------------------------
 .../gfac/monitor/email/EmailBasedMonitor.java   | 26 ++++++++++++++------
 1 file changed, 19 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/c22f21db/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 3d5c8f9..5a28c7b 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
@@ -20,6 +20,7 @@
 */
 package org.apache.airavata.gfac.monitor.email;
 
+import org.apache.aiaravata.application.catalog.data.model.ResourceJobManager;
 import org.apache.airavata.common.exception.AiravataException;
 import org.apache.airavata.common.exception.ApplicationSettingsException;
 import org.apache.airavata.common.logger.AiravataLogger;
@@ -46,12 +47,9 @@ import javax.mail.Message;
 import javax.mail.MessagingException;
 import javax.mail.Session;
 import javax.mail.Store;
-import javax.mail.search.AndTerm;
 import javax.mail.search.FlagTerm;
-import javax.mail.search.ReceivedDateTerm;
 import javax.mail.search.SearchTerm;
 import java.util.ArrayList;
-import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
@@ -70,13 +68,11 @@ public class EmailBasedMonitor implements Runnable{
     private Store store;
     private Folder emailFolder;
     private Properties properties;
-    private final ResourceJobManagerType RESOURCE_JOB_MONITOR_TYPE;
     private Map<String, JobExecutionContext> jobMonitorMap = new ConcurrentHashMap<String,
JobExecutionContext>();
     private String host, emailAddress, password, storeProtocol, folderName ;
     private Date monitorStartDate;
 
     public EmailBasedMonitor(ResourceJobManagerType type) throws AiravataException {
-        RESOURCE_JOB_MONITOR_TYPE = type;
         init();
     }
 
@@ -107,7 +103,8 @@ public class EmailBasedMonitor implements Runnable{
         Address fromAddress = message.getFrom()[0];
         EmailParser emailParser;
         String addressStr = fromAddress.toString();
-        switch (RESOURCE_JOB_MONITOR_TYPE) {
+        ResourceJobManagerType jobMonitorType = getJobMonitorType(addressStr);
+        switch (jobMonitorType) {
             case PBS:
                 emailParser = new PBSEmailParser();
                 break;
@@ -118,11 +115,26 @@ public class EmailBasedMonitor implements Runnable{
                 emailParser = new LSFEmailParser();
                 break;
             default:
-                throw new AiravataException("Un-handle resource job manager type: "+ RESOURCE_JOB_MONITOR_TYPE
+ " for email monitoring -->  " + addressStr);
+                throw new AiravataException("Un-handle resource job manager type: " + jobMonitorType.toString()
+" for email monitoring -->  " + addressStr);
         }
         return emailParser.parseEmail(message);
     }
 
+    private ResourceJobManagerType getJobMonitorType(String addressStr) throws AiravataException
{
+        switch (addressStr) {
+            case "pbsconsult@sdsc.edu":
+            case "adm@trident.bigred2.uits.iu.edu":
+                return ResourceJobManagerType.PBS;
+            case "slurm@batch1.stampede.tacc.utexas.edu":
+                return ResourceJobManagerType.SLURM;
+//            case "lsf":
+//                return ResourceJobManagerType.LSF;
+            default:
+                throw new AiravataException("Couldn't identify Resource job manager type
from address " + addressStr);
+        }
+
+    }
+
     @Override
     public void run() {
         try {


Mime
View raw message