You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by di...@apache.org on 2020/08/27 05:33:30 UTC
[airavata] 02/02: Fixing add child job status api
This is an automated email from the ASF dual-hosted git repository.
dimuthuupe pushed a commit to branch param-sweep
in repository https://gitbox.apache.org/repos/asf/airavata.git
commit 2fa995b83e6b10e26faec6c5597d2d3514c259f5
Author: Dimuthu Wannipurage <di...@gmail.com>
AuthorDate: Thu Aug 27 01:33:14 2020 -0400
Fixing add child job status api
---
.../expcatalog/ChildJobStatusRepository.java | 46 ++++++++++++++++++++++
.../api/service/handler/RegistryServerHandler.java | 11 +++++-
2 files changed, 56 insertions(+), 1 deletion(-)
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/ChildJobStatusRepository.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/ChildJobStatusRepository.java
new file mode 100644
index 0000000..31e7a95
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/ChildJobStatusRepository.java
@@ -0,0 +1,46 @@
+/*
+ *
+ * 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.repositories.expcatalog;
+
+import org.apache.airavata.model.status.ChildJobStatus;
+import org.apache.airavata.registry.core.entities.expcatalog.ChildJobStatusEntity;
+import org.apache.airavata.registry.core.entities.expcatalog.ChildJobStatusPK;
+import org.apache.airavata.registry.core.utils.ExpCatalogUtils;
+import org.apache.airavata.registry.core.utils.ObjectMapperSingleton;
+import org.dozer.Mapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ChildJobStatusRepository extends ExpCatAbstractRepository<ChildJobStatus, ChildJobStatusEntity, ChildJobStatusPK> {
+
+ private final static Logger logger = LoggerFactory.getLogger(ChildJobStatusRepository.class);
+
+ public ChildJobStatusRepository() { super(ChildJobStatus.class, ChildJobStatusEntity.class); }
+
+ public String addChildJobStatus(ChildJobStatus jobStatus, String childJobId) {
+ jobStatus.setStatusId(ExpCatalogUtils.getID("CHILD_JOB_STATE"));
+ Mapper mapper = ObjectMapperSingleton.getInstance();
+ ChildJobStatusEntity jobStatusEntity = mapper.map(jobStatus, ChildJobStatusEntity.class);
+ jobStatusEntity.setChildJobId(childJobId);
+ execute(entityManager -> entityManager.merge(jobStatusEntity));
+ return jobStatusEntity.getStatusId();
+ }
+}
diff --git a/modules/registry/registry-server/registry-api-service/src/main/java/org/apache/airavata/registry/api/service/handler/RegistryServerHandler.java b/modules/registry/registry-server/registry-api-service/src/main/java/org/apache/airavata/registry/api/service/handler/RegistryServerHandler.java
index af2d11e..7cb16c2 100644
--- a/modules/registry/registry-server/registry-api-service/src/main/java/org/apache/airavata/registry/api/service/handler/RegistryServerHandler.java
+++ b/modules/registry/registry-server/registry-api-service/src/main/java/org/apache/airavata/registry/api/service/handler/RegistryServerHandler.java
@@ -130,6 +130,7 @@ public class RegistryServerHandler implements RegistryService.Iface {
private TaskErrorRepository taskErrorRepository = new TaskErrorRepository();
private JobRepository jobRepository = new JobRepository();
private ChildJobRepository childJobRepository = new ChildJobRepository();
+ private ChildJobStatusRepository childJobStatusRepository = new ChildJobStatusRepository();
private JobStatusRepository jobStatusRepository = new JobStatusRepository();
private QueueStatusRepository queueStatusRepository = new QueueStatusRepository();
private DataProductRepository dataProductRepository = new DataProductRepository();
@@ -975,7 +976,15 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public void addChildJobStatus(ChildJobStatus jobStatus, String childJobId) throws RegistryServiceException, TException {
-
+ try {
+ childJobStatusRepository.addChildJobStatus(jobStatus, childJobId);
+ } catch (Exception e) {
+ logger.error("Error while adding the child job status for child job {}", childJobId, e);
+ AiravataSystemException exception = new AiravataSystemException();
+ exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
+ exception.setMessage("Error while adding child job status. More info : " + e.getMessage());
+ throw exception;
+ }
}
@Override