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/16 00:34:47 UTC

svn commit: r1338925 - in /incubator/airavata/branches/0.3-incubating-snapshot/modules: gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/reciever/ gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/impl/ xbaya-gui/src/main/j...

Author: lahiru
Date: Tue May 15 22:34:46 2012
New Revision: 1338925

URL: http://svn.apache.org/viewvc?rev=1338925&view=rev
Log:
committing output file statgin to the branch.

Modified:
    incubator/airavata/branches/0.3-incubating-snapshot/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/reciever/GFacMessageReciever.java
    incubator/airavata/branches/0.3-incubating-snapshot/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/impl/GramProvider.java
    incubator/airavata/branches/0.3-incubating-snapshot/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorSkeleton.java

Modified: incubator/airavata/branches/0.3-incubating-snapshot/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/reciever/GFacMessageReciever.java
URL: http://svn.apache.org/viewvc/incubator/airavata/branches/0.3-incubating-snapshot/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/reciever/GFacMessageReciever.java?rev=1338925&r1=1338924&r2=1338925&view=diff
==============================================================================
--- incubator/airavata/branches/0.3-incubating-snapshot/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/reciever/GFacMessageReciever.java (original)
+++ incubator/airavata/branches/0.3-incubating-snapshot/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/reciever/GFacMessageReciever.java Tue May 15 22:34:46 2012
@@ -30,6 +30,7 @@ import javax.xml.stream.XMLStreamExcepti
 import javax.xml.stream.XMLStreamReader;
 
 import org.apache.airavata.common.registry.api.exception.RegistryException;
+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.commons.gfac.wsdl.GFacSchemaConstants;
@@ -169,6 +170,9 @@ public class GFacMessageReciever impleme
         } catch (XmlException e) {
             e.printStackTrace();
         }
+        //Set the WorkflowContext Header to the ThreadLocal of the Gfac Service, so that this can be accessed easilly
+        WorkflowContextHeaderBuilder.setCurrentContextHeader(document.getContextHeader());
+
         Map<Parameter,ActualParameter> actualParameters = new LinkedHashMap<Parameter,ActualParameter>();
         ServiceDescription serviceDescription = getRegistry(context).getServiceDescription(serviceName);
         ServiceDescriptionType serviceDescriptionType = serviceDescription.getType();
@@ -183,7 +187,7 @@ public class GFacMessageReciever impleme
             //todo this implementation doesn't work when there are n number of nodes connecting .. need to fix
             actualParameters.put(parameter, GfacUtils.getInputActualParameter(parameter, element));
         }
-         DefaultInvocationContext invocationContext = null;
+        DefaultInvocationContext invocationContext = null;
         JobContext jobContext = new JobContext(actualParameters,topic,serviceName,brokerURL);
         if(document.getContextHeader().getSecurityContext().getAmazonWebservices() != null){
 //            invocationContext.getExecutionContext().setSecurityContextHeader(header);

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=1338925&r1=1338924&r2=1338925&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 Tue May 15 22:34:46 2012
@@ -25,9 +25,11 @@ import java.io.*;
 import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.net.URL;
 import java.util.Iterator;
 import java.util.Map;
 
+import org.apache.airavata.common.workflow.execution.context.WorkflowContextHeaderBuilder;
 import org.apache.airavata.commons.gfac.type.ActualParameter;
 import org.apache.airavata.core.gfac.context.invocation.InvocationContext;
 import org.apache.airavata.core.gfac.context.message.MessageContext;
@@ -46,6 +48,7 @@ import org.apache.airavata.core.gfac.uti
 import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
 import org.apache.airavata.schemas.gfac.GlobusHostType;
 import org.apache.airavata.schemas.gfac.URIParameterType;
+import org.apache.airavata.schemas.wec.WorkflowOutputDataHandlingDocument;
 import org.apache.xmlbeans.XmlException;
 import org.globus.gram.GramAttributes;
 import org.globus.gram.GramException;
@@ -281,8 +284,21 @@ public class GramProvider extends Abstra
 
                     String stdout = ftp.readRemoteFile(stdoutURI, gssCred, localStdOutFile);
                     String stderr = ftp.readRemoteFile(stderrURI, gssCred, localStdErrFile);
+                    Map<String, ?> stringMap = OutputUtils.fillOutputFromStdout(invocationContext.<ActualParameter>getOutput(), stdout);
 
-                    return OutputUtils.fillOutputFromStdout(invocationContext.<ActualParameter> getOutput(), stdout);
+                    // 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){
+                        WorkflowOutputDataHandlingDocument.WorkflowOutputDataHandling workflowOutputDataHandling =
+                                WorkflowContextHeaderBuilder.getCurrentContextHeader().getWorkflowOutputDataHandling();
+                        if(workflowOutputDataHandling.getApplicationOutputDataHandlingArray().length != 0){
+                            String outputDataDirectory = workflowOutputDataHandling.getApplicationOutputDataHandlingArray()[0].getOutputDataDirectory();
+                            if(outputDataDirectory != null && !"".equals(outputDataDirectory)){
+                                stageOutputFiles(invocationContext,outputDataDirectory);
+                            }
+                        }
+                    }
+                    return stringMap;
                 } catch (ToolsException e) {
                     throw new ProviderException(e.getMessage(), e);
                 } catch (URISyntaxException e) {
@@ -367,4 +383,39 @@ public class GramProvider extends Abstra
         invocationContext.setInput(inputNew);
 		return null;
 	}
+    private void stageOutputFiles(InvocationContext invocationContext,String outputFileStagingPath) throws ProviderException {
+        MessageContext outputNew = new ParameterContextImpl();
+        MessageContext<Object> input = invocationContext.getOutput();
+        for (Iterator<String> iterator = input.getNames(); iterator.hasNext(); ) {
+            String paramName = iterator.next();
+            String paramValue = input.getStringValue(paramName);
+            ActualParameter actualParameter = (ActualParameter) input
+                    .getValue(paramName);
+            //TODO: Review this with type
+            if ("URI".equals(actualParameter.getType().getType().toString())) {
+                try {
+                    GlobusHostType host = (GlobusHostType) invocationContext.getExecutionDescription().getHost().getType();
+                    GridFtp ftp = new GridFtp();
+                    gssContext = (GSISecurityContext) invocationContext.getSecurityContext(MYPROXY_SECURITY_CONTEXT);
+                    GSSCredential gssCred = gssContext.getGssCredentails();
+                    for (String endpoint : host.getGridFTPEndPointArray()) {
+                        URI srcURI = GfacUtils.createGsiftpURI(endpoint, paramValue);
+                        String fileName = new File(srcURI.getPath()).getName();
+                        File outputFile = new File(outputFileStagingPath + File.separator + fileName);
+                        ftp.readRemoteFile(srcURI,
+                                gssCred, outputFile);
+                        ((URIParameterType) actualParameter.getType()).setValue(outputFileStagingPath + File.separator + fileName);
+                    }
+                } catch (URISyntaxException e) {
+                    throw new ProviderException(e.getMessage(), e);
+                } catch (ToolsException e) {
+                    throw new ProviderException(e.getMessage(), e);
+                } catch (SecurityException e) {
+                    throw new ProviderException(e.getMessage(), e);
+                }
+            }
+            outputNew.add(paramName, actualParameter);
+        }
+        invocationContext.setOutput(outputNew);
+    }
 }

Modified: incubator/airavata/branches/0.3-incubating-snapshot/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorSkeleton.java
URL: http://svn.apache.org/viewvc/incubator/airavata/branches/0.3-incubating-snapshot/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorSkeleton.java?rev=1338925&r1=1338924&r2=1338925&view=diff
==============================================================================
--- incubator/airavata/branches/0.3-incubating-snapshot/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorSkeleton.java (original)
+++ incubator/airavata/branches/0.3-incubating-snapshot/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorSkeleton.java Tue May 15 22:34:46 2012
@@ -206,7 +206,6 @@ public class WorkflowInterpretorSkeleton
         ContextHeaderDocument parse = null;
         try {
             parse = ContextHeaderDocument.Factory.parse(workflowContext.toStringWithConsume());
-            configuration.put(GFAC,parse.getContextHeader().getWorkflowMonitoringContext().getEventPublishEpr());
             configuration.put(BROKER, parse.getContextHeader().getWorkflowMonitoringContext().getEventPublishEpr());
             configuration.put(GFAC, parse.getContextHeader().getSoaServiceEprs().getGfacUrl());
             configuration.put(MSGBOX, parse.getContextHeader().getWorkflowMonitoringContext().getMsgBoxEpr());
@@ -269,7 +268,6 @@ public class WorkflowInterpretorSkeleton
             interpreter = new WorkflowInterpreter(conf, topic, workflow, username, password, true);
         }
 
-//        interpreter.setBuilder(builder);
         WorkflowContextHeaderBuilder.setCurrentContextHeader(builder.getContextHeader());
 
         final WorkflowInterpretorEventListener finalListener = listener;