airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ramin...@apache.org
Subject svn commit: r1471144 - in /airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac: handler/GridFTPOutputHandler.java handler/SCPOutputHandler.java provider/impl/LocalProvider.java utils/OutputUtils.java
Date Tue, 23 Apr 2013 21:03:54 GMT
Author: raminder
Date: Tue Apr 23 21:03:54 2013
New Revision: 1471144

URL: http://svn.apache.org/r1471144
Log:
Fixed output handling AIRAVATA-833. There are lot of problems with output data handling. I
fixed it best according to current design and will start a mail thread with the problems to
get it fixed for 0.8. 

Modified:
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/handler/GridFTPOutputHandler.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/handler/SCPOutputHandler.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/LocalProvider.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/utils/OutputUtils.java

Modified: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/handler/GridFTPOutputHandler.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/handler/GridFTPOutputHandler.java?rev=1471144&r1=1471143&r2=1471144&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/handler/GridFTPOutputHandler.java
(original)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/handler/GridFTPOutputHandler.java
Tue Apr 23 21:03:54 2013
@@ -65,18 +65,15 @@ public class GridFTPOutputHandler implem
  	   HostDescriptionType hostType = jobExecutionContext.getApplicationContext().getHostDescription().getType();
  	   String[] gridFTPEndpointArray = null;
  	   String hostName = null;
- 	   String hostAddress = null;
-
+ 
        if(jobExecutionContext.getApplicationContext().getHostDescription().getType() instanceof
GlobusHostType){
         	gridFTPEndpointArray = ((GlobusHostType) hostType).getGridFTPEndPointArray();
         	hostName = ((GlobusHostType) hostType).getHostName();
-        	hostAddress = ((GlobusHostType) hostType).getHostAddress();
-
+ 
        }
        else if (jobExecutionContext.getApplicationContext().getHostDescription().getType()
instanceof UnicoreHostType){
         	gridFTPEndpointArray = ((UnicoreHostType) hostType).getGridFTPEndPointArray();
         	hostName = ((UnicoreHostType) hostType).getHostName();
-        	hostAddress = ((UnicoreHostType) hostType).getHostAddress();
        }
        else {
         	//TODO
@@ -152,7 +149,16 @@ public class GridFTPOutputHandler implem
 //                            stringMap = new HashMap<String, ActualParameter>();
                             stringMap.put(paramName, actualParameter);
                         } else if ("URI".equals(actualParameter.getType().getType().toString()))
{
-                            stringMap.put(paramName, actualParameter);
+                        	  URI outputURI = GFacUtils.createGsiftpURI(endpoint, app.getOutputDataDirectory());
+                              List<String> outputList = ftp.listDir(outputURI, gssCred);
+                              String valueList = outputList.get(0);
+                              if(valueList.isEmpty()){
+                            	  stringMap = OutputUtils.fillOutputFromStdout(output, stdout,
stderr);
+                              }else{
+                              ((URIParameterType) actualParameter.getType()).setValue(valueList);
+                              stringMap = new HashMap<String, ActualParameter>();
+                              stringMap.put(paramName, actualParameter);
+                              }
                         }
                         else if ("String".equals(actualParameter.getType().getType().toString()))
{
                         	String path = app.getOutputDataDirectory()+"/"+((StringParameterType)
actualParameter.getType()).getValue();
@@ -163,7 +169,7 @@ public class GridFTPOutputHandler implem
                         }
                         else {
                             // This is to handle exception during the output parsing.
-                            stringMap = OutputUtils.fillOutputFromStdout(jobExecutionContext,
stdout, stderr);
+                            stringMap = OutputUtils.fillOutputFromStdout(output, stdout,
stderr);
                         }
                     }
                     if (stringMap == null || stringMap.isEmpty()) {

Modified: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/handler/SCPOutputHandler.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/handler/SCPOutputHandler.java?rev=1471144&r1=1471143&r2=1471144&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/handler/SCPOutputHandler.java
(original)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/handler/SCPOutputHandler.java
Tue Apr 23 21:03:54 2013
@@ -42,9 +42,11 @@ public class SCPOutputHandler implements
 
 
 	public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException
{
-		ApplicationDeploymentDescriptionType app = jobExecutionContext.getApplicationContext().getApplicationDeploymentDescription().getType();
+		ApplicationDeploymentDescriptionType app = jobExecutionContext.getApplicationContext()
+				.getApplicationDeploymentDescription().getType();
 		try {
-			 SSHSecurityContext securityContext = (SSHSecurityContext)jobExecutionContext.getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT);
+			SSHSecurityContext securityContext = (SSHSecurityContext) jobExecutionContext
+					.getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT);
 
 			// Get the Stdouts and StdErrs
 			String timeStampedServiceName = GFacUtils.createUniqueNameForService(jobExecutionContext.getServiceName());
@@ -57,13 +59,14 @@ public class SCPOutputHandler implements
 
 			String stdOutStr = GFacUtils.readFileToString(localStdOutFile.getAbsolutePath());
 			String stdErrStr = GFacUtils.readFileToString(localStdErrFile.getAbsolutePath());
-			 Map<String, ActualParameter> stringMap = new HashMap<String, ActualParameter>();
-
-			 stringMap =  OutputUtils.fillOutputFromStdout(jobExecutionContext, stdOutStr, stdErrStr);
-			 if (stringMap == null || stringMap.isEmpty()) {
-                 throw new GFacHandlerException("Empty Output returned from the Application,
Double check the application" +
-                         "and ApplicationDescriptor output Parameter Names");
-             }
+			Map<String, ActualParameter> stringMap = new HashMap<String, ActualParameter>();
+			Map<String, Object> output = jobExecutionContext.getOutMessageContext().getParameters();
+			stringMap = OutputUtils.fillOutputFromStdout(output, stdOutStr, stdErrStr);
+			if (stringMap == null || stringMap.isEmpty()) {
+				throw new GFacHandlerException(
+						"Empty Output returned from the Application, Double check the application"
+								+ "and ApplicationDescriptor output Parameter Names");
+			}
 
 		} catch (XmlException e) {
 			throw new GFacHandlerException("Cannot read output:" + e.getMessage(), e);

Modified: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/LocalProvider.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/LocalProvider.java?rev=1471144&r1=1471143&r2=1471144&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/LocalProvider.java
(original)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/LocalProvider.java
Tue Apr 23 21:03:54 2013
@@ -130,7 +130,8 @@ public class LocalProvider implements GF
         try {
             String stdOutStr = GFacUtils.readFileToString(app.getStandardOutput());
             String stdErrStr = GFacUtils.readFileToString(app.getStandardError());
-            OutputUtils.fillOutputFromStdout(jobExecutionContext, stdOutStr, stdErrStr);
+			Map<String, Object> output = jobExecutionContext.getOutMessageContext().getParameters();
+            OutputUtils.fillOutputFromStdout(output, stdOutStr, stdErrStr);
         } catch (XmlException e) {
             throw new GFacProviderException("Cannot read output:" + e.getMessage(), e, jobExecutionContext);
         } catch (IOException io) {

Modified: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/utils/OutputUtils.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/utils/OutputUtils.java?rev=1471144&r1=1471143&r2=1471144&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/utils/OutputUtils.java
(original)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/utils/OutputUtils.java
Tue Apr 23 21:03:54 2013
@@ -20,46 +20,46 @@
 */
 package org.apache.airavata.gfac.utils;
 
-import org.apache.airavata.commons.gfac.type.ActualParameter;
-import org.apache.airavata.commons.gfac.type.MappingFactory;
-import org.apache.airavata.gfac.context.JobExecutionContext;
-import org.apache.airavata.gfac.context.MessageContext;
-import org.apache.airavata.schemas.gfac.OutputParameterType;
-import org.apache.airavata.schemas.gfac.StdErrParameterType;
-import org.apache.airavata.schemas.gfac.StdOutParameterType;
-
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Set;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import org.apache.airavata.commons.gfac.type.ActualParameter;
+import org.apache.airavata.commons.gfac.type.MappingFactory;
+import org.apache.airavata.schemas.gfac.StdErrParameterType;
+import org.apache.airavata.schemas.gfac.StdOutParameterType;
+import org.apache.airavata.schemas.gfac.URIParameterType;
+
 public class OutputUtils {
     private static String regexPattern = "\\s*=\\s*([^\\[\\s'\"][^\\s]*|\"[^\"]*\"|'[^']*'|\\[[^\\[]*\\])";
 
-    public static Map<String, ActualParameter> fillOutputFromStdout(JobExecutionContext
context, String stdout, String stderr) throws Exception {
+    public static Map<String, ActualParameter> fillOutputFromStdout(Map<String,
Object> output, String stdout, String stderr) throws Exception {
 
         Map<String, ActualParameter> result = new HashMap<String, ActualParameter>();
-        OutputParameterType[] outputParametersArray = context.getApplicationContext().
-                getServiceDescription().getType().getOutputParametersArray();
-        MessageContext outMessageContext = context.getOutMessageContext();
-        for (OutputParameterType outparamType : outputParametersArray) {
-            String parameterName = outparamType.getParameterName();
-            ActualParameter actual = (ActualParameter)outMessageContext.getParameter(outparamType.getParameterName());
+        Set<String> keys = output.keySet();
+        for (String paramName : keys) {
+        	ActualParameter actual = (ActualParameter) output.get(paramName);
             // if parameter value is not already set, we let it go
+            
             if (actual == null) {
                 continue;
             }
             if ("StdOut".equals(actual.getType().getType().toString())) {
                 ((StdOutParameterType) actual.getType()).setValue(stdout);
-                result.put(parameterName, actual);
+                result.put(paramName, actual);
             } else if ("StdErr".equals(actual.getType().getType().toString())) {
                 ((StdErrParameterType) actual.getType()).setValue(stderr);
-                result.put(parameterName, actual);
+                result.put(paramName, actual);
             } else {
-                String parseStdout = parseStdout(stdout, parameterName);
+            	if ("URI".equals(actual.getType().getType().toString()) &&  !((URIParameterType)
actual.getType()).getValue().isEmpty()){
+            		continue;
+            	}
+                String parseStdout = parseStdout(stdout, paramName);
                 if (parseStdout != null) {
                     MappingFactory.fromString(actual, parseStdout);
-                    result.put(parameterName, actual);
+                    result.put(paramName, actual);
                 }
             }
         }



Mime
View raw message