airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chath...@apache.org
Subject airavata git commit: saving errors
Date Tue, 08 Sep 2015 18:34:16 GMT
Repository: airavata
Updated Branches:
  refs/heads/master 3f890f968 -> 26f1039b6


saving errors


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/26f1039b
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/26f1039b
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/26f1039b

Branch: refs/heads/master
Commit: 26f1039b6dbc202d00cf8f07709889a7e3962950
Parents: 3f890f9
Author: Chathuri Wimalasena <chathuri@apache.org>
Authored: Tue Sep 8 14:34:05 2015 -0400
Committer: Chathuri Wimalasena <chathuri@apache.org>
Committed: Tue Sep 8 14:34:05 2015 -0400

----------------------------------------------------------------------
 .../apache/airavata/gfac/core/GFacUtils.java    | 35 ++++++++++++++++++++
 .../airavata/gfac/impl/GFacEngineImpl.java      | 34 +++++++++++++++----
 .../apache/airavata/gfac/impl/GFacWorker.java   | 10 ++++++
 3 files changed, 72 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/26f1039b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/GFacUtils.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/GFacUtils.java
b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/GFacUtils.java
index 1870255..fe125b8 100644
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/GFacUtils.java
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/GFacUtils.java
@@ -1093,6 +1093,41 @@ public class GFacUtils {
         }
     }
 
+    public static void saveExperimentError(ProcessContext processContext, ErrorModel errorModel)
throws GFacException {
+        try {
+            ExperimentCatalog experimentCatalog = processContext.getExperimentCatalog();
+            String experimentId = processContext.getExperimentId();
+            experimentCatalog.add(ExpCatChildDataType.EXPERIMENT_ERROR, errorModel, experimentId);
+        } catch (RegistryException e) {
+            String msg = "expId: " + processContext.getExperimentId() + " processId: " +
processContext.getProcessId()
+                    + " : - Error while updating experiment errors";
+            throw new GFacException(msg, e);
+        }
+    }
+
+    public static void saveProcessError(ProcessContext processContext, ErrorModel errorModel)
throws GFacException {
+        try {
+            ExperimentCatalog experimentCatalog = processContext.getExperimentCatalog();
+            experimentCatalog.add(ExpCatChildDataType.PROCESS_ERROR, errorModel, processContext.getProcessId());
+        } catch (RegistryException e) {
+            String msg = "expId: " + processContext.getExperimentId() + " processId: " +
processContext.getProcessId()
+                    + " : - Error while updating process errors";
+            throw new GFacException(msg, e);
+        }
+    }
+
+    public static void saveTaskError(TaskContext taskContext, ErrorModel errorModel) throws
GFacException {
+        try {
+            ExperimentCatalog experimentCatalog = taskContext.getParentProcessContext().getExperimentCatalog();
+            String taskId = taskContext.getTaskId();
+            experimentCatalog.add(ExpCatChildDataType.TASK_ERROR, errorModel, taskId);
+        } catch (RegistryException e) {
+            String msg = "expId: " + taskContext.getParentProcessContext().getExperimentId()
+ " processId: " + taskContext.getParentProcessContext().getProcessId() + " taskId: " + taskContext.getTaskId()
+                    + " : - Error while updating task errors";
+            throw new GFacException(msg, e);
+        }
+    }
+
 	public static void handleProcessInterrupt(ProcessContext processContext) throws GFacException
{
 		if (processContext.isCancel()) {
 			ProcessStatus pStatus = new ProcessStatus(ProcessState.CANCELLING);

http://git-wip-us.apache.org/repos/asf/airavata/blob/26f1039b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/GFacEngineImpl.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/GFacEngineImpl.java
b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/GFacEngineImpl.java
index b0bdb65..7926fdb 100644
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/GFacEngineImpl.java
+++ b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/GFacEngineImpl.java
@@ -42,6 +42,7 @@ import org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfil
 import org.apache.airavata.model.application.io.DataType;
 import org.apache.airavata.model.application.io.InputDataObjectType;
 import org.apache.airavata.model.application.io.OutputDataObjectType;
+import org.apache.airavata.model.commons.ErrorModel;
 import org.apache.airavata.model.job.JobModel;
 import org.apache.airavata.model.process.ProcessModel;
 import org.apache.airavata.model.status.ProcessState;
@@ -209,9 +210,15 @@ public class GFacEngineImpl implements GFacEngine {
 						taskStatus = executeTask(taskCtx, dMoveTask, false);
 						if (taskStatus.getState() == TaskState.FAILED) {
 							log.error("expId: {}, processId: {}, taskId: {} type: {},:- Input statging failed,
" +
-									"reason:" + " {}", taskCtx.getParentProcessContext().getExperimentId(), taskCtx
-									.getParentProcessContext().getProcessId(), taskCtx.getTaskId(), dMoveTask.getType
-									().name(), taskStatus.getReason());
+                                    "reason:" + " {}", taskCtx.getParentProcessContext().getExperimentId(),
taskCtx
+                                    .getParentProcessContext().getProcessId(), taskCtx.getTaskId(),
dMoveTask.getType
+                                    ().name(), taskStatus.getReason());
+                            String errorMsg = "expId: {}, processId: {}, taskId: {} type:
{},:- Input staging failed, " +
+                                    "reason:" + " {}" + processContext.getExperimentId()
+ processContext.getProcessId() + taskCtx.getTaskId() + dMoveTask.getType().name() + taskStatus.getReason();
+                            ErrorModel errorModel = new ErrorModel();
+                            errorModel.setUserFriendlyMessage("Error while staging input
data");
+                            errorModel.setActualErrorMessage(errorMsg);
+                            GFacUtils.saveTaskError(taskCtx, errorModel);
 							throw new GFacException("Error while staging input data");
 						}
 						break;
@@ -243,10 +250,16 @@ public class GFacEngineImpl implements GFacEngine {
 		SSHEnvironmentSetupTask envSetupTask = new SSHEnvironmentSetupTask();
 		TaskStatus taskStatus = executeTask(taskCtx, envSetupTask, recover);
 		if (taskStatus.getState() == TaskState.FAILED) {
-			log.error("expId: {}, processId: {}, taskId: {} type: {},:- Input statging failed, " +
+			log.error("expId: {}, processId: {}, taskId: {} type: {},:- Input staging failed, " +
 					"reason:" + " {}", taskCtx.getParentProcessContext().getExperimentId(), taskCtx
 					.getParentProcessContext().getProcessId(), taskCtx.getTaskId(), envSetupTask.getType
 					().name(), taskStatus.getReason());
+            String errorMsg = "expId: {}, processId: {}, taskId: {} type: {},:- Input staging
failed, " +
+                    "reason:" + " {}" + processContext.getExperimentId() + processContext.getProcessId()
+ taskCtx.getTaskId() + envSetupTask.getType().name() + taskStatus.getReason();
+            ErrorModel errorModel = new ErrorModel();
+            errorModel.setUserFriendlyMessage("Error while environment setup");
+            errorModel.setActualErrorMessage(errorMsg);
+            GFacUtils.saveTaskError(taskCtx, errorModel);
 			throw new GFacException("Error while environment setup");
 		}
 		if (processContext.isInterrupted()) {
@@ -349,7 +362,7 @@ public class GFacEngineImpl implements GFacEngine {
 					try {
 						taskCtx = getDataStagingTaskContext(processContext, processOutput);
 					} catch (TException e) {
-						throw new GFacException("Thrift model to byte[] convertion issue", e);
+						throw new GFacException("Thrift model to byte[] conversion issue", e);
 					}
 					File localWorkingdir = new File(taskCtx.getLocalWorkingDir());
 					localWorkingdir.mkdirs(); // make local dir if not exist
@@ -358,11 +371,18 @@ public class GFacEngineImpl implements GFacEngine {
 					Task dMoveTask = Factory.getDataMovementTask(processContext.getDataMovementProtocol());
 					TaskStatus taskStatus = executeTask(taskCtx, dMoveTask, recovery);
 					if (taskStatus.getState() == TaskState.FAILED) {
-						log.error("expId: {}, processId: {}, taskId: {} type: {},:- Input statging failed,
" +
+						log.error("expId: {}, processId: {}, taskId: {} type: {},:- output staging failed,
" +
 								"reason:" + " {}", taskCtx.getParentProcessContext().getExperimentId(), taskCtx
 								.getParentProcessContext().getProcessId(), taskCtx.getTaskId(), dMoveTask.getType
 								().name(), taskStatus.getReason());
-						throw new GFacException("Error while staging input data");
+
+                        String errorMsg = "expId: {}, processId: {}, taskId: {} type: {},:-
output staging failed, " +
+                                "reason:" + " {}" + processContext.getExperimentId() + processContext.getProcessId()
+ taskCtx.getTaskId() + dMoveTask.getType().name() + taskStatus.getReason();
+                        ErrorModel errorModel = new ErrorModel();
+                        errorModel.setUserFriendlyMessage("Error while staging output data");
+                        errorModel.setActualErrorMessage(errorMsg);
+                        GFacUtils.saveTaskError(taskCtx, errorModel);
+						throw new GFacException("Error while staging output data");
 					}
 					break;
 				default:

http://git-wip-us.apache.org/repos/asf/airavata/blob/26f1039b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/GFacWorker.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/GFacWorker.java
b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/GFacWorker.java
index cdbca05..fe33a86 100644
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/GFacWorker.java
+++ b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/GFacWorker.java
@@ -27,11 +27,14 @@ import org.apache.airavata.gfac.core.GFacException;
 import org.apache.airavata.gfac.core.GFacUtils;
 import org.apache.airavata.gfac.core.context.ProcessContext;
 import org.apache.airavata.gfac.core.monitor.JobMonitor;
+import org.apache.airavata.model.commons.ErrorModel;
 import org.apache.airavata.model.status.ProcessState;
 import org.apache.airavata.model.status.ProcessStatus;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.PrintWriter;
+import java.io.StringWriter;
 import java.text.MessageFormat;
 
 public class GFacWorker implements Runnable {
@@ -123,8 +126,15 @@ public class GFacWorker implements Runnable {
 			ProcessStatus status = new ProcessStatus(ProcessState.FAILED);
 			status.setReason(e.getMessage());
 			processContext.setProcessStatus(status);
+            StringWriter errors = new StringWriter();
+            e.printStackTrace(new PrintWriter(errors));
+            ErrorModel errorModel = new ErrorModel();
+            errorModel.setUserFriendlyMessage("GFac Worker throws an exception");
+            errorModel.setActualErrorMessage(errors.toString());
 			try {
 				GFacUtils.saveAndPublishProcessStatus(processContext);
+                GFacUtils.saveExperimentError(processContext, errorModel);
+                GFacUtils.saveProcessError(processContext, errorModel);
 			} catch (GFacException e1) {
 				log.error("expId: {}, processId: {} :- Couldn't save and publish process status {}",
processContext
 						.getExperimentId(), processContext.getProcessId(), processContext.getProcessState());


Mime
View raw message