You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by la...@apache.org on 2012/05/23 19:48:35 UTC

svn commit: r1341959 - in /incubator/airavata/branches/0.3-incubating-snapshot/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac: GfacAPI.java notification/impl/WorkflowTrackingNotification.java provider/impl/GramProvider.java

Author: lahiru
Date: Wed May 23 17:48:34 2012
New Revision: 1341959

URL: http://svn.apache.org/viewvc?rev=1341959&view=rev
Log:
committing the trunk commit 1341958 back to branch.

Modified:
    incubator/airavata/branches/0.3-incubating-snapshot/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/GfacAPI.java
    incubator/airavata/branches/0.3-incubating-snapshot/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/impl/WorkflowTrackingNotification.java
    incubator/airavata/branches/0.3-incubating-snapshot/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/impl/GramProvider.java

Modified: incubator/airavata/branches/0.3-incubating-snapshot/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/GfacAPI.java
URL: http://svn.apache.org/viewvc/incubator/airavata/branches/0.3-incubating-snapshot/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/GfacAPI.java?rev=1341959&r1=1341958&r2=1341959&view=diff
==============================================================================
--- incubator/airavata/branches/0.3-incubating-snapshot/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/GfacAPI.java (original)
+++ incubator/airavata/branches/0.3-incubating-snapshot/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/GfacAPI.java Wed May 23 17:48:34 2012
@@ -20,6 +20,7 @@
 */
 package org.apache.airavata.core.gfac;
 
+import org.apache.airavata.common.workflow.execution.context.WorkflowContextHeaderBuilder;
 import org.apache.airavata.commons.gfac.type.ActualParameter;
 import org.apache.airavata.commons.gfac.type.ServiceDescription;
 import org.apache.airavata.core.gfac.context.GFacConfiguration;
@@ -47,7 +48,10 @@ public class GfacAPI {
     public static final String REPOSITORY_PROPERTIES = "repository.properties";
 
     public DefaultInvocationContext gridJobSubmit(JobContext jobContext,GFacConfiguration gfacConfig) throws Exception {
-        WorkflowTrackingNotification workflowNotification = new WorkflowTrackingNotification(jobContext.getBrokerURL(), jobContext.getTopic());
+        String workflowNodeId = WorkflowContextHeaderBuilder.getCurrentContextHeader().getWorkflowMonitoringContext().getWorkflowNodeId();
+        String workflowInstanceId = WorkflowContextHeaderBuilder.getCurrentContextHeader().getWorkflowMonitoringContext().getWorkflowInstanceId();
+        WorkflowTrackingNotification workflowNotification = new WorkflowTrackingNotification(jobContext.getBrokerURL(),
+                jobContext.getTopic(),workflowNodeId,workflowInstanceId);
         LoggingNotification loggingNotification = new LoggingNotification();
         DefaultInvocationContext invocationContext = new DefaultInvocationContext();
         invocationContext.setExecutionContext(new DefaultExecutionContext());

Modified: incubator/airavata/branches/0.3-incubating-snapshot/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/impl/WorkflowTrackingNotification.java
URL: http://svn.apache.org/viewvc/incubator/airavata/branches/0.3-incubating-snapshot/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/impl/WorkflowTrackingNotification.java?rev=1341959&r1=1341958&r2=1341959&view=diff
==============================================================================
--- incubator/airavata/branches/0.3-incubating-snapshot/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/impl/WorkflowTrackingNotification.java (original)
+++ incubator/airavata/branches/0.3-incubating-snapshot/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/impl/WorkflowTrackingNotification.java Wed May 23 17:48:34 2012
@@ -53,15 +53,15 @@ public class WorkflowTrackingNotificatio
 
     private org.apache.airavata.workflow.tracking.common.InvocationContext invocationContext;
 
-    public WorkflowTrackingNotification(String brokerURL, String topic) {
+    public WorkflowTrackingNotification(String brokerURL, String topic,String workflowNodeID,String workflowID) {
         this.topic = topic;
         this.workflowID = URI.create(this.topic);
         Properties props = new Properties();
 
         this.notifier = NotifierFactory.createNotifier();
-        URI initiatorWorkflowID = null;
+        URI initiatorWorkflowID = URI.create(workflowID);
         URI initiatorServiceID = URI.create(topic);
-        String initiatorWorkflowNodeID = null;
+        String initiatorWorkflowNodeID = workflowNodeID;
         Integer initiatorWorkflowTimeStep = null;
         this.context = this.notifier.createTrackingContext(props, brokerURL, initiatorWorkflowID, initiatorServiceID,
                 initiatorWorkflowNodeID, initiatorWorkflowTimeStep);

Modified: incubator/airavata/branches/0.3-incubating-snapshot/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/impl/GramProvider.java
URL: http://svn.apache.org/viewvc/incubator/airavata/branches/0.3-incubating-snapshot/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/impl/GramProvider.java?rev=1341959&r1=1341958&r2=1341959&view=diff
==============================================================================
--- incubator/airavata/branches/0.3-incubating-snapshot/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/impl/GramProvider.java (original)
+++ incubator/airavata/branches/0.3-incubating-snapshot/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/impl/GramProvider.java Wed May 23 17:48:34 2012
@@ -203,6 +203,21 @@ public class GramProvider extends Abstra
              * Fail job
              */
             int jobStatus = listener.getStatus();
+
+            if(job.getExitCode() != 0){
+                int errCode = listener.getError();
+                String errorMsg = "Job " + job.getID() + " on host " + host.getHostAddress() + " Job Exit Code = "
+                        + job.getExitCode();
+                JobSubmissionFault error = new JobSubmissionFault(this, new Exception(errorMsg), "GFAC HOST",
+                        gateKeeper, job.getRSL());
+                if (errCode == 8) {
+                    error.setReason(JobSubmissionFault.JOB_CANCEL);
+                } else {
+                    error.setReason(JobSubmissionFault.JOB_FAILED + " With Exit Code:" + job.getExitCode());
+                }
+                invocationContext.getExecutionContext().getNotifier().executionFail(invocationContext,error,errorMsg);
+                throw error;
+            }
             if (jobStatus == GramJob.STATUS_FAILED) {
                 int errCode = listener.getError();
                 String errorMsg = "Job " + job.getID() + " on host " + host.getHostAddress() + " Error Code = "
@@ -214,6 +229,7 @@ public class GramProvider extends Abstra
                 } else {
                     error.setReason(JobSubmissionFault.JOB_FAILED);
                 }
+                invocationContext.getExecutionContext().getNotifier().executionFail(invocationContext,error,errorMsg);
                 throw error;
             }
 
@@ -286,6 +302,24 @@ public class GramProvider extends Abstra
                     String stderr = ftp.readRemoteFile(stderrURI, gssCred, localStdErrFile);
                     Map<String, ?> stringMap = OutputUtils.fillOutputFromStdout(invocationContext.<ActualParameter>getOutput(), stdout);
 
+                    MessageContext<Object> input = invocationContext.getOutput();
+                    for (Iterator<String> iterator = input.getNames(); iterator.hasNext(); ) {
+                        String paramName = iterator.next();
+                        String paramValue = input.getStringValue(paramName);
+                        if("".equals(paramValue) || paramValue == null){
+                            int errCode = listener.getError();
+                            String errorMsg = "Job " + job.getID() + " on host " + host.getHostAddress();
+                            JobSubmissionFault error = new JobSubmissionFault(this, new Exception(errorMsg), "GFAC HOST",
+                                    gateKeeper, job.getRSL());
+                            if (errCode == 8) {
+                                error.setReason(JobSubmissionFault.JOB_CANCEL);
+                            } else {
+                                error.setReason(JobSubmissionFault.JOB_FAILED + " With Exit Code:" + job.getExitCode());
+                            }
+                            invocationContext.getExecutionContext().getNotifier().executionFail(invocationContext,error,errorMsg);
+                            throw error;
+                        }
+                    }
                     // If users has given an output DAta poth we download the output files in to that directory, this will be apath in the machine where GFac is installed
                     if(WorkflowContextHeaderBuilder.getCurrentContextHeader()
                             .getWorkflowOutputDataHandling() != null){