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 job notify email to job detail object
Date Fri, 24 Apr 2015 03:00:21 GMT
Repository: airavata
Updated Branches:
  refs/heads/master f76a4a045 -> 52a6fda3b


Added job notify email to job detail object


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

Branch: refs/heads/master
Commit: 52a6fda3b4e649a2d880cb69b88d71561721796a
Parents: f76a4a0
Author: shamrath <shameerainfo@gmail.com>
Authored: Thu Apr 23 23:00:15 2015 -0400
Committer: shamrath <shameerainfo@gmail.com>
Committed: Thu Apr 23 23:00:15 2015 -0400

----------------------------------------------------------------------
 .../gsissh/provider/impl/GSISSHProvider.java    |  2 +-
 .../gfac/ssh/provider/impl/SSHProvider.java     |  2 +-
 .../airavata/gfac/ssh/util/GFACSSHUtils.java    | 73 +++++++++++++-------
 3 files changed, 49 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/52a6fda3/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/gsissh/provider/impl/GSISSHProvider.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/gsissh/provider/impl/GSISSHProvider.java
b/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/gsissh/provider/impl/GSISSHProvider.java
index 29287cc..1b0d283 100644
--- a/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/gsissh/provider/impl/GSISSHProvider.java
+++ b/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/gsissh/provider/impl/GSISSHProvider.java
@@ -155,7 +155,7 @@ public class GSISSHProvider extends AbstractRecoverableProvider {
                             sshJobSubmission.getResourceJobManager().getResourceJobManagerType());
                     emailBasedMonitor.addToJobMonitorMap(jobExecutionContext);
                 } catch (AiravataException e) {
-                    log.error("Couldn't active email monitoring, Error while initializing
Email Based Monitor", e);
+                    throw new GFacHandlerException("Error while activating email job monitoring
", e);
                 }
                 return;
             }

http://git-wip-us.apache.org/repos/asf/airavata/blob/52a6fda3/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 0df72f8..7023e3c 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
@@ -395,7 +395,7 @@ public class SSHProvider extends AbstractRecoverableProvider {
                             sshJobSubmission.getResourceJobManager().getResourceJobManagerType());
                     emailBasedMonitor.addToJobMonitorMap(jobExecutionContext);
                 } catch (AiravataException e) {
-                    log.error("Couldn't active email monitoring, Error while initializing
Email Based Monitor", e);
+                    throw new GFacHandlerException("Error while activating email job monitoring
", e);
                 }
                 return;
             }

http://git-wip-us.apache.org/repos/asf/airavata/blob/52a6fda3/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/ssh/util/GFACSSHUtils.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/ssh/util/GFACSSHUtils.java
b/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/ssh/util/GFACSSHUtils.java
index c04aecb..3129ac0 100644
--- a/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/ssh/util/GFACSSHUtils.java
+++ b/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/ssh/util/GFACSSHUtils.java
@@ -279,40 +279,50 @@ public class GFACSSHUtils {
     }
 
 
-    public static JobDescriptor createJobDescriptor(JobExecutionContext jobExecutionContext,
Cluster cluster) {
+    public static JobDescriptor createJobDescriptor(JobExecutionContext jobExecutionContext,
Cluster cluster) throws AppCatalogException, ApplicationSettingsException {
         JobDescriptor jobDescriptor = new JobDescriptor();
         TaskDetails taskData = jobExecutionContext.getTaskData();
 
 
-        try {
-			if(ServerSettings.getSetting(ServerSettings.JOB_NOTIFICATION_ENABLE).equalsIgnoreCase("true"))
{
-                String flags = ServerSettings.getSetting(ServerSettings.JOB_NOTIFICATION_FLAGS);
-                if (flags != null && jobExecutionContext.getApplicationContext().getComputeResourceDescription().getHostName().equals("stampede.tacc.xsede.org"))
{
-                    flags = "ALL";
+        // set email based job monitoring email  address if monitor mode is JOB_EMAIL_NOTIFICATION_MONITOR
+        boolean addJobNotifMail = isEmailBasedJobMonitor(jobExecutionContext);
+        String emailIds = null;
+        if (addJobNotifMail) {
+            emailIds = ServerSettings.getEmailBasedMonitorAddress();
+        }
+        // add all configured job notification email addresses.
+        if (ServerSettings.getSetting(ServerSettings.JOB_NOTIFICATION_ENABLE).equalsIgnoreCase("true"))
{
+            String flags = ServerSettings.getSetting(ServerSettings.JOB_NOTIFICATION_FLAGS);
+            if (flags != null && jobExecutionContext.getApplicationContext().getComputeResourceDescription().getHostName().equals("stampede.tacc.xsede.org"))
{
+                flags = "ALL";
+            }
+            jobDescriptor.setMailOptions(flags);
+
+            String userJobNotifEmailIds = ServerSettings.getSetting(ServerSettings.JOB_NOTIFICATION_EMAILIDS);
+            if (userJobNotifEmailIds != null && !userJobNotifEmailIds.isEmpty())
{
+                if (emailIds != null && !emailIds.isEmpty()) {
+                    emailIds += (", " + userJobNotifEmailIds);
+                } else {
+                    emailIds = userJobNotifEmailIds;
                 }
-                jobDescriptor.setMailOptions(flags);
-
-                String emailids = ServerSettings.getSetting(ServerSettings.JOB_NOTIFICATION_EMAILIDS);
-
-                if (taskData.isEnableEmailNotification()) {
-                    List<String> emailList = jobExecutionContext.getTaskData().getEmailAddresses();
-                    String elist = GFacUtils.listToCsv(emailList, ',');
-                    if (elist != null && !elist.isEmpty()) {
-                        if (emailids != null && !emailids.isEmpty()) {
-                            emailids = emailids + "," + elist;
-                        } else {
-                            emailids = elist;
-                        }
+            }
+
+            if (taskData.isEnableEmailNotification()) {
+                List<String> emailList = jobExecutionContext.getTaskData().getEmailAddresses();
+                String elist = GFacUtils.listToCsv(emailList, ',');
+                if (elist != null && !elist.isEmpty()) {
+                    if (emailIds != null && !emailIds.isEmpty()) {
+                        emailIds = emailIds + "," + elist;
+                    } else {
+                        emailIds = elist;
                     }
                 }
-                if (emailids != null && !emailids.isEmpty()) {
-                    logger.info("Email list: " + emailids);
-                    jobDescriptor.setMailAddress(emailids);
-                }
             }
-        } catch (ApplicationSettingsException e) {
-			 logger.error("ApplicationSettingsException : " +e.getLocalizedMessage());
-		}
+            if (emailIds != null && !emailIds.isEmpty()) {
+                logger.info("Email list: " + emailIds);
+                jobDescriptor.setMailAddress(emailIds);
+            }
+        }
         // this is common for any application descriptor
 
         jobDescriptor.setCallBackIp(ServerSettings.getIp());
@@ -480,6 +490,17 @@ public class GFACSSHUtils {
         return jobDescriptor;
     }
 
+    public static boolean isEmailBasedJobMonitor(JobExecutionContext jobExecutionContext)
throws AppCatalogException {
+        if (jobExecutionContext.getPreferredJobSubmissionProtocol() == JobSubmissionProtocol.SSH)
{
+            String jobSubmissionInterfaceId = jobExecutionContext.getPreferredJobSubmissionInterface().getJobSubmissionInterfaceId();
+            SSHJobSubmission sshJobSubmission = jobExecutionContext.getAppCatalog().getComputeResource().getSSHJobSubmission(jobSubmissionInterfaceId);
+            MonitorMode monitorMode = sshJobSubmission.getMonitorMode();
+            return monitorMode != null && monitorMode == MonitorMode.JOB_EMAIL_NOTIFICATION_MONITOR;
+        } else {
+            return false;
+        }
+    }
+
     private static int generateJobName() {
         Random random = new Random();
         int i = random.nextInt(Integer.MAX_VALUE);


Mime
View raw message