Repository: airavata Updated Branches: refs/heads/master 636a733bf -> f200d50be
Changing the unique key of the JobModel Project: http://git-wip-us.apache.org/repos/asf/airavata/repo Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/aa2fab54 Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/aa2fab54 Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/aa2fab54 Branch: refs/heads/master Commit: aa2fab54be0eae061769c4aca751ae50594bbc38 Parents: a2dce4f Author: Supun Nakandala <[email protected]> Authored: Thu Jun 25 20:48:37 2015 +0530 Committer: Supun Nakandala <[email protected]> Committed: Thu Jun 25 20:48:37 2015 +0530 ---------------------------------------------------------------------- .../catalog/impl/ExperimentCatalogImpl.java | 14 ++-- .../catalog/impl/ExperimentRegistry.java | 38 +++++++--- .../core/experiment/catalog/model/Job.java | 3 +- .../core/experiment/catalog/model/JobPK.java | 74 ++++++++++++++++++++ .../experiment/catalog/model/JobStatus.java | 11 +++ .../experiment/catalog/model/JobStatusPK.java | 13 ++++ .../resources/AbstractExpCatResource.java | 1 + .../resources/ExperimentStatusResource.java | 1 + .../catalog/resources/JobResource.java | 7 +- .../catalog/resources/JobStatusResource.java | 16 ++++- .../resources/ProcessStatusResource.java | 1 + .../catalog/resources/TaskResource.java | 5 +- .../catalog/resources/TaskStatusResource.java | 1 + .../src/main/resources/expcatalog-derby.sql | 5 +- .../src/main/resources/expcatalog-mysql.sql | 5 +- .../src/test/resources/expcatalog-derby.sql | 5 +- 16 files changed, 171 insertions(+), 29 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata/blob/aa2fab54/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ExperimentCatalogImpl.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ExperimentCatalogImpl.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ExperimentCatalogImpl.java index 014140e..f9648ff 100644 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ExperimentCatalogImpl.java +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ExperimentCatalogImpl.java @@ -178,7 +178,7 @@ public class ExperimentCatalogImpl implements ExperimentCatalog { case JOB: return experimentRegistry.addJob((JobModel) newObjectToAdd, (String) dependentIdentifier); case JOB_STATUS: - return experimentRegistry.addJobStatus((JobStatus) newObjectToAdd, (String) dependentIdentifier); + return experimentRegistry.addJobStatus((JobStatus) newObjectToAdd, (CompositeIdentifier) dependentIdentifier); default: logger.error("Unsupported dependent data type...", new UnsupportedOperationException()); throw new UnsupportedOperationException(); @@ -251,10 +251,10 @@ public class ExperimentCatalogImpl implements ExperimentCatalog { experimentRegistry.updateTaskError((ErrorModel) newObjectToUpdate, (String) identifier); break; case JOB: - experimentRegistry.updateJob((JobModel) newObjectToUpdate, (String) identifier); + experimentRegistry.updateJob((JobModel) newObjectToUpdate, (CompositeIdentifier) identifier); break; case JOB_STATUS: - experimentRegistry.updateJobStatus((JobStatus) newObjectToUpdate, (String) identifier); + experimentRegistry.updateJobStatus((JobStatus) newObjectToUpdate, (CompositeIdentifier) identifier); break; default: logger.error("Unsupported data type...", new UnsupportedOperationException()); @@ -349,9 +349,9 @@ public class ExperimentCatalogImpl implements ExperimentCatalog { case TASK_ERROR: return experimentRegistry.getTaskError((String) identifier); case JOB: - return experimentRegistry.getJob((String) identifier, null); + return experimentRegistry.getJob((CompositeIdentifier) identifier, null); case JOB_STATUS: - return experimentRegistry.getJobStatus((String) identifier); + return experimentRegistry.getJobStatus((CompositeIdentifier) identifier); default: logger.error("Unsupported data type...", new UnsupportedOperationException()); throw new UnsupportedOperationException(); @@ -630,7 +630,7 @@ public class ExperimentCatalogImpl implements ExperimentCatalog { experimentRegistry.removeTask((String) identifier); break; case JOB: - experimentRegistry.removeJob((String) identifier); + experimentRegistry.removeJob((CompositeIdentifier) identifier); break; default: logger.error("Unsupported data type...", new UnsupportedOperationException()); @@ -671,7 +671,7 @@ public class ExperimentCatalogImpl implements ExperimentCatalog { case TASK: return experimentRegistry.isTaskExist((String) identifier); case JOB: - return experimentRegistry.isJobExist((String) identifier); + return experimentRegistry.isJobExist((CompositeIdentifier) identifier); default: logger.error("Unsupported data type...", new UnsupportedOperationException()); throw new UnsupportedOperationException(); http://git-wip-us.apache.org/repos/asf/airavata/blob/aa2fab54/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ExperimentRegistry.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ExperimentRegistry.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ExperimentRegistry.java index 75218b7..7c3fe0a 100644 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ExperimentRegistry.java +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ExperimentRegistry.java @@ -38,6 +38,7 @@ import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils; import org.apache.airavata.registry.core.experiment.catalog.ResourceType; import org.apache.airavata.registry.core.experiment.catalog.resources.*; import org.apache.airavata.registry.core.experiment.catalog.utils.ThriftDataModelConversion; +import org.apache.airavata.registry.cpi.CompositeIdentifier; import org.apache.airavata.registry.cpi.RegistryException; import org.apache.airavata.registry.cpi.ResultOrderType; import org.apache.airavata.registry.cpi.utils.Constants; @@ -463,7 +464,7 @@ public class ExperimentRegistry { public String addJob(JobModel job, String taskId) throws RegistryException { try { JobResource jobResource = new JobResource(); - jobResource.setJobId(getJobID(taskId)); + jobResource.setJobId(job.getJobId()); jobResource.setTaskId(taskId); jobResource.setJobDescription(job.getJobDescription()); jobResource.setCreationTime(AiravataUtils.getTime(job.getCreationTime())); @@ -481,7 +482,9 @@ public class ExperimentRegistry { return taskId; } - public String addJobStatus(JobStatus jobStatus, String jobID) throws RegistryException { + public String addJobStatus(JobStatus jobStatus, CompositeIdentifier cis) throws RegistryException { + String taskID = (String)cis.getTopLevelIdentifier(); + String jobID = (String)cis.getSecondLevelIdentifier(); try { JobResource jobResource = new JobResource(); jobResource.setJobId(jobID); @@ -492,6 +495,7 @@ public class ExperimentRegistry { if (isValidStatusTransition(ProcessState.valueOf(status.getState()), jobStatus.getJobState())) { status.setStatusId(getStatusID(jobID)); status.setJobId(jobID); + status.setTaskId(taskID); status.setTimeOfStateChange(AiravataUtils.getTime(jobStatus.getTimeOfStateChange())); status.setState(jobStatus.getJobState().toString()); status.setReason(jobStatus.getReason()); @@ -807,10 +811,13 @@ public class ExperimentRegistry { return addTaskError(taskError, taskID); } - public String updateJob(JobModel job, String jobId) throws RegistryException { + public String updateJob(JobModel job, CompositeIdentifier cis) throws RegistryException { + String taskId = (String) cis.getTopLevelIdentifier(); + String jobId = (String) cis.getSecondLevelIdentifier(); try { TaskResource taskResource = new TaskResource(); - JobResource jobResource = taskResource.getJob(jobId); + taskResource.setTaskId(taskId); + JobResource jobResource = taskResource.getJob(taskId, jobId); jobResource.setJobId(jobId); jobResource.setTaskId(job.getTaskId()); jobResource.setJobDescription(job.getJobDescription()); @@ -829,8 +836,8 @@ public class ExperimentRegistry { return jobId; } - public String updateJobStatus(JobStatus jobStatus, String jobID) throws RegistryException { - return addJobStatus(jobStatus, jobID); + public String updateJobStatus(JobStatus jobStatus, CompositeIdentifier cis) throws RegistryException { + return addJobStatus(jobStatus, cis); } @@ -1038,10 +1045,13 @@ public class ExperimentRegistry { return null; } - public Object getJob(String jobId, String fieldName) throws RegistryException { + public Object getJob(CompositeIdentifier cis, String fieldName) throws RegistryException { + String taskID = (String) cis.getTopLevelIdentifier(); + String jobId = (String) cis.getSecondLevelIdentifier(); try { TaskResource taskResource = new TaskResource(); - JobResource resource = taskResource.getJob(jobId); + taskResource.setTaskId(taskID); + JobResource resource = taskResource.getJob(taskID, jobId); if (fieldName == null) { return ThriftDataModelConversion.getJobModel(resource); } else { @@ -1054,7 +1064,7 @@ public class ExperimentRegistry { return null; } - public Object getJobStatus(String identifier) { + public Object getJobStatus(CompositeIdentifier cis) { return null; } @@ -1353,9 +1363,12 @@ public class ExperimentRegistry { } } - public void removeJob(String jobId) throws RegistryException { + public void removeJob(CompositeIdentifier cis) throws RegistryException { try { + String taskId = (String) cis.getTopLevelIdentifier(); + String jobId = (String) cis.getSecondLevelIdentifier(); TaskResource taskResource = new TaskResource(); + taskResource.setTaskId(taskId); taskResource.remove(ResourceType.JOB, jobId); } catch (Exception e) { logger.error("Error while removing task details..", e); @@ -1416,9 +1429,12 @@ public class ExperimentRegistry { } - public boolean isJobExist(String jobId) throws RegistryException { + public boolean isJobExist(CompositeIdentifier cis) throws RegistryException { + String taskId = (String) cis.getTopLevelIdentifier(); + String jobId = (String) cis.getSecondLevelIdentifier(); try { TaskResource taskResource = new TaskResource(); + taskResource.setTaskId(taskId); return taskResource.isExists(ResourceType.JOB, jobId); } catch (Exception e) { logger.error("Error while retrieving job.....", e); http://git-wip-us.apache.org/repos/asf/airavata/blob/aa2fab54/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/Job.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/Job.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/Job.java index 95e1f1d..3347263 100644 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/Job.java +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/Job.java @@ -28,6 +28,7 @@ import java.sql.Timestamp; import java.util.Collection; @Entity +@IdClass(JobPK.class) public class Job { private final static Logger logger = LoggerFactory.getLogger(Job.class); private String jobId; @@ -50,7 +51,7 @@ public class Job { this.jobId = jobId; } - @Basic + @Id @Column(name = "TASK_ID") public String getTaskId() { return taskId; http://git-wip-us.apache.org/repos/asf/airavata/blob/aa2fab54/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/JobPK.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/JobPK.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/JobPK.java new file mode 100644 index 0000000..eb704d5 --- /dev/null +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/JobPK.java @@ -0,0 +1,74 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ +package org.apache.airavata.registry.core.experiment.catalog.model; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.persistence.Column; +import javax.persistence.Id; +import java.io.Serializable; + +public class JobPK implements Serializable { + private final static Logger logger = LoggerFactory.getLogger(JobPK.class); + private String jobId; + private String taskId; + + @Id + @Column(name = "JOB_ID") + public String getJobId() { + return jobId; + } + + public void setJobId(String jobId) { + this.jobId = jobId; + } + + @Id + @Column(name = "TASK_ID") + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + JobPK that = (JobPK) o; + + if (getJobId() != null ? !getJobId().equals(that.getJobId()) : that.getJobId() != null) return false; + if (getTaskId() != null ? !getTaskId().equals(that.getTaskId()) : that.getTaskId() != null) return false; + + return true; + } + + @Override + public int hashCode() { + int result = getJobId() != null ? getJobId().hashCode() : 0; + result = 31 * result + (getTaskId() != null ? getTaskId().hashCode() : 0); + return result; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/aa2fab54/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/JobStatus.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/JobStatus.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/JobStatus.java index 49735ff..c93d1cb 100644 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/JobStatus.java +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/JobStatus.java @@ -33,6 +33,7 @@ public class JobStatus { private final static Logger logger = LoggerFactory.getLogger(JobStatus.class); private String statusId; private String jobId; + private String taskId; private String state; private Timestamp timeOfStateChange; private String reason; @@ -58,6 +59,16 @@ public class JobStatus { this.jobId = jobId; } + @Id + @Column(name = "TASK_ID") + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + @Basic @Column(name = "STATE") public String getState() { http://git-wip-us.apache.org/repos/asf/airavata/blob/aa2fab54/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/JobStatusPK.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/JobStatusPK.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/JobStatusPK.java index 672319b..cac3c52 100644 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/JobStatusPK.java +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/JobStatusPK.java @@ -31,6 +31,7 @@ public class JobStatusPK implements Serializable { private final static Logger logger = LoggerFactory.getLogger(JobStatusPK.class); private String statusId; private String jobId; + private String taskId; @Id @Column(name = "STATUS_ID") @@ -52,6 +53,16 @@ public class JobStatusPK implements Serializable { this.jobId = jobId; } + @Id + @Column(name = "TASK_ID") + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -61,6 +72,7 @@ public class JobStatusPK implements Serializable { if (getStatusId() != null ? !getStatusId().equals(that.getStatusId()) : that.getStatusId() != null) return false; if (getJobId() != null ? !getJobId().equals(that.getJobId()) : that.getJobId() != null) return false; + if (getTaskId() != null ? !getTaskId().equals(that.getTaskId()) : that.getTaskId() != null) return false; return true; } @@ -69,6 +81,7 @@ public class JobStatusPK implements Serializable { public int hashCode() { int result = getStatusId() != null ? getStatusId().hashCode() : 0; result = 31 * result + (getJobId() != null ? getJobId().hashCode() : 0); + result = 31 * result + (getTaskId() != null ? getTaskId().hashCode() : 0); return result; } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/aa2fab54/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/AbstractExpCatResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/AbstractExpCatResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/AbstractExpCatResource.java index 8608d65..315e2e8 100644 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/AbstractExpCatResource.java +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/AbstractExpCatResource.java @@ -227,6 +227,7 @@ public abstract class AbstractExpCatResource implements ExperimentCatResource { public final class JobStatusConstants { public static final String STATUS_ID = "statusId"; public static final String JOB_ID = "jobId"; + public static final String TASK_ID = "taskId"; public static final String STATE = "state"; public static final String TIME_OF_STATE_CHANGE = "timeOfStateChange"; public static final String REASON = "reason"; http://git-wip-us.apache.org/repos/asf/airavata/blob/aa2fab54/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentStatusResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentStatusResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentStatusResource.java index 558762e..9cb4747 100644 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentStatusResource.java +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentStatusResource.java @@ -122,6 +122,7 @@ public class ExperimentStatusResource extends AbstractExpCatResource { if(experimentStatus == null){ experimentStatus = new ExperimentStatus(); } + experimentStatus.setStatusId(statusId); experimentStatus.setExperimentId(experimentId); experimentStatus.setState(state); experimentStatus.setReason(reason); http://git-wip-us.apache.org/repos/asf/airavata/blob/aa2fab54/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobResource.java index 55bdd98..6ed5a54 100644 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobResource.java +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobResource.java @@ -25,6 +25,7 @@ import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils; import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource; import org.apache.airavata.registry.core.experiment.catalog.ResourceType; import org.apache.airavata.registry.core.experiment.catalog.model.Job; +import org.apache.airavata.registry.core.experiment.catalog.model.JobPK; import org.apache.airavata.registry.core.experiment.catalog.model.JobStatus; import org.apache.airavata.registry.core.experiment.catalog.utils.QueryGenerator; import org.apache.airavata.registry.cpi.RegistryException; @@ -200,6 +201,7 @@ public class JobResource extends AbstractExpCatResource { case JOB_STATUS: generator = new QueryGenerator(JOB_STATUS); generator.setParameter(JobStatusConstants.JOB_ID, jobId); + generator.setParameter(JobStatusConstants.TASK_ID, taskId); q = generator.selectQuery(em); results = q.getResultList(); if (results.size() != 0) { @@ -239,7 +241,10 @@ public class JobResource extends AbstractExpCatResource { try { em = ExpCatResourceUtils.getEntityManager(); em.getTransaction().begin(); - Job job = em.find(Job.class, jobId); + JobPK jobPK = new JobPK(); + jobPK.setJobId(jobId); + jobPK.setTaskId(taskId); + Job job = em.find(Job.class, jobPK); if(job == null){ job = new Job(); } http://git-wip-us.apache.org/repos/asf/airavata/blob/aa2fab54/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobStatusResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobStatusResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobStatusResource.java index 5c0e3b2..4085a3b 100644 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobStatusResource.java +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobStatusResource.java @@ -38,6 +38,7 @@ public class JobStatusResource extends AbstractExpCatResource { private static final Logger logger = LoggerFactory.getLogger(JobStatusResource.class); private String statusId; private String jobId; + private String taskId; private String state; private Timestamp timeOfStateChange; private String reason; @@ -58,6 +59,14 @@ public class JobStatusResource extends AbstractExpCatResource { this.jobId = jobId; } + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + public String getState() { return state; } @@ -112,17 +121,20 @@ public class JobStatusResource extends AbstractExpCatResource { em = ExpCatResourceUtils.getEntityManager(); em.getTransaction().begin(); JobStatus jobStatus; - if(jobId == null || statusId == null){ - throw new RegistryException("Does not have the job id or status id"); + if(jobId == null || statusId == null || taskId == null){ + throw new RegistryException("Does not have the job id or status id or task id"); } JobStatusPK jobStatusPK = new JobStatusPK(); jobStatusPK.setJobId(jobId); jobStatusPK.setStatusId(statusId); + jobStatusPK.setTaskId(taskId); jobStatus = em.find(JobStatus.class, jobStatusPK); if(jobStatus == null){ jobStatus = new JobStatus(); } + jobStatus.setStatusId(statusId); jobStatus.setJobId(jobId); + jobStatus.setTaskId(taskId); jobStatus.setState(state); jobStatus.setReason(reason); em.persist(jobStatus); http://git-wip-us.apache.org/repos/asf/airavata/blob/aa2fab54/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessStatusResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessStatusResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessStatusResource.java index 6892510..de8c81b 100644 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessStatusResource.java +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessStatusResource.java @@ -122,6 +122,7 @@ public class ProcessStatusResource extends AbstractExpCatResource { if(processStatus == null){ processStatus = new ProcessStatus(); } + processStatus.setStatusId(statusId); processStatus.setProcessId(processId); processStatus.setState(state); processStatus.setReason(reason); http://git-wip-us.apache.org/repos/asf/airavata/blob/aa2fab54/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskResource.java index 5d90e4f..5d69bc1 100644 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskResource.java +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskResource.java @@ -149,6 +149,7 @@ public class TaskResource extends AbstractExpCatResource { case JOB: generator = new QueryGenerator(JOB); generator.setParameter(JobConstants.JOB_ID, name); + generator.setParameter(JobConstants.TASK_ID, taskId); q = generator.deleteQuery(em); q.executeUpdate(); break; @@ -203,6 +204,7 @@ public class TaskResource extends AbstractExpCatResource { case JOB: generator = new QueryGenerator(JOB); generator.setParameter(JobConstants.JOB_ID, name); + generator.setParameter(JobConstants.TASK_ID, taskId); q = generator.selectQuery(em); Job job = (Job) q.getSingleResult(); JobResource jobResource = (JobResource) Utils.getResource(ResourceType.JOB, job); @@ -372,7 +374,8 @@ public class TaskResource extends AbstractExpCatResource { } } - public JobResource getJob(String jobId) throws RegistryException { + public JobResource getJob(String taskId, String jobId) throws RegistryException { + this.taskId = taskId; return (JobResource) get(ResourceType.JOB, jobId); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/aa2fab54/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskStatusResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskStatusResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskStatusResource.java index fbc812f..85c9eb9 100644 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskStatusResource.java +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskStatusResource.java @@ -122,6 +122,7 @@ public class TaskStatusResource extends AbstractExpCatResource { if(taskStatus == null){ taskStatus = new TaskStatus(); } + taskStatus.setStatusId(statusId); taskStatus.setTaskId(taskId); taskStatus.setState(state); taskStatus.setReason(reason); http://git-wip-us.apache.org/repos/asf/airavata/blob/aa2fab54/modules/registry/registry-core/src/main/resources/expcatalog-derby.sql ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/resources/expcatalog-derby.sql b/modules/registry/registry-core/src/main/resources/expcatalog-derby.sql index 63f40ef..6ad715c 100644 --- a/modules/registry/registry-core/src/main/resources/expcatalog-derby.sql +++ b/modules/registry/registry-core/src/main/resources/expcatalog-derby.sql @@ -300,17 +300,18 @@ CREATE TABLE JOB ( COMPUTE_RESOURCE_CONSUMED varchar(255), JOB_NAME varchar(255), WORKING_DIR varchar(255), - PRIMARY KEY (JOB_ID), + PRIMARY KEY (JOB_ID, TASK_ID), FOREIGN KEY (TASK_ID) REFERENCES TASK(TASK_ID) ON DELETE CASCADE ); CREATE TABLE JOB_STATUS ( STATUS_ID varchar(255), JOB_ID varchar(255), + TASK_ID varchar(255), STATE varchar(255), TIME_OF_STATE_CHANGE timestamp DEFAULT '0000-00-00 00:00:00', REASON CLOB, - PRIMARY KEY (STATUS_ID, JOB_ID), + PRIMARY KEY (STATUS_ID, JOB_ID, TASK_ID), FOREIGN KEY (JOB_ID) REFERENCES JOB(JOB_ID) ON DELETE CASCADE ); http://git-wip-us.apache.org/repos/asf/airavata/blob/aa2fab54/modules/registry/registry-core/src/main/resources/expcatalog-mysql.sql ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/resources/expcatalog-mysql.sql b/modules/registry/registry-core/src/main/resources/expcatalog-mysql.sql index 56a3d3a..a446386 100644 --- a/modules/registry/registry-core/src/main/resources/expcatalog-mysql.sql +++ b/modules/registry/registry-core/src/main/resources/expcatalog-mysql.sql @@ -302,17 +302,18 @@ CREATE TABLE JOB ( COMPUTE_RESOURCE_CONSUMED varchar(255), JOB_NAME varchar(255), WORKING_DIR varchar(255), - PRIMARY KEY (JOB_ID), + PRIMARY KEY (JOB_ID, TASK_ID), FOREIGN KEY (TASK_ID) REFERENCES TASK(TASK_ID) ON DELETE CASCADE ); CREATE TABLE JOB_STATUS ( STATUS_ID varchar(255), JOB_ID varchar(255), + TASK_ID varchar(255), STATE varchar(255), TIME_OF_STATE_CHANGE timestamp DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP, REASON LONGTEXT, - PRIMARY KEY (STATUS_ID, JOB_ID), + PRIMARY KEY (STATUS_ID, JOB_ID, TASK_ID), FOREIGN KEY (JOB_ID) REFERENCES JOB(JOB_ID) ON DELETE CASCADE ); http://git-wip-us.apache.org/repos/asf/airavata/blob/aa2fab54/modules/registry/registry-core/src/test/resources/expcatalog-derby.sql ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/test/resources/expcatalog-derby.sql b/modules/registry/registry-core/src/test/resources/expcatalog-derby.sql index 63f40ef..6ad715c 100644 --- a/modules/registry/registry-core/src/test/resources/expcatalog-derby.sql +++ b/modules/registry/registry-core/src/test/resources/expcatalog-derby.sql @@ -300,17 +300,18 @@ CREATE TABLE JOB ( COMPUTE_RESOURCE_CONSUMED varchar(255), JOB_NAME varchar(255), WORKING_DIR varchar(255), - PRIMARY KEY (JOB_ID), + PRIMARY KEY (JOB_ID, TASK_ID), FOREIGN KEY (TASK_ID) REFERENCES TASK(TASK_ID) ON DELETE CASCADE ); CREATE TABLE JOB_STATUS ( STATUS_ID varchar(255), JOB_ID varchar(255), + TASK_ID varchar(255), STATE varchar(255), TIME_OF_STATE_CHANGE timestamp DEFAULT '0000-00-00 00:00:00', REASON CLOB, - PRIMARY KEY (STATUS_ID, JOB_ID), + PRIMARY KEY (STATUS_ID, JOB_ID, TASK_ID), FOREIGN KEY (JOB_ID) REFERENCES JOB(JOB_ID) ON DELETE CASCADE );
