airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chath...@apache.org
Subject git commit: implementing add method for child objects - AIRAVATA-1006
Date Mon, 24 Feb 2014 16:12:10 GMT
Repository: airavata
Updated Branches:
  refs/heads/master a7f35a3e0 -> 5c7fa2df3


implementing add method for child objects - AIRAVATA-1006


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

Branch: refs/heads/master
Commit: 5c7fa2df30da59deed4a0c7fe5becd8b5891f976
Parents: a7f35a3
Author: chathuri <chathuri@apache.org>
Authored: Mon Feb 24 11:12:03 2014 -0500
Committer: chathuri <chathuri@apache.org>
Committed: Mon Feb 24 11:12:03 2014 -0500

----------------------------------------------------------------------
 .../registry/jpa/impl/ExperimentRegistry.java   | 167 +++++++++++++++++--
 .../registry/jpa/impl/RegistryImpl.java         |  15 +-
 .../jpa/resources/TaskDetailResource.java       |   8 +-
 3 files changed, 161 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/5c7fa2df/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 17e4d7b..b7a25b3 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
@@ -345,10 +345,10 @@ public class ExperimentRegistry {
     }
 
     /**
-     * composite id will contain taskid and jobid
-     * @param status
-     * @param ids
-     * @return
+     *
+     * @param status job status
+     * @param ids composite id will contain taskid and jobid
+     * @return status id
      */
     public String addJobStatus(JobStatus status, CompositeIdentifier ids) {
         try {
@@ -373,10 +373,9 @@ public class ExperimentRegistry {
     }
 
     /**
-     * composite id will contain taskid and jobid
-     * @param status
-     * @param ids
-     * @return
+     * @param status application status
+     * @param ids composite id will contain taskid and jobid
+     * @return status id
      */
     public String addApplicationStatus(ApplicationStatus status, CompositeIdentifier ids)
{
         try {
@@ -400,6 +399,35 @@ public class ExperimentRegistry {
         return null;
     }
 
+    /**
+     *
+     * @param status data transfer status
+     * @param ids contains taskId and transfer id
+     * @return status id
+     */
+    public String addTransferStatus(TransferStatus status, CompositeIdentifier ids) {
+        try {
+            GatewayResource gateway = gatewayRegistry.getDefaultGateway();
+            ExperimentResource experiment = (ExperimentResource)gateway.create(ResourceType.EXPERIMENT);
+            WorkflowNodeDetailResource workflowNode = (WorkflowNodeDetailResource)experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
+            TaskDetailResource taskDetail = workflowNode.getTaskDetail((String) ids.getTopLevelIdentifier());
+            DataTransferDetailResource dataTransferDetail = taskDetail.getDataTransferDetail((String)
ids.getSecondLevelIdentifier());
+            StatusResource statusResource = (StatusResource)dataTransferDetail.create(ResourceType.STATUS);
+            statusResource.setExperimentResource(taskDetail.getWorkflowNodeDetailResource().getExperimentResource());
+            statusResource.setWorkflowNodeDetail(taskDetail.getWorkflowNodeDetailResource());
+            statusResource.setTaskDetailResource(taskDetail);
+            statusResource.setDataTransferDetail(dataTransferDetail);
+            statusResource.setStatusType(StatusType.DATA_TRANSFER.toString());
+            statusResource.setStatusUpdateTime(getTime(status.getTimeOfStateChange()));
+            statusResource.setState(status.getTransferState().toString());
+            statusResource.save();
+            return String.valueOf(statusResource.getStatusId());
+        } catch (ApplicationSettingsException e) {
+            logger.error("Unable to read airavata-server properties", e.getMessage());
+        }
+        return null;
+    }
+
     public String addWorkflowNodeDetails (WorkflowNodeDetails nodeDetails, String expId)
{
         try {
             gatewayRegistry = new GatewayRegistry();
@@ -417,7 +445,7 @@ public class ExperimentRegistry {
             }
             return resource.getNodeInstanceId();
         } catch (ApplicationSettingsException e) {
-            e.printStackTrace();
+            logger.error("Unable to read airavata-server properties", e.getMessage());
         }
         return null;
     }
@@ -466,7 +494,7 @@ public class ExperimentRegistry {
             }
             return taskDetail.getTaskId();
         } catch (ApplicationSettingsException e) {
-            e.printStackTrace();
+            logger.error("Unable to read airavata-server properties", e.getMessage());
         }
         return null;
     }
@@ -498,17 +526,11 @@ public class ExperimentRegistry {
             jobDetail.save();
             return jobDetail.getJobId();
         } catch (ApplicationSettingsException e) {
-            e.printStackTrace();
+            logger.error("Unable to read airavata-server properties", e.getMessage());
         }
         return null;
     }
 
-    /**
-     *
-     * @param transferDetails
-     * @param taskId
-     * @return
-     */
     public String addDataTransferDetails (DataTransferDetails transferDetails, String taskId)
{
         try {
             gatewayRegistry = new GatewayRegistry();
@@ -524,7 +546,116 @@ public class ExperimentRegistry {
             resource.save();
             return resource.getTransferId();
         } catch (ApplicationSettingsException e) {
-            e.printStackTrace();
+            logger.error("Unable to read airavata-server properties", e.getMessage());
+        }
+        return null;
+    }
+
+    /**
+     *
+     * @param scheduling computational resource object
+     * @param ids contains expId and taskId
+     * @return scheduling id
+     */
+    public String addComputationalResourceScheduling (ComputationalResourceScheduling scheduling,
CompositeIdentifier ids){
+        try {
+            gatewayRegistry = new GatewayRegistry();
+            GatewayResource gateway = gatewayRegistry.getDefaultGateway();
+            ExperimentResource experiment = gateway.getExperiment((String) ids.getTopLevelIdentifier());
+            WorkflowNodeDetailResource nodeDetailResource = (WorkflowNodeDetailResource)experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
+            TaskDetailResource taskDetail = nodeDetailResource.getTaskDetail((String) ids.getSecondLevelIdentifier());
+            ComputationSchedulingResource schedulingResource = (ComputationSchedulingResource)experiment.create(ResourceType.COMPUTATIONAL_RESOURCE_SCHEDULING);
+            schedulingResource.setExperimentResource(experiment);
+            schedulingResource.setTaskDetailResource(taskDetail);
+            schedulingResource.setResourceHostId(scheduling.getResourceHostId());
+            schedulingResource.setCpuCount(scheduling.getTotalCPUCount());
+            schedulingResource.setNodeCount(scheduling.getNodeCount());
+            schedulingResource.setNumberOfThreads(scheduling.getNumberOfThreads());
+            schedulingResource.setQueueName(scheduling.getQueueName());
+            schedulingResource.setWalltimeLimit(scheduling.getWallTimeLimit());
+            schedulingResource.setJobStartTime(getTime(scheduling.getJobStartTime()));
+            schedulingResource.setPhysicalMemory(scheduling.getTotalPhysicalMemory());
+            schedulingResource.setProjectName(scheduling.getComputationalProjectAccount());
+            schedulingResource.save();
+            return String.valueOf(schedulingResource.getSchedulingId());
+        } catch (ApplicationSettingsException e) {
+            logger.error("Unable to read airavata-server properties", e.getMessage());
+        }
+        return null;
+    }
+
+    /**
+     *
+     * @param dataHandling advanced input data handling object
+     * @param ids contains expId and taskId
+     * @return data handling id
+     */
+    public String addInputDataHandling (AdvancedInputDataHandling dataHandling, CompositeIdentifier
ids){
+        try {
+            gatewayRegistry = new GatewayRegistry();
+            GatewayResource gateway = gatewayRegistry.getDefaultGateway();
+            ExperimentResource experiment = gateway.getExperiment((String) ids.getTopLevelIdentifier());
+            WorkflowNodeDetailResource nodeDetailResource = (WorkflowNodeDetailResource)experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
+            TaskDetailResource taskDetail = nodeDetailResource.getTaskDetail((String) ids.getSecondLevelIdentifier());
+            AdvanceInputDataHandlingResource dataHandlingResource = (AdvanceInputDataHandlingResource)experiment.create(ResourceType.ADVANCE_INPUT_DATA_HANDLING);
+            dataHandlingResource.setExperimentResource(experiment);
+            dataHandlingResource.setTaskDetailResource(taskDetail);
+            dataHandlingResource.setWorkingDir(dataHandling.getUniqueWorkingDirectory());
+            dataHandlingResource.setWorkingDirParent(dataHandling.getParentWorkingDirectory());
+            dataHandlingResource.setStageInputFiles(dataHandling.isStageInputFilesToWorkingDir());
+            dataHandlingResource.setCleanAfterJob(dataHandling.isCleanUpWorkingDirAfterJob());
+            dataHandlingResource.save();
+            return String.valueOf(dataHandlingResource.getDataHandlingId());
+        } catch (ApplicationSettingsException e) {
+            logger.error("Unable to read airavata-server properties", e.getMessage());
+        }
+        return null;
+    }
+
+    /**
+     *
+     * @param dataHandling advanced output data handling object
+     * @param ids contains expId and taskId
+     * @return data handling id
+     */
+    public String addOutputDataHandling (AdvancedOutputDataHandling dataHandling, CompositeIdentifier
ids){
+        try {
+            gatewayRegistry = new GatewayRegistry();
+            GatewayResource gateway = gatewayRegistry.getDefaultGateway();
+            ExperimentResource experiment = gateway.getExperiment((String) ids.getTopLevelIdentifier());
+            WorkflowNodeDetailResource nodeDetailResource = (WorkflowNodeDetailResource)experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
+            TaskDetailResource taskDetail = nodeDetailResource.getTaskDetail((String) ids.getSecondLevelIdentifier());
+            AdvancedOutputDataHandlingResource dataHandlingResource = (AdvancedOutputDataHandlingResource)experiment.create(ResourceType.ADVANCE_OUTPUT_DATA_HANDLING);
+            dataHandlingResource.setExperimentResource(experiment);
+            dataHandlingResource.setTaskDetailResource(taskDetail);
+            dataHandlingResource.setOutputDataDir(dataHandling.getOutputDataDir());
+            dataHandlingResource.setDataRegUrl(dataHandling.getDataRegistryURL());
+            dataHandlingResource.setPersistOutputData(dataHandling.isPersistOutputData());
+            dataHandlingResource.save();
+            return String.valueOf(dataHandlingResource.getOutputDataHandlingId());
+        } catch (ApplicationSettingsException e) {
+            logger.error("Unable to read airavata-server properties", e.getMessage());
+        }
+        return null;
+    }
+
+    public String addQosParams (QualityOfServiceParams qosParams, CompositeIdentifier ids){
+        try {
+            gatewayRegistry = new GatewayRegistry();
+            GatewayResource gateway = gatewayRegistry.getDefaultGateway();
+            ExperimentResource experiment = gateway.getExperiment((String) ids.getTopLevelIdentifier());
+            WorkflowNodeDetailResource nodeDetailResource = (WorkflowNodeDetailResource)experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
+            TaskDetailResource taskDetail = nodeDetailResource.getTaskDetail((String) ids.getSecondLevelIdentifier());
+            QosParamResource qosParamResource = (QosParamResource)experiment.create(ResourceType.QOS_PARAM);
+            qosParamResource.setExperimentResource(experiment);
+            qosParamResource.setTaskDetailResource(taskDetail);
+            qosParamResource.setStartExecutionAt(qosParams.getStartExecutionAt());
+            qosParamResource.setExecuteBefore(qosParams.getExecuteBefore());
+            qosParamResource.setNoOfRetries(qosParams.getNumberofRetries());
+            qosParamResource.save();
+            return String.valueOf(qosParamResource.getQosId());
+        } catch (ApplicationSettingsException e) {
+            logger.error("Unable to read airavata-server properties", e.getMessage());
         }
         return null;
     }

http://git-wip-us.apache.org/repos/asf/airavata/blob/5c7fa2df/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 7d5c185..67121ab 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
@@ -94,22 +94,19 @@ public class RegistryImpl implements Registry {
             case DATA_TRANSFER_DETAIL:
                 return experimentRegistry.addDataTransferDetails((DataTransferDetails)newObjectToAdd,
(String)dependentIdentifier);
             case TRANSFER_STATUS:
-
+                return experimentRegistry.addTransferStatus((TransferStatus)newObjectToAdd,
(CompositeIdentifier)dependentIdentifier);
             case COMPUTATIONAL_RESOURCE_SCHEDULING:
-                // no thrift model yet
-                break;
+                return experimentRegistry.addComputationalResourceScheduling((ComputationalResourceScheduling)newObjectToAdd,
(CompositeIdentifier)dependentIdentifier);
             case ADVANCE_OUTPUT_DATA_HANDLING:
-                // no thrift model yet
-                break;
+                return experimentRegistry.addOutputDataHandling((AdvancedOutputDataHandling)newObjectToAdd,
(CompositeIdentifier)dependentIdentifier);
+            case ADVANCE_INPUT_DATA_HANDLING:
+                return experimentRegistry.addInputDataHandling((AdvancedInputDataHandling)newObjectToAdd,
(CompositeIdentifier)dependentIdentifier);
             case QOS_PARAM:
-                // no thrift model yet
-                break;
+                return experimentRegistry.addQosParams((QualityOfServiceParams)newObjectToAdd,
(CompositeIdentifier)dependentIdentifier);
             default:
                 logger.error("Unsupported dependent data type...", new UnsupportedOperationException());
                 throw new UnsupportedOperationException();
         }
-        return null;
-
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/airavata/blob/5c7fa2df/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/TaskDetailResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/TaskDetailResource.java
b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/TaskDetailResource.java
index 60c3651..641b7bd 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/TaskDetailResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/TaskDetailResource.java
@@ -244,7 +244,7 @@ public class TaskDetailResource extends AbstractResource {
                 return outputResource;
             case JOB_DETAIL:
                 generator = new QueryGenerator(JOB_DETAIL);
-                generator.setParameter(JobDetailConstants.TASK_ID, name);
+                generator.setParameter(JobDetailConstants.JOB_ID, name);
                 q = generator.selectQuery(em);
                 JobDetail jobDetail = (JobDetail)q.getSingleResult();
                 JobDetailResource jobDetailResource = (JobDetailResource)Utils.getResource(ResourceType.JOB_DETAIL,
jobDetail);
@@ -253,7 +253,7 @@ public class TaskDetailResource extends AbstractResource {
                 return jobDetailResource;
             case DATA_TRANSFER_DETAIL:
                 generator = new QueryGenerator(DATA_TRANSFER_DETAIL);
-                generator.setParameter(DataTransferDetailConstants.TASK_ID, name);
+                generator.setParameter(DataTransferDetailConstants.TRANSFER_ID, name);
                 q = generator.selectQuery(em);
                 DataTransferDetail transferDetail = (DataTransferDetail)q.getSingleResult();
                 DataTransferDetailResource transferDetailResource = (DataTransferDetailResource)Utils.getResource(ResourceType.DATA_TRANSFER_DETAIL,
transferDetail);
@@ -531,4 +531,8 @@ public class TaskDetailResource extends AbstractResource {
         return (JobDetailResource)get(ResourceType.JOB_DETAIL, jobId);
     }
 
+    public DataTransferDetailResource getDataTransferDetail (String dataTransferId){
+        return (DataTransferDetailResource)get(ResourceType.TASK_DETAIL, dataTransferId);
+    }
+
 }


Mime
View raw message