airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chath...@apache.org
Subject git commit: AIRAVATA-1049
Date Tue, 04 Mar 2014 19:51:55 GMT
Repository: airavata
Updated Branches:
  refs/heads/master b7b80180a -> 5b62ef6ac


AIRAVATA-1049


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

Branch: refs/heads/master
Commit: 5b62ef6ac04b97b4f851d2bfe13a0c5385f2c588
Parents: b7b8018
Author: chathuri <chathuri@apache.org>
Authored: Tue Mar 4 14:51:48 2014 -0500
Committer: chathuri <chathuri@apache.org>
Committed: Tue Mar 4 14:51:48 2014 -0500

----------------------------------------------------------------------
 .../client/samples/CreateLaunchExperiment.java  |  1 +
 .../registry/jpa/impl/ExperimentRegistry.java   | 38 +++++++++++++++++---
 .../jpa/resources/JobDetailResource.java        |  4 +--
 .../registry/jpa/resources/StatusResource.java  | 12 +++++--
 .../jpa/utils/ThriftDataModelConversion.java    | 17 ++++-----
 5 files changed, 55 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/5b62ef6a/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java
b/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java
index c232fa0..6bf809f 100644
--- a/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java
+++ b/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java
@@ -85,6 +85,7 @@ public class CreateLaunchExperiment {
                                      }
                                  }
                              }
+                             Thread.sleep(5000);
                          } catch (Exception e) {
                              e.printStackTrace();  //To change body of catch statement use
File | Settings | File Templates.
                          }

http://git-wip-us.apache.org/repos/asf/airavata/blob/5b62ef6a/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 9177dd0..49a5403 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
@@ -510,9 +510,12 @@ public class ExperimentRegistry {
             TaskDetailResource taskDetail = (TaskDetailResource) workflowNode.create(ResourceType.TASK_DETAIL);
             JobDetailResource jobDetail = taskDetail.getJobDetail(jobId);
             StatusResource statusResource = jobDetail.getJobStatus();
-            statusResource.setExperimentResource(jobDetail.getTaskDetailResource().getWorkflowNodeDetailResource().getExperimentResource());
-            statusResource.setWorkflowNodeDetail(jobDetail.getTaskDetailResource().getWorkflowNodeDetailResource());
-            statusResource.setTaskDetailResource(jobDetail.getTaskDetailResource());
+            taskDetail = jobDetail.getTaskDetailResource();
+            workflowNode = taskDetail.getWorkflowNodeDetailResource();
+            experiment = workflowNode.getExperimentResource();
+            statusResource.setExperimentResource(experiment);
+            statusResource.setWorkflowNodeDetail(workflowNode);
+            statusResource.setTaskDetailResource(taskDetail);
             statusResource.setStatusType(StatusType.JOB.toString());
             statusResource.setStatusUpdateTime(getTime(status.getTimeOfStateChange()));
             statusResource.setState(status.getJobState().toString());
@@ -934,11 +937,38 @@ public class ExperimentRegistry {
             WorkflowNodeDetailResource workflowNode = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
             TaskDetailResource taskDetail = (TaskDetailResource) workflowNode.create(ResourceType.TASK_DETAIL);
             JobDetailResource jobDetail = taskDetail.getJobDetail(jobId);
-            jobDetail.setTaskDetailResource(jobDetail.getTaskDetailResource());
+            TaskDetailResource taskDetailResource = jobDetail.getTaskDetailResource();
+            jobDetail.setTaskDetailResource(taskDetailResource);
             jobDetail.setJobDescription(jobDetails.getJobDescription());
             jobDetail.setCreationTime(getTime(jobDetails.getCreationTime()));
             jobDetail.setComputeResourceConsumed(jobDetails.getComputeResourceConsumed());
             jobDetail.save();
+            String taskId = taskDetailResource.getTaskId();
+            CompositeIdentifier ids = new CompositeIdentifier(taskId, jobId);
+            JobStatus jobStatus = jobDetails.getJobStatus();
+            if (jobStatus != null){
+                JobStatus status = getJobStatus(ids);
+                if (status != null){
+                    updateJobStatus(jobStatus, jobId);
+                }else {
+                    addJobStatus(jobStatus, ids);
+                }
+            }
+            ApplicationStatus applicationStatus = jobDetails.getApplicationStatus();
+            if (applicationStatus != null){
+                ApplicationStatus appStatus = getApplicationStatus(ids);
+                if (appStatus != null){
+                    updateApplicationStatus(applicationStatus, jobId);
+                }else {
+                    addApplicationStatus(applicationStatus, ids);
+                }
+            }
+            List<ErrorDetails> errors = jobDetails.getErrors();
+            if (errors != null && !errors.isEmpty()){
+                for (ErrorDetails error : errors ){
+                    addErrorDetails(error, jobId);
+                }
+            }
         } catch (Exception e) {
             logger.error("Error while updating job details...", e.getMessage());
             throw new Exception(e);

http://git-wip-us.apache.org/repos/asf/airavata/blob/5b62ef6a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/JobDetailResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/JobDetailResource.java
b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/JobDetailResource.java
index 6bdebb9..bb120ca 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/JobDetailResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/JobDetailResource.java
@@ -244,7 +244,7 @@ public class JobDetailResource extends AbstractResource {
         List<Resource> resources = get(ResourceType.STATUS);
         for (Resource resource : resources) {
             StatusResource jobStatus = (StatusResource) resource;
-            if(jobStatus.getStatusType().equals(StatusType.JOB)){
+            if(jobStatus.getStatusType().equals(StatusType.JOB.toString())){
                 return jobStatus;
             }
         }
@@ -255,7 +255,7 @@ public class JobDetailResource extends AbstractResource {
         List<Resource> resources = get(ResourceType.STATUS);
         for (Resource resource : resources) {
             StatusResource appStatus = (StatusResource) resource;
-            if(appStatus.getStatusType().equals(StatusType.APPLICATION)){
+            if(appStatus.getStatusType().equals(StatusType.APPLICATION.toString())){
                 return appStatus;
             }
         }

http://git-wip-us.apache.org/repos/asf/airavata/blob/5b62ef6a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/StatusResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/StatusResource.java
b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/StatusResource.java
index db2e8d3..426b9c4 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/StatusResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/StatusResource.java
@@ -34,7 +34,7 @@ import java.util.List;
 
 public class StatusResource extends AbstractResource {
     private static final Logger logger = LoggerFactory.getLogger(StatusResource.class);
-    private int statusId;
+    private int statusId = 0;
     private ExperimentResource experimentResource;
     private WorkflowNodeDetailResource workflowNodeDetail;
     private DataTransferDetailResource dataTransferDetail;
@@ -144,7 +144,14 @@ public class StatusResource extends AbstractResource {
     public void save() {
         EntityManager em = ResourceUtils.getEntityManager();
         em.getTransaction().begin();
-        Status status = new Status();
+        Status status;
+        if (statusId != 0){
+            status = em.find(Status.class, statusId);
+            status.setStatusId(statusId);
+        }else {
+            status = new Status();
+        }
+
         Experiment experiment = em.find(Experiment.class, experimentResource.getExpID());
         if (taskDetailResource != null){
             TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId());
@@ -161,7 +168,6 @@ public class StatusResource extends AbstractResource {
             status.setTransferDetail(transferDetail);
             status.setTransferId(dataTransferDetail.getTransferId());
         }
-        status.setStatusId(statusId);
         status.setExperiment(experiment);
         status.setJobId(jobId);
         status.setExpId(experimentResource.getExpID());

http://git-wip-us.apache.org/repos/asf/airavata/blob/5b62ef6a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/utils/ThriftDataModelConversion.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/utils/ThriftDataModelConversion.java
b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/utils/ThriftDataModelConversion.java
index 53c94d2..bfeb75f 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/utils/ThriftDataModelConversion.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/utils/ThriftDataModelConversion.java
@@ -229,31 +229,33 @@ public class ThriftDataModelConversion {
     }
 
     public static JobStatus getJobStatus (StatusResource status){
-        JobStatus jobStatus = new JobStatus();
         if (status != null){
+            JobStatus jobStatus = new JobStatus();
             jobStatus.setJobState(JobState.valueOf(status.getState()));
             jobStatus.setTimeOfStateChange(status.getStatusUpdateTime().getTime());
+            return jobStatus;
         }
-        return jobStatus;
+        return null;
     }
 
     public static TransferStatus getTransferStatus (StatusResource status){
-        TransferStatus transferStatus = new TransferStatus();
         if (status != null){
+            TransferStatus transferStatus = new TransferStatus();
             transferStatus.setTransferState(TransferState.valueOf(status.getState()));
             transferStatus.setTimeOfStateChange(status.getStatusUpdateTime().getTime());
+            return transferStatus;
         }
-
-        return transferStatus;
+        return null;
     }
 
     public static ApplicationStatus getApplicationStatus (StatusResource status){
-        ApplicationStatus applicationStatus = new ApplicationStatus();
         if (status != null){
+            ApplicationStatus applicationStatus = new ApplicationStatus();
             applicationStatus.setApplicationState(status.getState());
             applicationStatus.setTimeOfStateChange(status.getStatusUpdateTime().getTime());
+            return applicationStatus;
         }
-        return applicationStatus;
+        return null;
     }
 
     public static List<WorkflowNodeStatus> getWorkflowNodeStatusList(List<StatusResource>
statuses){
@@ -282,7 +284,6 @@ public class ThriftDataModelConversion {
             List<ErrorDetailResource> errorDetails = nodeDetailResource.getErrorDetails();
             wfNode.setErrors(getErrorDetailList(errorDetails));
         }
-
         return wfNode;
     }
 


Mime
View raw message