airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lah...@apache.org
Subject svn commit: r1345096 - in /incubator/airavata/branches/0.3-incubating-snapshot/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac: provider/impl/GramProvider.java utils/OutputUtils.java
Date Fri, 01 Jun 2012 12:10:14 GMT
Author: lahiru
Date: Fri Jun  1 12:10:14 2012
New Revision: 1345096

URL: http://svn.apache.org/viewvc?rev=1345096&view=rev
Log:
fixin minor issue with gfac notification sending.

Modified:
    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/gfac-core/src/main/java/org/apache/airavata/core/gfac/utils/OutputUtils.java

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=1345096&r1=1345095&r2=1345096&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
Fri Jun  1 12:10:14 2012
@@ -22,7 +22,6 @@
 package org.apache.airavata.core.gfac.provider.impl;
 
 import java.io.*;
-import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.*;
@@ -232,24 +231,22 @@ public class GramProvider extends Abstra
             }
 
         } catch (GramException e) {
-            JobSubmissionFault error = new JobSubmissionFault(this, e, host.getHostAddress(),
gateKeeper, job.getRSL());
-            if (listener.getError() == 8) {
-                error.setReason(JobSubmissionFault.JOB_CANCEL);
-            } else {
-                error.setReason(JobSubmissionFault.JOB_FAILED);
-            }
-            throw error;
+            invocationContext.getExecutionContext().getNotifier().executionFail(invocationContext,e,e.getMessage());
         } catch (GSSException e) {
+            invocationContext.getExecutionContext().getNotifier().executionFail(invocationContext,e,e.getMessage());
             throw new ProviderException(e.getMessage(), e);
         } catch (InterruptedException e) {
+            invocationContext.getExecutionContext().getNotifier().executionFail(invocationContext,e,e.getMessage());
             throw new ProviderException("Thread", e);
         } catch (SecurityException e) {
+            invocationContext.getExecutionContext().getNotifier().executionFail(invocationContext,e,e.getMessage());
             throw new ProviderException(e.getMessage(), e);
         } finally {
             if (job != null) {
                 try {
                     job.cancel();
                 } catch (Exception e) {
+                    invocationContext.getExecutionContext().getNotifier().executionFail(invocationContext,e,e.getMessage());
                 }
             }
         }
@@ -375,7 +372,7 @@ public class GramProvider extends Abstra
             throws ProviderException {
         MessageContext inputNew = new ParameterContextImpl();
         try {
-		MessageContext<Object> input = invocationContext.getInput();
+		    MessageContext<Object> input = invocationContext.getInput();
         for (Iterator<String> iterator = input.getNames(); iterator.hasNext();) {
 			String paramName = iterator.next();
 			String paramValue = input.getStringValue(paramName);
@@ -383,12 +380,12 @@ public class GramProvider extends Abstra
 					.getValue(paramName);
 			//TODO: Review this with type
 			if ("URI".equals(actualParameter.getType().getType().toString())) {
-                        ((URIParameterType) actualParameter.getType()).setValue(stageInputFiles(invocationContext,
paramValue, actualParameter).getPath());
+                        ((URIParameterType) actualParameter.getType()).setValue(stageInputFiles(invocationContext,
paramValue, actualParameter));
             }else if("URIArray".equals(actualParameter.getType().getType().toString())){
                 List<String> split = Arrays.asList(paramValue.split(","));
                 List<String> newFiles = new ArrayList<String>();
                     for (String paramValueEach : split) {
-                        newFiles.add(stageInputFiles(invocationContext, paramValueEach, actualParameter).getPath());
+                        newFiles.add(stageInputFiles(invocationContext, paramValueEach, actualParameter));
                     }
                 ((URIArrayType) actualParameter.getType()).setValueArray(newFiles.toArray(new
String[newFiles.size()]));
             }
@@ -402,7 +399,7 @@ public class GramProvider extends Abstra
 		return null;
 	}
 
-    private URI stageInputFiles(InvocationContext invocationContext, String paramValue, ActualParameter
actualParameter) throws URISyntaxException, SecurityException, ToolsException, IOException
{
+    private String stageInputFiles(InvocationContext invocationContext, String paramValue,
ActualParameter actualParameter) throws URISyntaxException, SecurityException, ToolsException,
IOException {
         URI gridftpURL;
         gridftpURL = new URI(paramValue);
         GlobusHostType host = (GlobusHostType) invocationContext.getExecutionDescription().getHost().getType();
@@ -415,9 +412,9 @@ public class GramProvider extends Abstra
             URI inputURI = GfacUtils.createGsiftpURI(endpoint, app.getInputDataDirectory());
             String fileName = new File(gridftpURL.getPath()).getName();
             String s = inputURI.getPath() + File.separator + fileName;
-            destURI = GfacUtils.createGsiftpURI(endpoint, s);
             //if user give a url just to refer an endpoint, not a web resource we are not
doing any transfer
             if (fileName != null && !"".equals(fileName)) {
+                destURI = GfacUtils.createGsiftpURI(endpoint, s);
                 if (paramValue.startsWith("gsiftp")) {
                     ftp.uploadFile(gridftpURL, destURI, gssCred);
                 } else if (paramValue.startsWith("file")) {
@@ -428,11 +425,14 @@ public class GramProvider extends Abstra
                             gssCred, (gridftpURL.toURL().openStream()));
                 }else {
                     //todo throw exception telling unsupported protocol
-//                                    new
+                    return paramValue;
                 }
+            }else{
+                // When the given input is not a web resource but a URI type input, then
we don't do any transfer just keep the same value as it isin the input
+                return paramValue;
             }
         }
-        return destURI;
+        return destURI.getPath();
     }
 
     private void stageOutputFiles(InvocationContext invocationContext,String outputFileStagingPath)
throws ProviderException {
@@ -456,7 +456,7 @@ public class GramProvider extends Abstra
             try {
                 if ("URI".equals(actualParameter.getType().getType().toString())) {
                     for (String endpoint : host.getGridFTPEndPointArray()) {
-                        ((URIParameterType) actualParameter.getType()).setValue(stageOutputFiles(outputFileStagingPath,
+                        ((URIParameterType) actualParameter.getType()).setValue(doStaging(outputFileStagingPath,
                                 paramValue, actualParameter, ftp, gssCred, endpoint));
                     }
                 } else if ("URIArray".equals(actualParameter.getType().getType().toString()))
{
@@ -464,7 +464,7 @@ public class GramProvider extends Abstra
                     List<String> newFiles = new ArrayList<String>();
                     for (String endpoint : host.getGridFTPEndPointArray()) {
                         for (String paramValueEach : split) {
-                            newFiles.add(stageOutputFiles(outputFileStagingPath, paramValueEach,
actualParameter, ftp, gssCred, endpoint));
+                            newFiles.add(doStaging(outputFileStagingPath, paramValueEach,
actualParameter, ftp, gssCred, endpoint));
                         }
                         ((URIArrayType) actualParameter.getType()).setValueArray(newFiles.toArray(new
String[newFiles.size()]));
                     }
@@ -480,7 +480,7 @@ public class GramProvider extends Abstra
         invocationContext.setOutput(outputNew);
     }
 
-    private String stageOutputFiles(String outputFileStagingPath, String paramValue, ActualParameter
actualParameter, GridFtp ftp, GSSCredential gssCred, String endpoint) throws URISyntaxException,
ToolsException {
+    private String doStaging(String outputFileStagingPath, String paramValue, ActualParameter
actualParameter, GridFtp ftp, GSSCredential gssCred, String endpoint) throws URISyntaxException,
ToolsException {
         URI srcURI = GfacUtils.createGsiftpURI(endpoint, paramValue);
         String fileName = new File(srcURI.getPath()).getName();
         File outputFile = new File(outputFileStagingPath + File.separator + fileName);

Modified: incubator/airavata/branches/0.3-incubating-snapshot/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/utils/OutputUtils.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/utils/OutputUtils.java?rev=1345096&r1=1345095&r2=1345096&view=diff
==============================================================================
--- incubator/airavata/branches/0.3-incubating-snapshot/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/utils/OutputUtils.java
(original)
+++ incubator/airavata/branches/0.3-incubating-snapshot/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/utils/OutputUtils.java
Fri Jun  1 12:10:14 2012
@@ -56,7 +56,7 @@ public class OutputUtils {
         return result;
     }
 
-    private static String parseStdout(String stdout, String outParam) {
+    private static String parseStdout(String stdout, String outParam)throws NullPointerException
{
         String regex = Pattern.quote(outParam) + "\\s*=\\s*([^\\[\\s'\"][^\\s]*|\"[^\"]*\"|'[^']*'|\\[[^\\[]*\\])";
         String match = null;
         Pattern pattern = Pattern.compile(regex);
@@ -68,7 +68,7 @@ public class OutputUtils {
             match = match.trim();
             return match;
         } else {
-            return null;
+            throw new NullPointerException();
         }
     }
 }



Mime
View raw message