diff options
Diffstat (limited to 'mso-api-handlers')
8 files changed, 102 insertions, 111 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/data.sql b/mso-api-handlers/mso-api-handler-infra/src/test/resources/data.sql index 712cb98c07..f99f89653f 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/data.sql +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/data.sql @@ -31,10 +31,10 @@ INSERT INTO requestdb.activate_operational_env_per_distributionid_status(DISTRIB ('TEST_distributionId_2', 'DISTRIBUTION_COMPLETE_OK', NULL, '2018-02-02 18:44:27', '2018-02-02 18:45:06', '1dfe7154-eae0-44f2-8e7a-8e5e7882e55d', '37305814-4949-45ce-ae24-c378c7ed07d1', '483646fe-36cc-4e90-895a-c472f6da3f74'); -INSERT INTO requestdb.watchdog_distributionid_status(DISTRIBUTION_ID, DISTRIBUTION_ID_STATUS, CREATE_TIME, MODIFY_TIME) VALUES -('1533c4bd-a3e3-493f-a16d-28c20614415e', '', '2017-11-30 15:48:09', '2017-11-30 15:48:09'), -('55429711-809b-4a3b-9ee5-5120d46d9de0', '', '2017-11-30 16:35:36', '2017-11-30 16:35:36'), -('67f0b2d1-9013-4b2b-9914-bbe2288284fb', '', '2017-11-30 15:54:39', '2017-11-30 15:54:39'); +INSERT INTO requestdb.watchdog_distributionid_status(DISTRIBUTION_ID, DISTRIBUTION_ID_STATUS, LOCK_VERSION, CREATE_TIME, MODIFY_TIME) VALUES +('1533c4bd-a3e3-493f-a16d-28c20614415e', '', 0, '2017-11-30 15:48:09', '2017-11-30 15:48:09'), +('55429711-809b-4a3b-9ee5-5120d46d9de0', '', 0, '2017-11-30 16:35:36', '2017-11-30 16:35:36'), +('67f0b2d1-9013-4b2b-9914-bbe2288284fb', '', 0, '2017-11-30 15:54:39', '2017-11-30 15:54:39'); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql b/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql index 95db1c2b7a..5873e147bc 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql @@ -946,6 +946,7 @@ CREATE TABLE `site_status` ( CREATE TABLE `watchdog_distributionid_status` ( `DISTRIBUTION_ID` varchar(45) NOT NULL, `DISTRIBUTION_ID_STATUS` varchar(45) DEFAULT NULL, + `LOCK_VERSION` int NOT NULL, `CREATE_TIME` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `MODIFY_TIME` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`DISTRIBUTION_ID`) diff --git a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java index c15c70cd98..39cccd8aaa 100644 --- a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java +++ b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java @@ -4,6 +4,7 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. + * Modifications Copyright (c) 2019 Samsung * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +23,8 @@ package org.onap.so.db.request.data.repository; import org.onap.so.db.request.beans.InfraActiveRequests; -import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Repository; @@ -60,8 +62,7 @@ public class InfraActiveRequestsRepositoryImpl implements InfraActiveRequestsRep @Autowired private EntityManager entityManager; - protected static MsoLogger msoLogger = - MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL, InfraActiveRequestsRepositoryImpl.class); + protected static Logger logger = LoggerFactory.getLogger(InfraActiveRequestsRepositoryImpl.class); protected static final String REQUEST_STATUS = "requestStatus"; protected static final String SOURCE = "source"; @@ -113,20 +114,15 @@ public class InfraActiveRequestsRepositoryImpl implements InfraActiveRequestsRep final List<Predicate> predicates, final Order order) { final long startTime = System.currentTimeMillis(); - msoLogger.debug("Execute query on infra active request table"); + logger.debug("Execute query on infra active request table"); List<InfraActiveRequests> results = new ArrayList<InfraActiveRequests>(); - try { - final CriteriaBuilder cb = entityManager.getCriteriaBuilder(); - crit.where(cb.and(predicates.toArray(new Predicate[0]))); - crit.orderBy(order); - results = entityManager.createQuery(crit).getResultList(); + final CriteriaBuilder cb = entityManager.getCriteriaBuilder(); + crit.where(cb.and(predicates.toArray(new Predicate[0]))); + crit.orderBy(order); + results = entityManager.createQuery(crit).getResultList(); - } finally { - msoLogger.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - "Successfully", "RequestDB", "getInfraActiveRequest", null); - } return results; } @@ -140,19 +136,13 @@ public class InfraActiveRequestsRepositoryImpl implements InfraActiveRequestsRep @Override public InfraActiveRequests getRequestFromInfraActive(final String requestId) { final long startTime = System.currentTimeMillis(); - msoLogger.debug("Get request " + requestId + " from InfraActiveRequests DB"); + logger.debug("Get request {} from InfraActiveRequests DB", requestId); InfraActiveRequests ar = null; - try { - final Query query = entityManager.createQuery( - "from InfraActiveRequests where requestId = :requestId OR clientRequestId = :requestId"); - query.setParameter(REQUEST_ID, requestId); - ar = this.getSingleResult(query); - } finally { - - msoLogger.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - "Successfully", "InfraRequestDB", "getRequestFromInfraActive", null); - } + final Query query = entityManager + .createQuery("from InfraActiveRequests where requestId = :requestId OR clientRequestId = :requestId"); + query.setParameter(REQUEST_ID, requestId); + ar = this.getSingleResult(query); return ar; } @@ -313,7 +303,7 @@ public class InfraActiveRequestsRepositoryImpl implements InfraActiveRequestsRep predicates.add(cb.between(tableRoot.get(mapKey), minTime, maxTime)); } } catch (final Exception e) { - msoLogger.debug("Exception in getOrchestrationFiltersFromInfraActive(): + " + e.getMessage(), e); + logger.debug("Exception in getOrchestrationFiltersFromInfraActive(): {}", e.getMessage(), e); return null; } } else if ("DOES_NOT_EQUAL".equalsIgnoreCase(entry.getValue().get(0))) { @@ -377,7 +367,7 @@ public class InfraActiveRequestsRepositoryImpl implements InfraActiveRequestsRep predicates.add(cb.between(tableRoot.get(mapKey), minTime, maxTime)); } catch (final Exception e) { - msoLogger.debug("Exception in getCloudOrchestrationFiltersFromInfraActive(): + " + e.getMessage()); + logger.debug("Exception in getCloudOrchestrationFiltersFromInfraActive(): {}", e.getMessage()); return null; } } else { @@ -399,7 +389,7 @@ public class InfraActiveRequestsRepositoryImpl implements InfraActiveRequestsRep @Override public List<InfraActiveRequests> getRequestListFromInfraActive(final String queryAttributeName, final String queryValue, final String requestType) { - msoLogger.debug("Get list of infra requests from DB with " + queryAttributeName + " = " + queryValue); + logger.debug("Get list of infra requests from DB with {} = {}", queryAttributeName, queryValue); try { @@ -419,7 +409,7 @@ public class InfraActiveRequestsRepositoryImpl implements InfraActiveRequestsRep return arList; } } catch (final Exception exception) { - msoLogger.error("Unable to execute query", exception); + logger.error("Unable to execute query", exception); } return Collections.emptyList(); } @@ -435,19 +425,15 @@ public class InfraActiveRequestsRepositoryImpl implements InfraActiveRequestsRep @Override public InfraActiveRequests getRequestFromInfraActive(final String requestId, final String requestType) { final long startTime = System.currentTimeMillis(); - msoLogger.debug("Get infra request from DB with id " + requestId); + logger.debug("Get infra request from DB with id {}", requestId); InfraActiveRequests ar = null; - try { - final Query query = entityManager.createQuery( - "from InfraActiveRequests where (requestId = :requestId OR clientRequestId = :requestId) and requestType = :requestType"); - query.setParameter(REQUEST_ID, requestId); - query.setParameter(REQUEST_TYPE, requestType); - ar = this.getSingleResult(query); - } finally { - msoLogger.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - "Successfully", "RequestDB", "getRequestFromInfraActive", null); - } + + final Query query = entityManager.createQuery( + "from InfraActiveRequests where (requestId = :requestId OR clientRequestId = :requestId) and requestType = :requestType"); + query.setParameter(REQUEST_ID, requestId); + query.setParameter(REQUEST_TYPE, requestType); + ar = this.getSingleResult(query); return ar; } @@ -464,24 +450,19 @@ public class InfraActiveRequestsRepositoryImpl implements InfraActiveRequestsRep final String requestType) { final long startTime = System.currentTimeMillis(); - msoLogger.debug("Get infra request from DB for VNF " + vnfName + " and action " + action + " and requestType " - + requestType); + logger.debug("Get infra request from DB for VNF {} and action {} and requestType {}", vnfName, action, + requestType); InfraActiveRequests ar = null; - try { - final Query query = entityManager.createQuery( - "from InfraActiveRequests where vnfName = :vnfName and action = :action and (requestStatus = 'PENDING' or requestStatus = 'IN_PROGRESS' or requestStatus = 'TIMEOUT' or requestStatus = 'PENDING_MANUAL_TASK') and requestType = :requestType ORDER BY startTime DESC"); - query.setParameter("vnfName", vnfName); - query.setParameter("action", action); - query.setParameter(REQUEST_TYPE, requestType); - @SuppressWarnings("unchecked") - final List<InfraActiveRequests> results = query.getResultList(); - if (!results.isEmpty()) { - ar = results.get(0); - } - } finally { - msoLogger.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - "Successfully", "RequestDB", "checkDuplicateByVnfName", null); + + final Query query = entityManager.createQuery( + "from InfraActiveRequests where vnfName = :vnfName and action = :action and (requestStatus = 'PENDING' or requestStatus = 'IN_PROGRESS' or requestStatus = 'TIMEOUT' or requestStatus = 'PENDING_MANUAL_TASK') and requestType = :requestType ORDER BY startTime DESC"); + query.setParameter("vnfName", vnfName); + query.setParameter("action", action); + query.setParameter(REQUEST_TYPE, requestType); + @SuppressWarnings("unchecked") final List<InfraActiveRequests> results = query.getResultList(); + if (!results.isEmpty()) { + ar = results.get(0); } return ar; @@ -499,23 +480,18 @@ public class InfraActiveRequestsRepositoryImpl implements InfraActiveRequestsRep final String requestType) { final long startTime = System.currentTimeMillis(); - msoLogger.debug("Get list of infra requests from DB for VNF " + vnfId + " and action " + action); + logger.debug("Get list of infra requests from DB for VNF {} and action {}", vnfId, action); InfraActiveRequests ar = null; - try { - final Query query = entityManager.createQuery( - "from InfraActiveRequests where vnfId = :vnfId and action = :action and (requestStatus = 'PENDING' or requestStatus = 'IN_PROGRESS' or requestStatus = 'TIMEOUT' or requestStatus = 'PENDING_MANUAL_TASK') and requestType = :requestType ORDER BY startTime DESC"); - query.setParameter("vnfId", vnfId); - query.setParameter("action", action); - query.setParameter(REQUEST_TYPE, requestType); - @SuppressWarnings("unchecked") - final List<InfraActiveRequests> results = query.getResultList(); - if (!results.isEmpty()) { - ar = results.get(0); - } - } finally { - msoLogger.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - "Successfully", "RequestDB", "checkDuplicateByVnfId", null); + + final Query query = entityManager.createQuery( + "from InfraActiveRequests where vnfId = :vnfId and action = :action and (requestStatus = 'PENDING' or requestStatus = 'IN_PROGRESS' or requestStatus = 'TIMEOUT' or requestStatus = 'PENDING_MANUAL_TASK') and requestType = :requestType ORDER BY startTime DESC"); + query.setParameter("vnfId", vnfId); + query.setParameter("action", action); + query.setParameter(REQUEST_TYPE, requestType); + @SuppressWarnings("unchecked") final List<InfraActiveRequests> results = query.getResultList(); + if (!results.isEmpty()) { + ar = results.get(0); } return ar; @@ -530,29 +506,24 @@ public class InfraActiveRequestsRepositoryImpl implements InfraActiveRequestsRep @Override public InfraActiveRequests checkVnfIdStatus(final String operationalEnvironmentId) { final long startTime = System.currentTimeMillis(); - msoLogger.debug("Get Infra request from DB for OperationalEnvironmentId " + operationalEnvironmentId); + logger.debug("Get Infra request from DB for OperationalEnvironmentId {}", operationalEnvironmentId); InfraActiveRequests ar = null; - try { - final CriteriaBuilder cb = entityManager.getCriteriaBuilder(); - final CriteriaQuery<InfraActiveRequests> crit = cb.createQuery(InfraActiveRequests.class); - final Root<InfraActiveRequests> candidateRoot = crit.from(InfraActiveRequests.class); - final Predicate operationalEnvEq = - cb.equal(candidateRoot.get("operationalEnvId"), operationalEnvironmentId); - final Predicate requestStatusNotEq = cb.notEqual(candidateRoot.get(REQUEST_STATUS), "COMPLETE"); - final Predicate actionEq = cb.equal(candidateRoot.get("action"), "create"); - final Order startTimeOrder = cb.desc(candidateRoot.get("startTime")); - crit.select(candidateRoot); - crit.where(cb.and(operationalEnvEq, requestStatusNotEq, actionEq)); - crit.orderBy(startTimeOrder); - final TypedQuery<InfraActiveRequests> query = entityManager.createQuery(crit); - final List<InfraActiveRequests> results = query.getResultList(); - if (!results.isEmpty()) { - ar = results.get(0); - } - } finally { - msoLogger.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - "Successfully", "RequestDB", "checkDuplicateByVnfName", null); + + final CriteriaBuilder cb = entityManager.getCriteriaBuilder(); + final CriteriaQuery<InfraActiveRequests> crit = cb.createQuery(InfraActiveRequests.class); + final Root<InfraActiveRequests> candidateRoot = crit.from(InfraActiveRequests.class); + final Predicate operationalEnvEq = cb.equal(candidateRoot.get("operationalEnvId"), operationalEnvironmentId); + final Predicate requestStatusNotEq = cb.notEqual(candidateRoot.get(REQUEST_STATUS), "COMPLETE"); + final Predicate actionEq = cb.equal(candidateRoot.get("action"), "create"); + final Order startTimeOrder = cb.desc(candidateRoot.get("startTime")); + crit.select(candidateRoot); + crit.where(cb.and(operationalEnvEq, requestStatusNotEq, actionEq)); + crit.orderBy(startTimeOrder); + final TypedQuery<InfraActiveRequests> query = entityManager.createQuery(crit); + final List<InfraActiveRequests> results = query.getResultList(); + if (!results.isEmpty()) { + ar = results.get(0); } return ar; @@ -595,7 +566,7 @@ public class InfraActiveRequestsRepositoryImpl implements InfraActiveRequestsRep } return entityManager.createQuery(criteriaQuery).getResultList(); } catch (final Exception exception) { - msoLogger.error("Unable to execute query using filters: " + filters, exception); + logger.error("Unable to execute query using filters: {}", filters, exception); return Collections.emptyList(); } } diff --git a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/WatchdogDistributionStatusRepository.java b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/WatchdogDistributionStatusRepository.java index fde8485e6d..6fddf8567c 100644 --- a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/WatchdogDistributionStatusRepository.java +++ b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/WatchdogDistributionStatusRepository.java @@ -27,5 +27,7 @@ import org.springframework.stereotype.Repository; @RepositoryRestResource(collectionResourceRel = "watchdogDistributionStatus", path = "watchdogDistributionStatus") public interface WatchdogDistributionStatusRepository extends JpaRepository<WatchdogDistributionStatus, String> { + + public WatchdogDistributionStatus findOneByDistributionId(String distributionId); } diff --git a/mso-api-handlers/mso-requests-db-repositories/src/test/resources/afterMigrate.sql b/mso-api-handlers/mso-requests-db-repositories/src/test/resources/afterMigrate.sql index b0e7479cc5..43571e42fc 100644 --- a/mso-api-handlers/mso-requests-db-repositories/src/test/resources/afterMigrate.sql +++ b/mso-api-handlers/mso-requests-db-repositories/src/test/resources/afterMigrate.sql @@ -12,10 +12,10 @@ insert into infra_active_requests(request_id, client_request_id, action, request ('00173cc9-5ce2-4673-a810-f87fefb2829e', null, 'createInstance', 'FAILED', 'Error parsing request. No valid instanceName is specified', '100', '2017-04-14 21:08:46', '2017-04-14 21:08:46', 'VID', null, null, null, null, null, 'a259ae7b7c3f493cb3d91f95a7c18149', null, null, null, '{"requestDetails":{"modelInfo":{"modelInvariantId":"ff6163d4-7214-459e-9f76-507b4eb00f51","modelType":"service","modelName":"ConstraintsSrvcVID","modelVersion":"2.0","modelVersionId":"722d256c-a374-4fba-a14f-a59b76bb7656"},"requestInfo":{"productFamilyId":"LRSI-OSPF","source":"VID","requestorId":"xxxxxx"},"subscriberInfo":{"globalSubscriberId":"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"},"cloudConfiguration":{"tenantId":"a259ae7b7c3f493cb3d91f95a7c18149","lcpCloudRegionId":"mtn16"},"requestParameters":{"subscriptionServiceType":"Mobility","userParams":[{"name":"neutronport6_name","value":"8"},{"name":"neutronnet5_network_name","value":"8"},{"name":"contrailv2vlansubinterface3_name","value":"false"}]}}}', null, 'APIH', '2016-12-22 19:00:28', null, null, null, null, null, null, null, 'mtn16', null, null, null, null, null, 'service', 'createInstance', null, null, null, null, null, null, null, 'http://localhost:8080/onap/so/infra/serviceInstantiation/v7/serviceInstances'), ('0017f68c-eb2d-45bb-b7c7-ec31b37dc349', null, 'activateInstance', 'UNLOCKED', null, '20', '2017-09-26 16:09:29', '2017-09-28 12:45:53', 'VID', null, null, null, null, null, null, null, null, null, '{"requestDetails":{"modelInfo":{"modelCustomizationName":null,"modelInvariantId":"1587cf0e-f12f-478d-8530-5c55ac578c39","modelType":"configuration","modelNameVersionId":null,"modelName":null,"modelVersion":null,"modelCustomizationUuid":null,"modelVersionId":"36a3a8ea-49a6-4ac8-b06c-89a545444455","modelCustomizationId":"68dc9a92-214c-11e7-93ae-92361f002671","modelUuid":null,"modelInvariantUuid":null,"modelInstanceName":null},"requestInfo":{"billingAccountNumber":null,"callbackUrl":null,"correlator":null,"orderNumber":null,"productFamilyId":null,"orderVersion":null,"source":"VID","instanceName":null,"suppressRollback":false,"requestorId":"xxxxxx"},"relatedInstanceList":[{"relatedInstance":{"instanceName":null,"instanceId":"9e15a443-af65-4f05-9000-47ae495e937d","modelInfo":{"modelCustomizationName":null,"modelInvariantId":"de19ae10-9a25-11e7-abc4-cec278b6b50a","modelType":"service","modelNameVersionId":null,"modelName":"MSOTADevInfra_Configuration_Service","modelVersion":"1.0","modelCustomizationUuid":null,"modelVersionId":"ee938612-9a25-11e7-abc4-cec278b6b50a","modelCustomizationId":null,"modelUuid":null,"modelInvariantUuid":null,"modelInstanceName":null},"instanceDirection":null}}],"subscriberInfo":null,"cloudConfiguration":{"aicNodeClli":null,"tenantId":null,"lcpCloudRegionId":"mtn6"},"requestParameters":{"subscriptionServiceType":null,"userParams":[],"aLaCarte":false,"autoBuildVfModules":false,"cascadeDelete":false,"usePreload":true,"alaCarte":false},"project":null,"owningEntity":null,"platform":null,"lineOfBusiness":null}}', null, 'APIH', '2017-09-26 16:09:29', null, null, null, null, null, null, null, 'mtn6', null, null, null, null, null, 'configuration', 'activateInstance', '9e15a443-af65-4f05-9000-47ae495e937d', null, 'xxxxxx', '26ef7f15-57bb-48df-8170-e59edc26234c', null, null, null, 'http://localhost:8080/onap/so/infra/serviceInstantiation/v7/serviceInstances'); -insert into watchdog_distributionid_status(distribution_id, distribution_id_status, create_time, modify_time) values -('1533c4bd-a3e3-493f-a16d-28c20614415e', '', '2017-11-30 15:48:09', '2017-11-30 15:48:09'), -('55429711-809b-4a3b-9ee5-5120d46d9de0', '', '2017-11-30 16:35:36', '2017-11-30 16:35:36'), -('67f0b2d1-9013-4b2b-9914-bbe2288284fb', '', '2017-11-30 15:54:39', '2017-11-30 15:54:39'); +insert into watchdog_distributionid_status(distribution_id, distribution_id_status, lock_version, create_time, modify_time) values +('1533c4bd-a3e3-493f-a16d-28c20614415e', '', 0, '2017-11-30 15:48:09', '2017-11-30 15:48:09'), +('55429711-809b-4a3b-9ee5-5120d46d9de0', '', 0, '2017-11-30 16:35:36', '2017-11-30 16:35:36'), +('67f0b2d1-9013-4b2b-9914-bbe2288284fb', '', 0, '2017-11-30 15:54:39', '2017-11-30 15:54:39'); insert into watchdog_per_component_distribution_status(distribution_id, component_name, component_distribution_status, create_time, modify_time) values ('1533c4bd-a3e3-493f-a16d-28c20614415e', 'MSO', 'COMPONENT_DONE_OK', '2017-11-30 15:48:09', '2017-11-30 15:48:09'), diff --git a/mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql b/mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql index bf9a9e1dfe..541f356055 100644 --- a/mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql +++ b/mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql @@ -177,15 +177,16 @@ INSERT INTO PUBLIC.SITE_STATUS(SITE_NAME, STATUS, CREATION_TIMESTAMP) VALUES CREATE CACHED TABLE PUBLIC.WATCHDOG_DISTRIBUTIONID_STATUS( DISTRIBUTION_ID VARCHAR NOT NULL, DISTRIBUTION_ID_STATUS VARCHAR, + LOCK_VERSION int, CREATE_TIME VARCHAR, MODIFY_TIME VARCHAR ); -INSERT INTO PUBLIC.WATCHDOG_DISTRIBUTIONID_STATUS(DISTRIBUTION_ID, DISTRIBUTION_ID_STATUS, CREATE_TIME, MODIFY_TIME) VALUES -('1533c4bd-a3e3-493f-a16d-28c20614415e', '', '2017-11-30 15:48:09', '2017-11-30 15:48:09'), -('55429711-809b-4a3b-9ee5-5120d46d9de0', '', '2017-11-30 16:35:36', '2017-11-30 16:35:36'), -('67f0b2d1-9013-4b2b-9914-bbe2288284fb', '', '2017-11-30 15:54:39', '2017-11-30 15:54:39'); +INSERT INTO PUBLIC.WATCHDOG_DISTRIBUTIONID_STATUS(DISTRIBUTION_ID, DISTRIBUTION_ID_STATUS, LOCK_VERSION, CREATE_TIME, MODIFY_TIME) VALUES +('1533c4bd-a3e3-493f-a16d-28c20614415e', '', 0, '2017-11-30 15:48:09', '2017-11-30 15:48:09'), +('55429711-809b-4a3b-9ee5-5120d46d9de0', '', 0, '2017-11-30 16:35:36', '2017-11-30 16:35:36'), +('67f0b2d1-9013-4b2b-9914-bbe2288284fb', '', 0, '2017-11-30 15:54:39', '2017-11-30 15:54:39'); CREATE CACHED TABLE PUBLIC.WATCHDOG_PER_COMPONENT_DISTRIBUTION_STATUS( DISTRIBUTION_ID VARCHAR NOT NULL, diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/WatchdogDistributionStatus.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/WatchdogDistributionStatus.java index 40c81b96e7..69d84b7679 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/WatchdogDistributionStatus.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/WatchdogDistributionStatus.java @@ -31,6 +31,8 @@ import javax.persistence.PreUpdate; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; +import javax.persistence.Version; + import java.util.Objects; import org.apache.commons.lang3.builder.ToStringBuilder; @@ -54,6 +56,9 @@ public class WatchdogDistributionStatus implements Serializable { @Column(name = "MODIFY_TIME") @Temporal(TemporalType.TIMESTAMP) private Date modifyTime; + @Version + @Column(name = "LOCK_VERSION") + private int version; public WatchdogDistributionStatus() { @@ -78,7 +83,15 @@ public class WatchdogDistributionStatus implements Serializable { public void setDistributionIdStatus(String distributionIdStatus) { this.distributionIdStatus = distributionIdStatus; } - + + public int getVersion() { + return version; + } + + public void setVersion(int version) { + this.version = version; + } + public Date getCreateTime() { return createTime; } diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/requestsdb/RequestsDBHelper.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/requestsdb/RequestsDBHelper.java index ea3ef30827..da72ef985c 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/requestsdb/RequestsDBHelper.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/requestsdb/RequestsDBHelper.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * Licensed 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 @@ -23,8 +25,9 @@ package org.onap.so.requestsdb; import java.sql.Timestamp; import org.onap.so.db.request.beans.InfraActiveRequests; -import org.onap.so.logger.MsoLogger; import org.onap.so.db.request.client.RequestsDbClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; @@ -33,7 +36,7 @@ import org.springframework.stereotype.Component; public class RequestsDBHelper { private static final String UNKNOWN = "UNKNOWN"; - private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH, RequestsDBHelper.class); + private static Logger logger = LoggerFactory.getLogger(RequestsDBHelper.class); private String className = this.getClass().getSimpleName() +" class\'s "; private String methodName = ""; private String classMethodMessage = ""; @@ -51,7 +54,7 @@ public class RequestsDBHelper { public void updateInfraSuccessCompletion(String msg, String requestId, String operationalEnvironmentId) { methodName = "updateInfraSuccessCompletion() method."; classMethodMessage = className + " " + methodName; - msoLogger.debug("Begin of " + classMethodMessage); + logger.debug("Begin of {}", classMethodMessage); InfraActiveRequests request = requestsDbClient.getInfraActiveRequestbyRequestId(requestId); @@ -70,7 +73,7 @@ public class RequestsDBHelper { request.setEndTime(endTimeStamp); requestsDbClient.save(request); - msoLogger.debug("End of " + classMethodMessage); + logger.debug("End of {}", classMethodMessage); } @@ -85,7 +88,7 @@ public class RequestsDBHelper { public void updateInfraFailureCompletion(String msg, String requestId, String operationalEnvironmentId) { methodName = "updateInfraFailureCompletion() method."; classMethodMessage = className + " " + methodName; - msoLogger.debug("Begin of " + classMethodMessage); + logger.debug("Begin of {}", classMethodMessage); InfraActiveRequests request = requestsDbClient.getInfraActiveRequestbyRequestId(requestId); request.setRequestStatus("FAILED"); @@ -103,7 +106,7 @@ public class RequestsDBHelper { request.setEndTime(endTimeStamp); requestsDbClient.save(request); - msoLogger.debug("End of " + classMethodMessage); + logger.debug("End of {}", classMethodMessage); } } |