From: Niranjana Date: Mon, 18 May 2020 13:21:34 +0000 (+0530) Subject: Fix networkId issue while making call to oof X-Git-Tag: 2.1.1~9 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=733bd98973d4e42f310c0ca0b44848474db94a83;p=dcaegen2%2Fservices%2Fson-handler.git Fix networkId issue while making call to oof Issue-ID: DCAEGEN2-2249 Signed-off-by: Niranjana Change-Id: Ia34b19f18c04d073c45be4a93a5408dc6dd76126 --- diff --git a/pom.xml b/pom.xml index 03694cf..9ec00c6 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.onap.dcaegen2.services.son-handler son-handler dcaegen2-services-son-handler - 2.0.2-SNAPSHOT + 2.0.3-SNAPSHOT diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/MainThreadComponent.java b/src/main/java/org/onap/dcaegen2/services/sonhms/MainThreadComponent.java index e809b45..608e95b 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/MainThreadComponent.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/MainThreadComponent.java @@ -82,7 +82,7 @@ public class MainThreadComponent { Long difference = fixedPciCreatedAt.getTime() - lastInvokedOofTimeStamp.getTime(); Configuration configuration = Configuration.getInstance(); - if (difference > configuration.getPolicyFixedPciTimeInterval()) { + if (Math.abs(difference) > configuration.getPolicyFixedPciTimeInterval()) { log.info("Creating new child thread for sending fixedPciCells"); List cluster = new ArrayList<>(); BlockingQueue> childStatusQueue = new LinkedBlockingQueue<>(); diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThread.java b/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThread.java index 1e740a9..fd2de30 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThread.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThread.java @@ -25,6 +25,7 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import fj.data.Either; +import org.json.JSONObject; import java.io.IOException; import java.sql.Timestamp; @@ -80,6 +81,7 @@ public class ChildThread implements Runnable { HoMetricsComponent hoMetricsComponent; private static final Logger log = org.slf4j.LoggerFactory.getLogger(ChildThread.class); private static Timestamp startTime; + private static String networkId; /** @@ -169,7 +171,14 @@ public class ChildThread implements Runnable { new PolicyDmaapClient(new DmaapUtils(), Configuration.getInstance()), new HoMetricsComponent()); try { - String networkId = cluster.getNetworkId(); + networkId = cluster.getNetworkId(); + if (cluster.getCellPciNeighbourMap().isEmpty()) { + FixedPciCellsRepository fixedPciCellsRepository = BeanUtil.getBean(FixedPciCellsRepository.class); + List fixedPciCells = fixedPciCellsRepository.getFixedPciCells(); + String cellId = fixedPciCells.get(0); + JSONObject cellData = SdnrRestClient.getCellData(cellId); + networkId = cellData.getJSONObject("Cell").getString("networkId"); + } Boolean done = false; @@ -526,4 +535,4 @@ public class ChildThread implements Runnable { } return Either.right(404); } -} \ No newline at end of file +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/SdnrRestClient.java b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/SdnrRestClient.java index 2478f82..a390bbe 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/SdnrRestClient.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/SdnrRestClient.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * son-handler * ================================================================================ - * Copyright (C) 2019 Wipro Limited. + * Copyright (C) 2019-2020 Wipro Limited. * ============================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -105,6 +105,21 @@ public class SdnrRestClient { return responseObject.getString("value"); } + /** + * Method to get CellData name from SDNR. + * + * @throws ConfigDbNotFoundException + * when request to configDB fails + */ + public static JSONObject getCellData(String cellId) throws ConfigDbNotFoundException { + Configuration configuration = Configuration.getInstance(); + String requestUrl = configuration.getConfigDbService() + "/api/sdnc-config-db/v3/getCell" + "/" + cellId; + String response = sendRequest(requestUrl); + JSONObject responseObject = new JSONObject(response); + return responseObject; + } + + /** * Method to send request. */ diff --git a/version.properties b/version.properties index f6b204e..49429b8 100644 --- a/version.properties +++ b/version.properties @@ -20,7 +20,7 @@ ############################################################################### major=2 minor=0 -patch=2 +patch=3 base_version=${major}.${minor}.${patch} release_version=${base_version} snapshot_version=${base_version}-SNAPSHOT