airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chath...@apache.org
Subject git commit: adding error details - AIRAVATA-1006
Date Tue, 25 Feb 2014 20:09:45 GMT
Repository: airavata
Updated Branches:
  refs/heads/master 605ffaa27 -> b5d57f8ba


adding error details - AIRAVATA-1006


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

Branch: refs/heads/master
Commit: b5d57f8baa70018bb2c957d925fdae2baf8c9c56
Parents: 605ffaa
Author: chathuri <chathuri@apache.org>
Authored: Tue Feb 25 15:09:27 2014 -0500
Committer: chathuri <chathuri@apache.org>
Committed: Tue Feb 25 15:09:27 2014 -0500

----------------------------------------------------------------------
 .../registry/jpa/impl/ExperimentRegistry.java   | 101 ++++++++++++++++++-
 .../registry/jpa/impl/RegistryImpl.java         |   9 +-
 .../src/main/resources/registry-derby.sql       |   1 +
 .../airavata/registry/cpi/utils/Constants.java  |   9 +-
 4 files changed, 117 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/b5d57f8b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/ExperimentRegistry.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/ExperimentRegistry.java
b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/ExperimentRegistry.java
index 9704f3e..a2e59d2 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/ExperimentRegistry.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/ExperimentRegistry.java
@@ -934,6 +934,70 @@ public class ExperimentRegistry {
         return null;
     }
 
+    public String addErrorDetails (ErrorDetails error, Object id){
+        try{
+
+            GatewayResource gateway = gatewayRegistry.getDefaultGateway();
+            ErrorDetailResource errorResource = null;
+            ExperimentResource experiment;
+            TaskDetailResource taskDetail;
+            WorkflowNodeDetailResource workflowNode;
+            // figure out the id is an experiment, node task or job
+            if (id instanceof String){
+                if (isExperimentExist((String) id)){
+                    experiment = gateway.getExperiment((String) id);
+                    errorResource = (ErrorDetailResource)experiment.create(ResourceType.ERROR_DETAIL);
+                }else if (isWFNodeExist((String) id)){
+                    experiment = (ExperimentResource)gateway.create(ResourceType.EXPERIMENT);
+                    workflowNode = experiment.getWorkflowNode((String)id);
+                    errorResource = (ErrorDetailResource)workflowNode.create(ResourceType.ERROR_DETAIL);
+                    errorResource.setExperimentResource(workflowNode.getExperimentResource());
+                }else if (isTaskDetailExist((String)id)){
+                    experiment = (ExperimentResource)gateway.create(ResourceType.EXPERIMENT);
+                    workflowNode = (WorkflowNodeDetailResource)experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
+                    taskDetail = workflowNode.getTaskDetail((String)id);
+                    errorResource = (ErrorDetailResource)taskDetail.create(ResourceType.ERROR_DETAIL);
+                    errorResource.setTaskDetailResource(taskDetail);
+                    errorResource.setNodeDetail(taskDetail.getWorkflowNodeDetailResource());
+                    errorResource.setExperimentResource(taskDetail.getWorkflowNodeDetailResource().getExperimentResource());
+                }else {
+                    logger.error("The id provided is not an experiment id or a workflow id
or a task id..");
+                }
+            }else if (id instanceof CompositeIdentifier){
+                CompositeIdentifier cid = (CompositeIdentifier)id;
+                if (isJobDetailExist(cid)){
+                    experiment = (ExperimentResource)gateway.create(ResourceType.EXPERIMENT);
+                    workflowNode = (WorkflowNodeDetailResource)experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
+                    taskDetail = workflowNode.getTaskDetail((String)cid.getTopLevelIdentifier());
+                    JobDetailResource jobDetail = taskDetail.getJobDetail((String) cid.getSecondLevelIdentifier());
+                    errorResource = (ErrorDetailResource)jobDetail.create(ResourceType.ERROR_DETAIL);
+                    errorResource.setTaskDetailResource(taskDetail);
+                    errorResource.setNodeDetail(taskDetail.getWorkflowNodeDetailResource());
+                    errorResource.setExperimentResource(taskDetail.getWorkflowNodeDetailResource().getExperimentResource());
+                }else {
+                    logger.error("The id provided is not a job in the system..");
+                }
+            }else {
+                logger.error("The id provided is not an experiment id or a workflow id or
a task id or a composite " +
+                        "identifier for job..");
+            }
+            if (errorResource != null){
+                errorResource.setCreationTime(getTime(error.getCreationTime()));
+                errorResource.setActualErrorMsg(error.getActualErrorMessage());
+                errorResource.setUserFriendlyErrorMsg(error.getUserFriendlyMessage());
+                errorResource.setErrorCategory(error.getErrorCategory().toString());
+                errorResource.setTransientPersistent(error.isTransientOrPersistent());
+                errorResource.setCorrectiveAction(error.getCorrectiveAction().toString());
+                errorResource.setActionableGroup(error.getActionableGroup().toString());
+                errorResource.save();
+                return String.valueOf(errorResource.getErrorId());
+            }
+        } catch (ApplicationSettingsException e) {
+            logger.error("Unable to read airavata-server properties", e.getMessage());
+        }
+        return null;
+    }
+
     public String getNodeInstanceID(String nodeName) {
         return nodeName + "_" + UUID.randomUUID();
     }
@@ -1198,7 +1262,7 @@ public class ExperimentRegistry {
     public List<WorkflowNodeStatus> getWFNodeStatusList (String fieldName, Object value){
         try {
             GatewayResource defaultGateway = gatewayRegistry.getDefaultGateway();
-            if (fieldName.equals(Constants.FieldConstants.WorkflowNodeStatus.EXPERIMENT_ID)){
+            if (fieldName.equals(Constants.FieldConstants.WorkflowNodeStatusConstants.EXPERIMENT_ID)){
                 ExperimentResource experiment = defaultGateway.getExperiment((String) value);
                 List<StatusResource> workflowNodeStatuses = experiment.getWorkflowNodeStatuses();
                 return ThriftDataModelConversion.getWorkflowNodeStatusList(workflowNodeStatuses);
@@ -1264,6 +1328,41 @@ public class ExperimentRegistry {
         return null;
     }
 
+    public List<ErrorDetails> getErrorDetails (String fieldName, Object value){
+        try {
+            GatewayResource defaultGateway = gatewayRegistry.getDefaultGateway();
+            if (fieldName.equals(Constants.FieldConstants.ErrorDetailsConstants.EXPERIMENT_ID)){
+                ExperimentResource experiment = defaultGateway.getExperiment((String) value);
+                List<ErrorDetailResource> errorDetails = experiment.getErrorDetails();
+                return ThriftDataModelConversion.getErrorDetailList(errorDetails);
+            }else if (fieldName.equals(Constants.FieldConstants.ErrorDetailsConstants.NODE_ID)){
+                ExperimentResource experiment = (ExperimentResource)defaultGateway.create(ResourceType.EXPERIMENT);
+                WorkflowNodeDetailResource workflowNode = experiment.getWorkflowNode((String)
value);
+                List<ErrorDetailResource> errorDetails = workflowNode.getErrorDetails();
+                return ThriftDataModelConversion.getErrorDetailList(errorDetails);
+            }else if (fieldName.equals(Constants.FieldConstants.ErrorDetailsConstants.TASK_ID)){
+                ExperimentResource experiment = (ExperimentResource)defaultGateway.create(ResourceType.EXPERIMENT);
+                WorkflowNodeDetailResource workflowNode = (WorkflowNodeDetailResource)experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
+                TaskDetailResource taskDetail = workflowNode.getTaskDetail((String) value);
+                List<ErrorDetailResource> errorDetailList = taskDetail.getErrorDetailList();
+                return ThriftDataModelConversion.getErrorDetailList(errorDetailList);
+            }else if (fieldName.equals(Constants.FieldConstants.ErrorDetailsConstants.JOB_ID)){
+                CompositeIdentifier cid = (CompositeIdentifier)value;
+                ExperimentResource experiment = (ExperimentResource)defaultGateway.create(ResourceType.EXPERIMENT);
+                WorkflowNodeDetailResource workflowNode = (WorkflowNodeDetailResource)experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
+                TaskDetailResource taskDetail = workflowNode.getTaskDetail((String)cid.getTopLevelIdentifier());
+                JobDetailResource jobDetail = taskDetail.getJobDetail((String) cid.getSecondLevelIdentifier());
+                List<ErrorDetailResource> errorDetails = jobDetail.getErrorDetails();
+                return ThriftDataModelConversion.getErrorDetailList(errorDetails);
+            }else {
+                logger.error("Unsupported field name to retrieve job details list...");
+            }
+        } catch (ApplicationSettingsException e) {
+            logger.error("Unable to read airavata-server properties", e.getMessage());
+        }
+        return null;
+    }
+
     public Object getExperiment(String expId, String fieldName) {
         try {
             GatewayResource gateway = gatewayRegistry.getDefaultGateway();

http://git-wip-us.apache.org/repos/asf/airavata/blob/b5d57f8b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/RegistryImpl.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/RegistryImpl.java
b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/RegistryImpl.java
index 5a91f04..41f0a11 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/RegistryImpl.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/RegistryImpl.java
@@ -103,6 +103,8 @@ public class RegistryImpl implements Registry {
                 return experimentRegistry.addInputDataHandling((AdvancedInputDataHandling)
newObjectToAdd, (CompositeIdentifier) dependentIdentifier);
             case QOS_PARAM:
                 return experimentRegistry.addQosParams((QualityOfServiceParams)newObjectToAdd,
(CompositeIdentifier)dependentIdentifier);
+            case ERROR_DETAIL:
+                return experimentRegistry.addErrorDetails((ErrorDetails)newObjectToAdd, dependentIdentifier);
             default:
                 logger.error("Unsupported dependent data type...", new UnsupportedOperationException());
                 throw new UnsupportedOperationException();
@@ -223,7 +225,6 @@ public class RegistryImpl implements Registry {
      */
     @Override
     public Object get(DataType dataType, Object identifier) throws Exception {
-
         switch (dataType){
             case EXPERIMENT:
                 return experimentRegistry.getExperiment((String)identifier, null);
@@ -318,6 +319,12 @@ public class RegistryImpl implements Registry {
                     result.add(transferDetails);
                 }
                 return result;
+            case ERROR_DETAIL:
+                List<ErrorDetails> errorDetails = experimentRegistry.getErrorDetails(fieldName,
value);
+                for (ErrorDetails error : errorDetails){
+                    result.add(error);
+                }
+                return result;
             default:
                 logger.error("Unsupported data type...", new UnsupportedOperationException());
                 throw new UnsupportedOperationException();

http://git-wip-us.apache.org/repos/asf/airavata/blob/b5d57f8b/modules/registry/airavata-jpa-registry/src/main/resources/registry-derby.sql
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/resources/registry-derby.sql
b/modules/registry/airavata-jpa-registry/src/main/resources/registry-derby.sql
index d65118c..7b8fb39 100644
--- a/modules/registry/airavata-jpa-registry/src/main/resources/registry-derby.sql
+++ b/modules/registry/airavata-jpa-registry/src/main/resources/registry-derby.sql
@@ -193,6 +193,7 @@ CREATE TABLE ERROR_DETAIL
          EXPERIMENT_ID VARCHAR(255),
          TASK_ID VARCHAR(255),
          NODE_INSTANCE_ID VARCHAR(255),
+         JOB_ID VARCHAR(255),
          CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
          ACTUAL_ERROR_MESSAGE CLOB,
          USER_FRIEDNLY_ERROR_MSG VARCHAR(255),

http://git-wip-us.apache.org/repos/asf/airavata/blob/b5d57f8b/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/utils/Constants.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/utils/Constants.java
b/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/utils/Constants.java
index 4c0cf86..f2579b2 100644
--- a/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/utils/Constants.java
+++ b/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/utils/Constants.java
@@ -79,8 +79,15 @@ public class Constants {
             public static final String TASK_ID = "taskId";
         }
 
-        public final class WorkflowNodeStatus {
+        public final class WorkflowNodeStatusConstants {
             public static final String EXPERIMENT_ID = "experimentId";
         }
+
+        public final class ErrorDetailsConstants {
+            public static final String EXPERIMENT_ID = "experimentId";
+            public static final String NODE_ID = "nodeId";
+            public static final String TASK_ID = "taskId";
+            public static final String JOB_ID = "jobId";
+        }
     }
 }


Mime
View raw message