You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sa...@apache.org on 2012/07/13 20:39:08 UTC
svn commit: r1361326 - in
/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac:
exception/ provider/impl/
Author: samindaw
Date: Fri Jul 13 18:39:07 2012
New Revision: 1361326
URL: http://svn.apache.org/viewvc?rev=1361326&view=rev
Log:
throwing fault notification when ProviderException is thrown
Modified:
incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/JobSubmissionFault.java
incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/ProviderException.java
incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/impl/EC2Provider.java
incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/impl/GramProvider.java
incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/impl/LocalProvider.java
incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/impl/SSHProvider.java
Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/JobSubmissionFault.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/JobSubmissionFault.java?rev=1361326&r1=1361325&r2=1361326&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/JobSubmissionFault.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/JobSubmissionFault.java Fri Jul 13 18:39:07 2012
@@ -21,6 +21,7 @@
package org.apache.airavata.core.gfac.exception;
+import org.apache.airavata.core.gfac.context.invocation.InvocationContext;
import org.apache.airavata.core.gfac.provider.Provider;
/**
@@ -34,8 +35,8 @@ public class JobSubmissionFault extends
private String reason;
- public JobSubmissionFault(Provider provider, Throwable cause, String submitHost, String contact, String rsl) {
- super(cause.getMessage(), cause);
+ public JobSubmissionFault(Provider provider, Throwable cause, String submitHost, String contact, String rsl, InvocationContext invocationContext) {
+ super(cause.getMessage(), cause,invocationContext);
}
public void setReason(String reason) {
Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/ProviderException.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/ProviderException.java?rev=1361326&r1=1361325&r2=1361326&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/ProviderException.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/ProviderException.java Fri Jul 13 18:39:07 2012
@@ -21,6 +21,7 @@
package org.apache.airavata.core.gfac.exception;
+import org.apache.airavata.core.gfac.context.invocation.InvocationContext;
import org.apache.airavata.core.gfac.provider.Provider;
/**
@@ -29,11 +30,25 @@ import org.apache.airavata.core.gfac.pro
*/
public class ProviderException extends GfacException {
- public ProviderException(String message) {
+ private static final long serialVersionUID = 7994167766799131223L;
+
+ public ProviderException(String message, InvocationContext invocationContext, String...additionalExceptiondata) {
super(message);
+ sendFaultNotification(message, invocationContext, new Exception(message),additionalExceptiondata);
}
- public ProviderException(String message, Throwable cause) {
+ public ProviderException(String message, Throwable cause, InvocationContext invocationContext, String...additionalExceptiondata) {
super(message, cause);
+ Exception e = new Exception(cause);
+ sendFaultNotification(message, invocationContext, e, additionalExceptiondata);
}
+
+ private void sendFaultNotification(String message,
+ InvocationContext invocationContext, Exception e,
+ String... additionalExceptiondata) {
+ if (additionalExceptiondata==null || additionalExceptiondata.length==0){
+ additionalExceptiondata=new String[]{message,e.getLocalizedMessage()};
+ }
+ invocationContext.getExecutionContext().getNotifier().executionFail(invocationContext,e,additionalExceptiondata);
+ }
}
Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/impl/EC2Provider.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/impl/EC2Provider.java?rev=1361326&r1=1361325&r2=1361326&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/impl/EC2Provider.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/impl/EC2Provider.java Fri Jul 13 18:39:07 2012
@@ -100,13 +100,13 @@ public class EC2Provider extends SSHProv
* Validation
*/
if (access_key == null || access_key.isEmpty())
- throw new ProviderException("Access Key is empty");
+ throw new ProviderException("EC2 Access Key is empty", invocationContext);
if (secret_key == null || secret_key.isEmpty())
- throw new ProviderException("Secret Key is empty");
+ throw new ProviderException("EC2 Secret Key is empty", invocationContext);
if ((ami_id == null && ins_id == null) || (ami_id != null && ami_id.isEmpty()) || (ins_id != null && ins_id.isEmpty()))
- throw new ProviderException("AMI or Instance ID is empty");
+ throw new ProviderException("EC2 AMI or Instance ID is empty", invocationContext);
if (this.username == null || this.username.isEmpty())
- throw new ProviderException("Username is empty");
+ throw new ProviderException("EC2 Username is empty", invocationContext);
/*
* Need to start EC2 instance before running it
@@ -167,7 +167,7 @@ public class EC2Provider extends SSHProv
}
} catch (Exception e) {
- throw new ProviderException("Invalied Request",e);
+ throw new ProviderException("Invalied Request",e,invocationContext);
}
SSHSecurityContextImpl sshContext = ((SSHSecurityContextImpl) invocationContext.getSecurityContext(SSH_SECURITY_CONTEXT));
Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/impl/GramProvider.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/impl/GramProvider.java?rev=1361326&r1=1361325&r2=1361326&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/impl/GramProvider.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/impl/GramProvider.java Fri Jul 13 18:39:07 2012
@@ -85,7 +85,7 @@ public class GramProvider extends Abstra
}
boolean success = false;
- ProviderException pe = new ProviderException("");
+ ProviderException pe = null;// = new ProviderException("");
for (String endpoint : host.getGridFTPEndPointArray()) {
try {
@@ -109,17 +109,17 @@ public class GramProvider extends Abstra
success = true;
break;
} catch (URISyntaxException e) {
- pe = new ProviderException("URI is malformatted:" + e.getMessage(), e);
+ pe = new ProviderException("URI is malformatted:" + e.getMessage(), e,invocationContext);
} catch (ToolsException e) {
- pe = new ProviderException(e.getMessage(), e);
+ pe = new ProviderException(e.getMessage(), e,invocationContext);
}
}
if (success == false) {
throw pe;
}
} catch (SecurityException e) {
- throw new ProviderException(e.getMessage(), e);
+ throw new ProviderException(e.getMessage(), e,invocationContext);
}
}
@@ -151,7 +151,7 @@ public class GramProvider extends Abstra
job.addListener(listener);
} catch (ToolsException te) {
- throw new ProviderException(te.getMessage(), te);
+ throw new ProviderException(te.getMessage(), te, invocationContext);
}
}
@@ -214,21 +214,21 @@ public class GramProvider extends Abstra
String errorMsg = "Job " + job.getID() + " on host " + host.getHostAddress() + " Job Exit Code = "
+ listener.getError();
JobSubmissionFault error = new JobSubmissionFault(this, new Exception(errorMsg), "GFAC HOST",
- gateKeeper, job.getRSL());
+ gateKeeper, job.getRSL(),invocationContext);
errorReason(errCode, error);
invocationContext.getExecutionContext().getNotifier().executionFail(invocationContext,error,errorMsg);
throw error;
}
} catch (GramException e) {
- JobSubmissionFault error = new JobSubmissionFault(this, e, host.getHostAddress(), gateKeeper, job.getRSL());
+ JobSubmissionFault error = new JobSubmissionFault(this, e, host.getHostAddress(), gateKeeper, job.getRSL(), invocationContext);
int errCode = listener.getError();
throw errorReason(errCode, error);
} catch (GSSException e) {
- throw new ProviderException(e.getMessage(), e);
+ throw new ProviderException(e.getMessage(), e, invocationContext);
} catch (InterruptedException e) {
- throw new ProviderException("Thread", e);
+ throw new ProviderException("Thread", e,invocationContext);
} catch (SecurityException e) {
- throw new ProviderException(e.getMessage(), e);
+ throw new ProviderException(e.getMessage(), e,invocationContext);
} finally {
if (job != null) {
try {
@@ -261,7 +261,7 @@ public class GramProvider extends Abstra
if (hostgridFTP == null || hostgridFTP.length == 0) {
hostgridFTP = new String[] { host.getHostAddress() };
}
- ProviderException pe = new ProviderException("");
+ ProviderException pe = null;
for (String endpoint : host.getGridFTPEndPointArray()) {
try {
/*
@@ -307,7 +307,7 @@ public class GramProvider extends Abstra
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());
+ gateKeeper, job.getRSL(), invocationContext);
errorReason(errCode, error);
invocationContext.getExecutionContext().getNotifier().executionFail(invocationContext,error,
readLastLinesofStdOut(localStdErrFile.getPath(), 20));
@@ -316,7 +316,7 @@ public class GramProvider extends Abstra
}
}
if(stringMap == null || stringMap.isEmpty()){
- ProviderException exception = new ProviderException("Error creating job output");
+ ProviderException exception = new ProviderException("Gram provider: Error creating job output", invocationContext);
invocationContext.getExecutionContext().getNotifier().executionFail(invocationContext,exception,exception.getLocalizedMessage());
throw exception;
}
@@ -334,18 +334,18 @@ public class GramProvider extends Abstra
}
return stringMap;
}catch (XmlException e) {
- invocationContext.getExecutionContext().getNotifier().executionFail(invocationContext,e,readLastLinesofStdOut(localStdErrFile.getPath(), 20));
- throw new ProviderException(e.getMessage(), e);
+// invocationContext.getExecutionContext().getNotifier().executionFail(invocationContext,e,readLastLinesofStdOut(localStdErrFile.getPath(), 20));
+ throw new ProviderException(e.getMessage(), e,invocationContext,readLastLinesofStdOut(localStdErrFile.getPath(), 20));
}
catch (ToolsException e) {
- invocationContext.getExecutionContext().getNotifier().executionFail(invocationContext,e,readLastLinesofStdOut(localStdErrFile.getPath(), 20));
- throw new ProviderException(e.getMessage(), e);
+// invocationContext.getExecutionContext().getNotifier().executionFail(invocationContext,e,readLastLinesofStdOut(localStdErrFile.getPath(), 20));
+ throw new ProviderException(e.getMessage(), e,invocationContext,readLastLinesofStdOut(localStdErrFile.getPath(), 20));
} catch (URISyntaxException e) {
- invocationContext.getExecutionContext().getNotifier().executionFail(invocationContext,e,readLastLinesofStdOut(localStdErrFile.getPath(), 20));
- throw new ProviderException("URI is malformatted:" + e.getMessage(), e);
+// invocationContext.getExecutionContext().getNotifier().executionFail(invocationContext,e,readLastLinesofStdOut(localStdErrFile.getPath(), 20));
+ throw new ProviderException("URI is malformatted:" + e.getMessage(), e, invocationContext,readLastLinesofStdOut(localStdErrFile.getPath(), 20));
}catch (NullPointerException e) {
- invocationContext.getExecutionContext().getNotifier().executionFail(invocationContext,e,e.getMessage());
- throw new ProviderException("Outupt is not produced in stdout:" + e.getMessage(), e);
+// invocationContext.getExecutionContext().getNotifier().executionFail(invocationContext,e,e.getMessage());
+ throw new ProviderException("Outupt is not produced in stdout:" + e.getMessage(), e, invocationContext, readLastLinesofStdOut(localStdErrFile.getPath(), 20));
}
}
@@ -355,8 +355,8 @@ public class GramProvider extends Abstra
throw pe;
} catch (Exception e) {
- invocationContext.getExecutionContext().getNotifier().executionFail(invocationContext,e,readLastLinesofStdOut(localStdErrFile.getPath(), 20));
- throw new ProviderException(e.getMessage(), e);
+// invocationContext.getExecutionContext().getNotifier().executionFail(invocationContext,e,readLastLinesofStdOut(localStdErrFile.getPath(), 20));
+ throw new ProviderException(e.getMessage(), e, invocationContext, readLastLinesofStdOut(localStdErrFile.getPath(), 20));
}
}
@@ -386,8 +386,8 @@ public class GramProvider extends Abstra
inputNew.add(paramName, actualParameter);
}
}catch (Exception e){
- invocationContext.getExecutionContext().getNotifier().executionFail(invocationContext,e,"Error during Input File staging");
- throw new ProviderException("Error while input File Staging", e.getCause());
+// invocationContext.getExecutionContext().getNotifier().executionFail(invocationContext,e,"Error during Input File staging");
+ throw new ProviderException("Error while input File Staging", e.getCause(),invocationContext, "Error during Input File staging");
}
invocationContext.setInput(inputNew);
return null;
@@ -465,9 +465,9 @@ public class GramProvider extends Abstra
}
} catch (URISyntaxException e) {
- throw new ProviderException(e.getMessage(), e);
+ throw new ProviderException(e.getMessage(), e, invocationContext);
} catch (ToolsException e) {
- throw new ProviderException(e.getMessage(), e);
+ throw new ProviderException(e.getMessage(), e, invocationContext);
}
outputNew.add(paramName, actualParameter);
}
Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/impl/LocalProvider.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/impl/LocalProvider.java?rev=1361326&r1=1361325&r2=1361326&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/impl/LocalProvider.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/impl/LocalProvider.java Fri Jul 13 18:39:07 2012
@@ -21,13 +21,8 @@
package org.apache.airavata.core.gfac.provider.impl;
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
import java.io.File;
-import java.io.FileWriter;
import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@@ -55,12 +50,12 @@ public class LocalProvider extends Abstr
private ProcessBuilder builder;
private List<String> cmdList;
- private void makeFileSystemDir(String dir) throws ProviderException {
+ private void makeFileSystemDir(String dir, InvocationContext invocationContext) throws ProviderException {
File f = new File(dir);
if (f.isDirectory() && f.exists()) {
return;
} else if (!new File(dir).mkdir()) {
- throw new ProviderException("Cannot make directory");
+ throw new ProviderException("Cannot make directory "+dir, invocationContext);
}
}
@@ -70,10 +65,10 @@ public class LocalProvider extends Abstr
log.info("working diectroy = " + app.getStaticWorkingDirectory());
log.info("temp directory = " + app.getScratchWorkingDirectory());
- makeFileSystemDir(app.getStaticWorkingDirectory());
- makeFileSystemDir(app.getScratchWorkingDirectory());
- makeFileSystemDir(app.getInputDataDirectory());
- makeFileSystemDir(app.getOutputDataDirectory());
+ makeFileSystemDir(app.getStaticWorkingDirectory(),invocationContext);
+ makeFileSystemDir(app.getScratchWorkingDirectory(),invocationContext);
+ makeFileSystemDir(app.getInputDataDirectory(),invocationContext);
+ makeFileSystemDir(app.getOutputDataDirectory(),invocationContext);
}
public void setupEnvironment(InvocationContext context) throws ProviderException {
@@ -171,9 +166,9 @@ public class LocalProvider extends Abstr
log.info(buf.toString());
} catch (IOException io) {
- throw new ProviderException(io.getMessage(), io);
+ throw new ProviderException(io.getMessage(), io,context);
} catch (InterruptedException e) {
- throw new ProviderException(e.getMessage(), e);
+ throw new ProviderException(e.getMessage(), e, context);
}
}
@@ -187,9 +182,9 @@ public class LocalProvider extends Abstr
// set to context
return OutputUtils.fillOutputFromStdout(context.<ActualParameter>getOutput(), stdOutStr);
} catch (XmlException e) {
- throw new ProviderException("Cannot read output:" + e.getMessage(), e);
+ throw new ProviderException("Cannot read output:" + e.getMessage(), e, context);
} catch (IOException io) {
- throw new ProviderException(io.getMessage(), io);
+ throw new ProviderException(io.getMessage(), io, context);
}
}
Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/impl/SSHProvider.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/impl/SSHProvider.java?rev=1361326&r1=1361325&r2=1361326&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/impl/SSHProvider.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/impl/SSHProvider.java Fri Jul 13 18:39:07 2012
@@ -129,11 +129,11 @@ public class SSHProvider extends Abstrac
Command cmd = session.exec(commandString.toString());
cmd.join(COMMAND_EXECUTION_TIMEOUT, TimeUnit.SECONDS);
} catch (ConnectionException e) {
- throw new ProviderException(e.getMessage(), e);
+ throw new ProviderException(e.getMessage(), e, context);
} catch (TransportException e) {
- throw new ProviderException(e.getMessage(), e);
+ throw new ProviderException(e.getMessage(), e, context);
} catch (IOException e) {
- throw new ProviderException(e.getMessage(), e);
+ throw new ProviderException(e.getMessage(), e, context);
} finally {
closeSession(session);
}
@@ -222,11 +222,11 @@ public class SSHProvider extends Abstrac
}
} catch (ConnectionException e) {
- throw new ProviderException(e.getMessage(), e);
+ throw new ProviderException(e.getMessage(), e, context);
} catch (TransportException e) {
- throw new ProviderException(e.getMessage(), e);
+ throw new ProviderException(e.getMessage(), e, context);
} catch (IOException e) {
- throw new ProviderException(e.getMessage(), e);
+ throw new ProviderException(e.getMessage(), e, context);
} finally {
closeSession(session);
}
@@ -251,13 +251,13 @@ public class SSHProvider extends Abstrac
return OutputUtils.fillOutputFromStdout(context.<ActualParameter> getOutput(), stdOutStr);
} catch (XmlException e) {
- throw new ProviderException("Cannot read output:" + e.getMessage(), e);
+ throw new ProviderException("Cannot read output:" + e.getMessage(), e, context);
} catch (ConnectionException e) {
- throw new ProviderException(e.getMessage(), e);
+ throw new ProviderException(e.getMessage(), e, context);
} catch (TransportException e) {
- throw new ProviderException(e.getMessage(), e);
+ throw new ProviderException(e.getMessage(), e, context);
} catch (IOException e) {
- throw new ProviderException(e.getMessage(), e);
+ throw new ProviderException(e.getMessage(), e, context);
}
}