aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorniranjana <niranjana.y60@wipro.com>2020-02-20 15:14:34 +0530
committerniranjana <niranjana.y60@wipro.com>2020-02-20 17:52:48 +0530
commit4df89dfce2ef6ad2a0d28e8750822c594529ae25 (patch)
treeddb160ae43b5d1bc5e1a3174a64026c227477a50 /src/main/java
parent8e924858d792abf90c689d65ec89daa67ed72298 (diff)
Implement adaptive SON functionality
Issue-ID: DCAEGEN2-2023 Signed-off-by: niranjana <niranjana.y60@wipro.com> Change-Id: I419b04f669f0b021396a4b04f11139eb4918de09
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/Application.java3
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java26
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/MainThreadComponent.java50
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThread.java436
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.java8
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/child/StateOof.java6
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/dao/FixedPciCellsRepository.java48
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/dao/PciUpdateRepository.java53
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/DmaapClient.java18
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyNotificationCallback.java90
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/entity/FixedPciCells.java84
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/entity/PciUpdate.java88
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/restclient/CellInfo.java10
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/restclient/OofRestClient.java9
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/utils/ThreadUtils.java19
15 files changed, 723 insertions, 225 deletions
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/Application.java b/src/main/java/org/onap/dcaegen2/services/sonhms/Application.java
index 3e65c8c..71dabff 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/Application.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/Application.java
@@ -40,8 +40,9 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
+import org.springframework.scheduling.annotation.EnableScheduling;
-
+@EnableScheduling
@SpringBootApplication
public class Application {
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java b/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java
index d3d9d39..13c86b6 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java
@@ -71,7 +71,8 @@ public class Configuration {
private int oofTriggerCountTimer;
private int oofTriggerCountThreshold;
private int policyRespTimer;
-
+ private int policyNegativeAckThreshold;
+ private long policyFixedPciTimeInterval;
public int getPoorCountThreshold() {
return poorCountThreshold;
@@ -351,7 +352,23 @@ public class Configuration {
this.oofEndpoint = oofEndpoint;
}
- @Override
+ public int getPolicyNegativeAckThreshold() {
+ return policyNegativeAckThreshold;
+ }
+
+ public void setPolicyNegativeAckThreshold(int policyNegativeAckThreshold) {
+ this.policyNegativeAckThreshold = policyNegativeAckThreshold;
+ }
+
+ public long getPolicyFixedPciTimeInterval() {
+ return policyFixedPciTimeInterval;
+ }
+
+ public void setPolicyFixedPciTimeInterval(long policyFixedPciTimeInterval) {
+ this.policyFixedPciTimeInterval = policyFixedPciTimeInterval;
+ }
+
+ @Override
public String toString() {
return "Configuration [pgHost=" + pgHost + ", pgPort=" + pgPort + ", pgUsername=" + pgUsername + ", pgPassword="
+ pgPassword + ", dmaapServers=" + dmaapServers + ", configDbService=" + configDbService
@@ -365,7 +382,7 @@ public class Configuration {
+ ", badThreshold=" + badThreshold + ", poorThreshold=" + poorThreshold + ", poorCountThreshold="
+ poorCountThreshold + ", badCountThreshold=" + badCountThreshold + ", oofTriggerCountTimer="
+ oofTriggerCountTimer + ", oofTriggerCountThreshold=" + oofTriggerCountThreshold + ", policyRespTimer="
- + policyRespTimer + "]";
+ + policyRespTimer + ", policyNegativeAckThreshold=" + policyNegativeAckThreshold + ", policyFixedPciTimeInterval="+ policyFixedPciTimeInterval + "]";
}
/**
@@ -422,7 +439,8 @@ public class Configuration {
oofTriggerCountTimer = jsonObject.get("sonhandler.oofTriggerCountTimer").getAsInt();
oofTriggerCountThreshold = jsonObject.get("sonhandler.oofTriggerCountThreshold").getAsInt();
policyRespTimer = jsonObject.get("sonhandler.policyRespTimer").getAsInt();
-
+ policyNegativeAckThreshold = jsonObject.get("sonhandler.policyNegativeAckThreshold").getAsInt();
+ policyFixedPciTimeInterval = jsonObject.get("sonhandler.policyFixedPciTimeInterval").getAsLong();
log.info("configuration from CBS {}", this);
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 a167872..e809b45 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/MainThreadComponent.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/MainThreadComponent.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.
@@ -21,11 +21,27 @@
package org.onap.dcaegen2.services.sonhms;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.LinkedBlockingQueue;
+
import javax.annotation.PostConstruct;
+import org.onap.dcaegen2.services.sonhms.child.ChildThread;
+import org.onap.dcaegen2.services.sonhms.child.Graph;
+import org.onap.dcaegen2.services.sonhms.dao.FixedPciCellsRepository;
+import org.onap.dcaegen2.services.sonhms.utils.BeanUtil;
+import org.onap.dcaegen2.services.sonhms.utils.ClusterUtils;
+import org.onap.dcaegen2.services.sonhms.utils.ThreadUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component
@@ -42,8 +58,6 @@ public class MainThreadComponent {
@Autowired
private NewFmNotification newFmNotification;
-
-
/**
* main thread initialization.
*/
@@ -55,4 +69,34 @@ public class MainThreadComponent {
Thread pmThread = new Thread(new PmThread(newPmNotification));
pmThread.start();
}
+
+ @Scheduled(fixedRate = 300000, initialDelay = 60000)
+ public void checkFixedPciTable() {
+ log.info("Inside checkFixedPciTable method");
+ FixedPciCellsRepository fixedPciCellsRepository = BeanUtil.getBean(FixedPciCellsRepository.class);
+ List<String> fixedPciCellsList = fixedPciCellsRepository.getFixedPciCells();
+ if (!fixedPciCellsList.isEmpty()) {
+ log.info("Fixed Pci table not empty");
+ Timestamp lastInvokedOofTimeStamp = ChildThread.getLastInvokedOofTimeStamp();
+ Timestamp fixedPciCreatedAt = fixedPciCellsRepository.getTimeStampforFixedPci();
+ Long difference = fixedPciCreatedAt.getTime() - lastInvokedOofTimeStamp.getTime();
+ Configuration configuration = Configuration.getInstance();
+
+ if (difference > configuration.getPolicyFixedPciTimeInterval()) {
+ log.info("Creating new child thread for sending fixedPciCells");
+ List<Graph> cluster = new ArrayList<>();
+ BlockingQueue<List<String>> childStatusQueue = new LinkedBlockingQueue<>();
+ EventHandler eventHandler = new EventHandler(childStatusQueue,
+ Executors.newFixedThreadPool(Configuration.getInstance().getMaximumClusters()), new HashMap<>(),
+ new ClusterUtils(), new ThreadUtils());
+ ExecutorService pool = Executors.newFixedThreadPool(5);
+ ThreadUtils threadUtils = new ThreadUtils();
+ boolean result = threadUtils.createNewThread(cluster, childStatusQueue, pool, eventHandler, null);
+ log.info("Child Thread creation result:"+ result);
+ }
+
+ } else {
+ log.info("Exiting function fixedPci table empty");
+ }
+ }
}
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 87c5081..1e740a9 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
@@ -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.
@@ -45,9 +45,12 @@ import org.onap.dcaegen2.services.sonhms.Configuration;
import org.onap.dcaegen2.services.sonhms.HoMetricsComponent;
import org.onap.dcaegen2.services.sonhms.Timer;
import org.onap.dcaegen2.services.sonhms.dao.ClusterDetailsRepository;
+import org.onap.dcaegen2.services.sonhms.dao.FixedPciCellsRepository;
+import org.onap.dcaegen2.services.sonhms.dao.PciUpdateRepository;
import org.onap.dcaegen2.services.sonhms.dao.SonRequestsRepository;
import org.onap.dcaegen2.services.sonhms.dmaap.PolicyDmaapClient;
import org.onap.dcaegen2.services.sonhms.entity.HandOverMetrics;
+import org.onap.dcaegen2.services.sonhms.entity.PciUpdate;
import org.onap.dcaegen2.services.sonhms.exceptions.ConfigDbNotFoundException;
import org.onap.dcaegen2.services.sonhms.exceptions.OofNotFoundException;
import org.onap.dcaegen2.services.sonhms.model.AnrInput;
@@ -57,6 +60,8 @@ import org.onap.dcaegen2.services.sonhms.model.Flag;
import org.onap.dcaegen2.services.sonhms.model.HoDetails;
import org.onap.dcaegen2.services.sonhms.model.ThreadId;
import org.onap.dcaegen2.services.sonhms.restclient.AsyncResponseBody;
+import org.onap.dcaegen2.services.sonhms.restclient.PciSolutions;
+import org.onap.dcaegen2.services.sonhms.restclient.SdnrRestClient;
import org.onap.dcaegen2.services.sonhms.utils.BeanUtil;
import org.onap.dcaegen2.services.sonhms.utils.ClusterUtils;
import org.onap.dcaegen2.services.sonhms.utils.DmaapUtils;
@@ -74,6 +79,8 @@ public class ChildThread implements Runnable {
Map<CellPciPair, ArrayList<CellPciPair>> clusterMap;
HoMetricsComponent hoMetricsComponent;
private static final Logger log = org.slf4j.LoggerFactory.getLogger(ChildThread.class);
+ private static Timestamp startTime;
+
/**
* Constructor with parameters.
@@ -139,211 +146,244 @@ public class ChildThread implements Runnable {
return responseMap;
}
- @Override
- public void run() {
-
- threadId.setChildThreadId(Thread.currentThread().getId());
- synchronized (threadId) {
- threadId.notifyAll();
- }
-
- MDC.put("logFileName", Thread.currentThread().getName());
- log.info("Starting child thread");
-
- StateOof oof = new StateOof(childStatusUpdate);
- ClusterUtils clusterUtils = new ClusterUtils();
- Detection detect = new Detection();
- ChildThreadUtils childUtils = new ChildThreadUtils(ConfigPolicy.getInstance(), new PnfUtils(),
- new PolicyDmaapClient(new DmaapUtils(), Configuration.getInstance()), new HoMetricsComponent());
-
- try {
- String networkId = cluster.getNetworkId();
-
- Boolean done = false;
-
- Map<String, ArrayList<Integer>> collisionConfusionResult;
- while (!done) {
- if (cluster.getCollisionConfusionMap().isEmpty()) {
-
- collisionConfusionResult = detect.detectCollisionConfusion(cluster);
- } else {
- collisionConfusionResult = cluster.getCollisionConfusionMap();
- }
-
- Boolean trigger = childUtils.triggerOrWait(collisionConfusionResult);
- ConfigPolicy configPolicy = ConfigPolicy.getInstance();
- double timer = 60;
- try {
- timer = (double) configPolicy.getConfig().get("PCI_NEIGHBOR_CHANGE_CLUSTER_TIMEOUT_IN_SECS");
- } catch (NullPointerException e) {
- log.info("Policy config not available. Using default timeout - 60 seconds");
- }
- if (!trigger) {
- try {
- Thread.sleep((long) timer * 1000);
- } catch (InterruptedException e) {
- log.error("Interrupted Exception while waiting for more notifications {}", e);
- Thread.currentThread().interrupt();
- }
-
- while (!queue.isEmpty()) {
- Map<CellPciPair, ArrayList<CellPciPair>> newNotification;
- newNotification = queue.poll();
- log.info("New notification from SDNR {}", newNotification);
- cluster = clusterUtils.modifyCluster(cluster, newNotification);
-
- // update cluster in DB
- clusterUtils.updateCluster(cluster);
- collisionConfusionResult = detect.detectCollisionConfusion(cluster);
-
- }
-
- }
- ArrayList<String> cellidList = new ArrayList<>();
- ArrayList<String> cellIds = new ArrayList<>();
-
- for (Map.Entry<String, ArrayList<Integer>> entry : collisionConfusionResult.entrySet()) {
- String key = entry.getKey();
- ArrayList<Integer> arr;
- arr = entry.getValue();
- if (!arr.isEmpty()) {
- Set<Integer> set = new HashSet<>(arr);
- if (((set.size() == 1) && !set.contains(0)) || (set.size() != 1)) {
- cellIds.add(key);
-
- }
- }
-
- }
-
- for (String cell : cellIds) {
- log.debug("cellidList entries: {}", cell);
- cellidList.add(cell);
- }
- UUID transactionId;
+ public static Timestamp getLastInvokedOofTimeStamp() {
+ return startTime;
- Flag policyTriggerFlag = BeanUtil.getBean(Flag.class);
- while (policyTriggerFlag.getHolder().equals("PM")) {
- Thread.sleep(100);
- }
- policyTriggerFlag.setHolder("CHILD");
- policyTriggerFlag.setNumChilds(policyTriggerFlag.getNumChilds() + 1);
-
- Timer timerOof = BeanUtil.getBean(Timer.class);
- if (!timerOof.getIsTimer()) {
- log.info("Starting timer");
- timerOof.setIsTimer(true);
- Timestamp startTime = new Timestamp(System.currentTimeMillis());
- timerOof.setStartTime(startTime);
- timerOof.setCount(0);
- log.info("startTime {}", startTime);
+ }
- }
- int timerThreshold = (Configuration.getInstance().getOofTriggerCountTimer() * 60000);
- int triggerCountThreshold = Configuration.getInstance().getOofTriggerCountThreshold();
- log.info("Time threshold {}, triggerCountThreshold {}", timerThreshold, triggerCountThreshold);
- log.info("oof trigger count {}", timerOof.getCount());
- timerOof.setCount(timerOof.getCount() + 1);
- Timestamp currentTime = new Timestamp(System.currentTimeMillis());
- Long difference = currentTime.getTime() - timerOof.getStartTime().getTime();
- if (difference < timerThreshold && timerOof.getCount() > triggerCountThreshold) {
- log.info("difference {}", difference);
-
- Either<List<AnrInput>, Integer> anrTriggerResponse = checkAnrTrigger();
- if (anrTriggerResponse.isRight()) {
- log.info("ANR trigger response right {}", anrTriggerResponse.right().value());
- if (anrTriggerResponse.right().value() == 404) {
- log.info("No poor neighbors found");
- } else if (anrTriggerResponse.right().value() == 500) {
- log.info("Failed to fetch HO details from DB ");
- }
- transactionId = oof.triggerOof(cellidList, networkId, new ArrayList<>());
-
- } else {
- log.info("ANR trigger response left {}", anrTriggerResponse.left().value());
- List<AnrInput> anrInputList = anrTriggerResponse.left().value();
- log.info("Trigger oof for joint optimization");
- transactionId = oof.triggerOof(cellidList, networkId, anrInputList);
-
- }
-
- } else {
-
- transactionId = oof.triggerOof(cellidList, networkId, new ArrayList<>());
-
- if (difference > timerThreshold) {
- timerOof.setIsTimer(false);
- timerOof.setCount(0);
- }
- }
+ @Override
+ public void run() {
- long childThreadId = Thread.currentThread().getId();
- childUtils.saveRequest(transactionId.toString(), childThreadId);
+ threadId.setChildThreadId(Thread.currentThread().getId());
+ synchronized (threadId) {
+ threadId.notifyAll();
+ }
+
+ MDC.put("logFileName", Thread.currentThread().getName());
+ log.info("Starting child thread");
+
+ StateOof oof = new StateOof(childStatusUpdate);
+ ClusterUtils clusterUtils = new ClusterUtils();
+ Detection detect = new Detection();
+ ChildThreadUtils childUtils = new ChildThreadUtils(ConfigPolicy.getInstance(), new PnfUtils(),
+ new PolicyDmaapClient(new DmaapUtils(), Configuration.getInstance()), new HoMetricsComponent());
+
+ try {
+ String networkId = cluster.getNetworkId();
+
+ Boolean done = false;
+
+ Map<String, ArrayList<Integer>> collisionConfusionResult = new HashMap<String, ArrayList<Integer>>();
+
+ while (!done) {
+
+ if (!cluster.getCellPciNeighbourMap().isEmpty()) {
+
+ if (cluster.getCollisionConfusionMap().isEmpty()) {
+
+ collisionConfusionResult = detect.detectCollisionConfusion(cluster);
+ } else {
+ collisionConfusionResult = cluster.getCollisionConfusionMap();
+ }
+
+ Boolean trigger = childUtils.triggerOrWait(collisionConfusionResult);
+ ConfigPolicy configPolicy = ConfigPolicy.getInstance();
+ double timer = 60;
+ try {
+ timer = (double) configPolicy.getConfig().get("PCI_NEIGHBOR_CHANGE_CLUSTER_TIMEOUT_IN_SECS");
+ } catch (NullPointerException e) {
+ log.info("Policy config not available. Using default timeout - 60 seconds");
+ }
+ if (!trigger) {
+ try {
+ Thread.sleep((long) timer * 1000);
+ } catch (InterruptedException e) {
+ log.error("Interrupted Exception while waiting for more notifications {}", e);
+ Thread.currentThread().interrupt();
+ }
+
+ while (!queue.isEmpty()) {
+ Map<CellPciPair, ArrayList<CellPciPair>> newNotification;
+ newNotification = queue.poll();
+ log.info("New notification from SDNR {}", newNotification);
+ cluster = clusterUtils.modifyCluster(cluster, newNotification);
+
+ // update cluster in DB
+ clusterUtils.updateCluster(cluster);
+ collisionConfusionResult = detect.detectCollisionConfusion(cluster);
+
+ }
+
+ }
+ }
+ ArrayList<String> cellidList = new ArrayList<>();
+ ArrayList<String> cellIds = new ArrayList<>();
+
+ for (Map.Entry<String, ArrayList<Integer>> entry : collisionConfusionResult.entrySet()) {
+ String key = entry.getKey();
+ ArrayList<Integer> arr;
+ arr = entry.getValue();
+ if (!arr.isEmpty()) {
+ Set<Integer> set = new HashSet<>(arr);
+ if (((set.size() == 1) && !set.contains(0)) || (set.size() != 1)) {
+ cellIds.add(key);
+
+ }
+ }
+
+ }
+
+ for (String cell : cellIds) {
+ log.debug("cellidList entries: {}", cell);
+ cellidList.add(cell);
+ }
+ UUID transactionId;
+
+ Flag policyTriggerFlag = BeanUtil.getBean(Flag.class);
+ while (policyTriggerFlag.getHolder().equals("PM")) {
+ Thread.sleep(100);
+ }
+ policyTriggerFlag.setHolder("CHILD");
+ policyTriggerFlag.setNumChilds(policyTriggerFlag.getNumChilds() + 1);
+
+ FixedPciCellsRepository fixedPciCellsRepository = BeanUtil.getBean(FixedPciCellsRepository.class);
+ List<String> fixedPciCells = fixedPciCellsRepository.getFixedPciCells();
+
+ Timer timerOof = BeanUtil.getBean(Timer.class);
+ if (!timerOof.getIsTimer()) {
+ log.info("Starting timer");
+ timerOof.setIsTimer(true);
+ startTime = new Timestamp(System.currentTimeMillis());
+ timerOof.setStartTime(startTime);
+ timerOof.setCount(0);
+ log.info("startTime {}", startTime);
+
+ }
+ int timerThreshold = (Configuration.getInstance().getOofTriggerCountTimer() * 60000);
+ int triggerCountThreshold = Configuration.getInstance().getOofTriggerCountThreshold();
+ log.info("Time threshold {}, triggerCountThreshold {}", timerThreshold, triggerCountThreshold);
+ log.info("oof trigger count {}", timerOof.getCount());
+ timerOof.setCount(timerOof.getCount() + 1);
+ Timestamp currentTime = new Timestamp(System.currentTimeMillis());
+ Long difference = currentTime.getTime() - timerOof.getStartTime().getTime();
+ if (difference < timerThreshold && timerOof.getCount() > triggerCountThreshold) {
+ log.info("difference {}", difference);
+
+ Either<List<AnrInput>, Integer> anrTriggerResponse = checkAnrTrigger();
+ if (anrTriggerResponse.isRight()) {
+ log.info("ANR trigger response right {}", anrTriggerResponse.right().value());
+ if (anrTriggerResponse.right().value() == 404) {
+ log.info("No poor neighbors found");
+ } else if (anrTriggerResponse.right().value() == 500) {
+ log.info("Failed to fetch HO details from DB ");
+ }
+ transactionId = oof.triggerOof(cellidList, networkId, new ArrayList<>(),fixedPciCells);
+
+ } else {
+ log.info("ANR trigger response left {}", anrTriggerResponse.left().value());
+ List<AnrInput> anrInputList = anrTriggerResponse.left().value();
+ log.info("Trigger oof for joint optimization");
+ transactionId = oof.triggerOof(cellidList, networkId, anrInputList,fixedPciCells);
+
+ }
+
+ } else {
+
+ transactionId = oof.triggerOof(cellidList, networkId, new ArrayList<>(),fixedPciCells);
+
+ if (difference > timerThreshold) {
+ timerOof.setIsTimer(false);
+ timerOof.setCount(0);
+ }
+ }
+
+ long childThreadId = Thread.currentThread().getId();
+ childUtils.saveRequest(transactionId.toString(), childThreadId);
while (!ChildThread.getResponseMap().containsKey(childThreadId)) {
Thread.sleep(100);
}
AsyncResponseBody asynResponseBody = ChildThread.getResponseMap().get(childThreadId);
-
- try {
- childUtils.sendToPolicy(asynResponseBody);
- policyTriggerFlag.setNumChilds(policyTriggerFlag.getNumChilds() - 1);
- if (policyTriggerFlag.getNumChilds() == 0) {
- policyTriggerFlag.setHolder("NONE");
- }
-
- } catch (ConfigDbNotFoundException e1) {
- log.debug("Config DB is unreachable: {}", e1);
- }
-
- SonRequestsRepository sonRequestsRepository = BeanUtil.getBean(SonRequestsRepository.class);
- sonRequestsRepository.deleteByChildThreadId(childThreadId);
-
- List<String> childStatus = new ArrayList<>();
- childStatus.add(Long.toString(Thread.currentThread().getId()));
- childStatus.add("success");
- try {
- childStatusUpdate.put(childStatus);
- } catch (InterruptedException e) {
- log.debug("InterruptedException during childStatus update {}", e);
- Thread.currentThread().interrupt();
-
- }
-
- Either<List<String>, Integer> bufferedNotifications = getBufferedNotifications();
-
- if (bufferedNotifications.isRight()) {
- log.info("No buffered notifications");
- done = true;
- } else {
- List<Map<CellPciPair, ArrayList<CellPciPair>>> clusterMaps = getClusterMapsFromNotifications(
- bufferedNotifications.left().value());
- for (Map<CellPciPair, ArrayList<CellPciPair>> bufferedClusterMap : clusterMaps) {
- cluster = clusterUtils.modifyCluster(cluster, bufferedClusterMap);
- }
- String cellPciNeighbourString = cluster.getPciNeighbourJson();
- UUID clusterId = cluster.getGraphId();
- ClusterDetailsRepository clusterDetailsRepository = BeanUtil
- .getBean(ClusterDetailsRepository.class);
- clusterDetailsRepository.updateCluster(cellPciNeighbourString, clusterId.toString());
- }
-
- }
-
- } catch (OofNotFoundException e) {
- log.error("OOF not found, Removing flag and cleaning up");
- Flag policyTriggerFlag = BeanUtil.getBean(Flag.class);
- policyTriggerFlag.setNumChilds(policyTriggerFlag.getNumChilds() - 1);
- if (policyTriggerFlag.getNumChilds() == 0) {
- policyTriggerFlag.setHolder("NONE");
- }
- } catch (Exception e) {
- log.error("{}", e);
-
-
- }
-
- cleanup();
+
+ List<PciSolutions> pciSolutionsList = asynResponseBody.getSolutions().getPciSolutions();
+
+ if (!pciSolutionsList.isEmpty())
+ for (PciSolutions pcisolutions : pciSolutionsList) {
+
+ String cellId = pcisolutions.getCellId();
+ int oldPci = SdnrRestClient.getPci(cellId);
+ int newPci = pcisolutions.getPci();
+ PciUpdate pciUpdate = new PciUpdate();
+ pciUpdate.setCellId(cellId);
+ pciUpdate.setOldPci(oldPci);
+ pciUpdate.setNewPci(newPci);
+ PciUpdateRepository pciUpdateRepository = BeanUtil.getBean(PciUpdateRepository.class);
+ pciUpdateRepository.save(pciUpdate);
+ }
+
+ try {
+ childUtils.sendToPolicy(asynResponseBody);
+ policyTriggerFlag.setNumChilds(policyTriggerFlag.getNumChilds() - 1);
+ if (policyTriggerFlag.getNumChilds() == 0) {
+ policyTriggerFlag.setHolder("NONE");
+ }
+
+ } catch (ConfigDbNotFoundException e1) {
+ log.debug("Config DB is unreachable: {}", e1);
+ }
+
+ SonRequestsRepository sonRequestsRepository = BeanUtil.getBean(SonRequestsRepository.class);
+ sonRequestsRepository.deleteByChildThreadId(childThreadId);
+
+ List<String> childStatus = new ArrayList<>();
+ childStatus.add(Long.toString(Thread.currentThread().getId()));
+ childStatus.add("success");
+ try {
+ childStatusUpdate.put(childStatus);
+ } catch (InterruptedException e) {
+ log.debug("InterruptedException during childStatus update {}", e);
+ Thread.currentThread().interrupt();
+
+ }
+
+ if (!cluster.getCellPciNeighbourMap().isEmpty()) {
+
+ Either<List<String>, Integer> bufferedNotifications = getBufferedNotifications();
+
+ if (bufferedNotifications.isRight()) {
+ log.info("No buffered notifications");
+ done = true;
+ } else {
+ List<Map<CellPciPair, ArrayList<CellPciPair>>> clusterMaps = getClusterMapsFromNotifications(
+ bufferedNotifications.left().value());
+ for (Map<CellPciPair, ArrayList<CellPciPair>> bufferedClusterMap : clusterMaps) {
+ cluster = clusterUtils.modifyCluster(cluster, bufferedClusterMap);
+ }
+ String cellPciNeighbourString = cluster.getPciNeighbourJson();
+ UUID clusterId = cluster.getGraphId();
+ ClusterDetailsRepository clusterDetailsRepository = BeanUtil
+ .getBean(ClusterDetailsRepository.class);
+ clusterDetailsRepository.updateCluster(cellPciNeighbourString, clusterId.toString());
+ }
+ } else {
+ done = true;
+ }
+
+ }
+
+ } catch (OofNotFoundException e) {
+ log.error("OOF not found, Removing flag and cleaning up");
+ Flag policyTriggerFlag = BeanUtil.getBean(Flag.class);
+ policyTriggerFlag.setNumChilds(policyTriggerFlag.getNumChilds() - 1);
+ if (policyTriggerFlag.getNumChilds() == 0) {
+ policyTriggerFlag.setHolder("NONE");
+ }
+ } catch (Exception e) {
+ log.error("{}", e);
+
+ }
+
+ cleanup();
}
private List<Map<CellPciPair, ArrayList<CellPciPair>>> getClusterMapsFromNotifications(List<String> notifications) {
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.java b/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.java
index 852d087..d04e6cb 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.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.
@@ -207,9 +207,6 @@ public class ChildThreadUtils {
} else {
log.debug("Sending notification to policy failed");
}
- policyDmaapClient.handlePolicyResponse(requestId);
- log.info("handled policy response in ModifyConfig");
-
}
}
if (!solutions.getAnrSolutions().isEmpty()) {
@@ -276,9 +273,6 @@ public class ChildThreadUtils {
log.info("Policy Notification: {}", notification);
Boolean result = policyDmaapClient.sendNotificationToPolicy(notification);
log.info("send notification to policy result {} ", result);
- policyDmaapClient.handlePolicyResponse(requestId);
- log.info("handled policy response in ModifyConfigANR");
-
}
}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/child/StateOof.java b/src/main/java/org/onap/dcaegen2/services/sonhms/child/StateOof.java
index a00c166..04d4fb1 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/child/StateOof.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/child/StateOof.java
@@ -55,7 +55,7 @@ public class StateOof {
* @throws OofNotFoundException
* when trigger oof fails
*/
- public UUID triggerOof(List<String> cellidList, String networkId, List<AnrInput> anrInputList)
+ public UUID triggerOof(List<String> cellidList, String networkId, List<AnrInput> anrInputList, List<String> fixedPciCells)
throws OofNotFoundException, InterruptedException {
log.info("Triggering oof");
@@ -75,10 +75,10 @@ public class StateOof {
String oofResponse = null;
if (!anrInputList.isEmpty()) {
oofResponse = OofRestClient.queryOof(numSolutions, transactionId.toString(), "create", cellidList,
- networkId, pciAnrOptimizerList, anrInputList);
+ networkId, pciAnrOptimizerList, anrInputList,fixedPciCells);
} else {
oofResponse = OofRestClient.queryOof(numSolutions, transactionId.toString(), "create", cellidList,
- networkId, pciOptimizerList, anrInputList);
+ networkId, pciOptimizerList, anrInputList,fixedPciCells);
}
log.info("Synchronous Response {}", oofResponse);
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dao/FixedPciCellsRepository.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dao/FixedPciCellsRepository.java
new file mode 100644
index 0000000..1f9c858
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dao/FixedPciCellsRepository.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.dao;
+
+import java.sql.Timestamp;
+import java.util.List;
+import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.Transactional;
+import org.onap.dcaegen2.services.sonhms.entity.FixedPciCells;
+import org.springframework.data.repository.CrudRepository;
+import org.springframework.data.jpa.repository.Query;
+
+@Repository
+@Transactional
+public interface FixedPciCellsRepository extends CrudRepository<FixedPciCells, String> {
+
+ @SuppressWarnings("unchecked")
+ public FixedPciCells save(FixedPciCells persisted);
+
+ @Query(nativeQuery = true, value = "SELECT cell_id FROM fixed_pci_cells")
+ public List<String> getFixedPciCells();
+
+ @Query(nativeQuery = true,
+ value = "SELECT created_at FROM fixed_pci_cells WHERE "
+ + "created_at=(SELECT created_at FROM fixed_pci_cells "
+ + "ORDER BY created_at DESC FOR UPDATE SKIP LOCKED LIMIT 1);")
+ public Timestamp getTimeStampforFixedPci();
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dao/PciUpdateRepository.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dao/PciUpdateRepository.java
new file mode 100644
index 0000000..dc997bc
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dao/PciUpdateRepository.java
@@ -0,0 +1,53 @@
+
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.dao;
+
+import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.Transactional;
+import org.onap.dcaegen2.services.sonhms.entity.PciUpdate;
+import org.springframework.data.repository.CrudRepository;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.jpa.repository.Modifying;
+
+@Repository
+@Transactional
+public interface PciUpdateRepository extends CrudRepository<PciUpdate, String> {
+
+ @SuppressWarnings("unchecked")
+ public PciUpdate save(PciUpdate persisted);
+
+ @Query(nativeQuery = true, value = "SELECT negative_ack_count FROM pci_update WHERE cell_id = ?1")
+ public int getNegativeAckCountforCellId(String cellId);
+
+ @Query(nativeQuery = true, value = "SELECT old_pci FROM pci_update WHERE cell_id = ?1")
+ public long getOldPciforCellId(String cellId);
+
+ @Modifying
+ @Query(nativeQuery = true, value = "UPDATE pci_update SET negative_ack_count = ?1 WHERE cell_id = ?2")
+ public void increaseNegativeAckCountforCellId(int negativeAckCount, String cellId);
+
+ @Modifying
+ @Query(nativeQuery = true, value = "DELETE FROM pci_update WHERE cell_id = ?1")
+ public void deleterecordforCellId(String cellId);
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/DmaapClient.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/DmaapClient.java
index 664dbf8..8284f8f 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/DmaapClient.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/DmaapClient.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.
@@ -81,13 +81,21 @@ public class DmaapClient {
String[] pmTopicSplit = pmTopicUrl.split("\\/");
String pmTopic = pmTopicSplit[sdnrTopicSplit.length - 1];
log.debug("pm topic : {}", pmTopic);
+ String policyResponseTopicUrl = ((Map<String, String>) ((Map<String, Object>) streamSubscribes
+ .get("dcae_cl_response_topic")).get("dmaap_info")).get("topic_url");
+ String[] policyResponseTopicUrlSplit = policyResponseTopicUrl.split("\\/");
+ String policyResponseTopic = policyResponseTopicUrlSplit[policyResponseTopicUrlSplit.length - 1];
+ log.debug("policyResponse Topic : {}", policyResponseTopic);
CambriaConsumer sdnrNotifCambriaConsumer = null;
CambriaConsumer fmNotifCambriaConsumer = null;
CambriaConsumer pmNotifCambriaConsumer = null;
+ CambriaConsumer policyResponseCambriaConsumer = null;
sdnrNotifCambriaConsumer = dmaapUtils.buildConsumer(configuration, sdnrTopic);
fmNotifCambriaConsumer = dmaapUtils.buildConsumer(configuration, fmTopic);
pmNotifCambriaConsumer = dmaapUtils.buildConsumer(configuration, pmTopic);
+ policyResponseCambriaConsumer = dmaapUtils.buildConsumer(configuration, policyResponseTopic);
+
// create notification consumers for SNDR and policy
NotificationConsumer sdnrNotificationConsumer = new NotificationConsumer(sdnrNotifCambriaConsumer,
@@ -114,6 +122,14 @@ public class DmaapClient {
executorPool.scheduleAtFixedRate(pmNotificationConsumer, 0, configuration.getPollingInterval(),
TimeUnit.SECONDS);
+ // create notification consumers for Policy
+ NotificationConsumer policyNotificationConsumer = new NotificationConsumer(policyResponseCambriaConsumer,
+ new PolicyNotificationCallback());
+ // start policy notification consumer threads
+ executorPool = Executors.newScheduledThreadPool(10);
+ executorPool.scheduleAtFixedRate(policyNotificationConsumer, 0, configuration.getPollingInterval(),
+ TimeUnit.SECONDS);
+
}
}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyNotificationCallback.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyNotificationCallback.java
new file mode 100644
index 0000000..82e940d
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyNotificationCallback.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.dmaap;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.IOException;
+import java.util.List;
+
+import org.onap.dcaegen2.services.sonhms.Configuration;
+import org.onap.dcaegen2.services.sonhms.dao.FixedPciCellsRepository;
+import org.onap.dcaegen2.services.sonhms.dao.PciUpdateRepository;
+import org.onap.dcaegen2.services.sonhms.entity.FixedPciCells;
+import org.onap.dcaegen2.services.sonhms.model.Configurations;
+import org.onap.dcaegen2.services.sonhms.model.Payload;
+import org.onap.dcaegen2.services.sonhms.model.PolicyNotification;
+import org.onap.dcaegen2.services.sonhms.utils.BeanUtil;
+import org.slf4j.Logger;
+
+public class PolicyNotificationCallback extends NotificationCallback {
+
+ private static final Logger log = org.slf4j.LoggerFactory.getLogger(PolicyNotificationCallback.class);
+
+ @Override
+ public void activateCallBack(String msg) {
+ handlePolicyNotification(msg);
+ }
+
+ private void handlePolicyNotification(String msg) {
+ PciUpdateRepository pciUpdateRepository = BeanUtil.getBean(PciUpdateRepository.class);
+ Configuration configuration = Configuration.getInstance();
+ try {
+ ObjectMapper mapper = new ObjectMapper();
+ PolicyNotification policyResponse = mapper.readValue(msg, PolicyNotification.class);
+ String payload = policyResponse.getPayload();
+ Payload payloadObject = mapper.readValue(payload, Payload.class);
+ List<Configurations> configurationList = payloadObject.getConfiguration();
+ for (Configurations config : configurationList) {
+ int status = config.getStatus().getCode();
+ if (status != 200) {
+ String cellId = config.getData().getFapservice().getAlias();
+
+ int negativeAckCount = pciUpdateRepository.getNegativeAckCountforCellId(cellId);
+ if (negativeAckCount > configuration.getPolicyNegativeAckThreshold()) {
+ long fixedPci = pciUpdateRepository.getOldPciforCellId(cellId);
+
+ FixedPciCellsRepository fixedPciCellsRepository = BeanUtil
+ .getBean(FixedPciCellsRepository.class);
+ FixedPciCells fixedPciCells = new FixedPciCells();
+ fixedPciCells.setCellId(cellId);
+ fixedPciCells.setFixedPci(fixedPci);
+ fixedPciCellsRepository.save(fixedPciCells);
+ pciUpdateRepository.deleterecordforCellId(cellId);
+ } else {
+
+ pciUpdateRepository.increaseNegativeAckCountforCellId(++negativeAckCount, cellId);
+ }
+ } else {
+
+ String cellId = config.getData().getFapservice().getAlias();
+ pciUpdateRepository.deleterecordforCellId(cellId);
+ }
+
+ String statusToString = Integer.toString(status);
+ log.info("Handled response from policy, status code {}", statusToString);
+ }
+ } catch (IOException e) {
+ log.info("caught io exception while fetching policy response");
+
+ }
+ }
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/entity/FixedPciCells.java b/src/main/java/org/onap/dcaegen2/services/sonhms/entity/FixedPciCells.java
new file mode 100644
index 0000000..e48a054
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/entity/FixedPciCells.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.entity;
+
+import java.sql.Timestamp;
+import javax.persistence.Column;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Entity;
+import org.hibernate.annotations.CreationTimestamp;
+
+@Entity
+@Table(name ="FIXED_PCI_CELLS")
+public class FixedPciCells {
+
+ @Id
+ @Column(name = "cell_id", columnDefinition = "text")
+ private String cellId;
+
+ @Column(name = "fixed_pci", columnDefinition = "bigint")
+ private long fixedPci;
+
+ @CreationTimestamp
+ @Column(name = "created_at", columnDefinition = "timestamp")
+ private Timestamp createdAt;
+
+ public FixedPciCells() {
+
+ }
+
+ public FixedPciCells(String cellId, long fixedPci, Timestamp createdAt) {
+ this.cellId = cellId;
+ this.fixedPci = fixedPci;
+ this.createdAt = createdAt;
+ }
+
+ public String getCellId() {
+ return cellId;
+ }
+
+ public void setCellId(String cellId) {
+ this.cellId = cellId;
+ }
+
+ public long getFixedPci() {
+ return fixedPci;
+ }
+
+ public void setFixedPci(long fixedPci) {
+ this.fixedPci = fixedPci;
+ }
+
+ public Timestamp getCreatedAt() {
+ return createdAt;
+ }
+
+ public void setCreatedAt(Timestamp createdAt) {
+ this.createdAt = createdAt;
+ }
+
+
+
+
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/entity/PciUpdate.java b/src/main/java/org/onap/dcaegen2/services/sonhms/entity/PciUpdate.java
new file mode 100644
index 0000000..8c04922
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/entity/PciUpdate.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.entity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "PCI_UPDATE")
+public class PciUpdate {
+
+ @Id
+ @Column(name = "cell_id", columnDefinition = "text")
+ private String cellId;
+
+ @Column(name = "old_pci", columnDefinition = "bigint")
+ private long oldPci;
+
+ @Column(name = "new_pci", columnDefinition = "bigint")
+ private long newPci;
+
+ @Column(name = "negative_ack_count", columnDefinition = "int")
+ private int negativeAckCount;
+
+ public PciUpdate() {
+
+ }
+
+ public PciUpdate(String cellId, long oldPci, long newPci, int negativeAckCount) {
+ this.cellId = cellId;
+ this.oldPci = oldPci;
+ this.newPci = newPci;
+ this.negativeAckCount = negativeAckCount;
+ }
+
+ public String getCellId() {
+ return cellId;
+ }
+
+ public void setCellId(String cellId) {
+ this.cellId = cellId;
+ }
+
+ public long getOldPci() {
+ return oldPci;
+ }
+
+ public void setOldPci(long oldPci) {
+ this.oldPci = oldPci;
+ }
+
+ public long getNewPci() {
+ return newPci;
+ }
+
+ public void setNewPci(long newPci) {
+ this.newPci = newPci;
+ }
+
+ public int getNegativeAckCount() {
+ return negativeAckCount;
+ }
+
+ public void setNegativeAckCount(int negativeAckCount) {
+ this.negativeAckCount = negativeAckCount;
+ }
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/CellInfo.java b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/CellInfo.java
index ccca473..273b480 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/CellInfo.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/CellInfo.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.
@@ -32,6 +32,7 @@ public class CellInfo {
List<String> cellIdList = new ArrayList<>();
protected List<AnrInput> anrInputList = new ArrayList<>();
String trigger;
+ List<String> fixedPCICells = new ArrayList<>();
public List<AnrInput> getAnrInputList() {
@@ -66,6 +67,11 @@ public class CellInfo {
this.cellIdList = cellIdList;
}
-
+ public List<String> getFixedPCICells() {
+ return fixedPCICells;
+ }
+ public void setFixedPCICells(List<String> fixedPCICells) {
+ this.fixedPCICells = fixedPCICells;
+ }
}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/OofRestClient.java b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/OofRestClient.java
index d6b6c74..ca56e89 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/OofRestClient.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/OofRestClient.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.
@@ -53,7 +53,7 @@ public class OofRestClient {
*/
public static String queryOof(int numSolutions, String transactionId, String requestType, List<String> cellIdList,
- String networkId, List<String> optimizers, List<AnrInput> anrInputList) throws OofNotFoundException {
+ String networkId, List<String> optimizers, List<AnrInput> anrInputList, List<String> fixedPciCells) throws OofNotFoundException {
log.debug("inside queryoof");
Configuration configuration = Configuration.getInstance();
@@ -82,6 +82,9 @@ public class OofRestClient {
if (!anrInputList.isEmpty()) {
cellInfo.setAnrInputList(anrInputList);
}
+ if(!fixedPciCells.isEmpty()) {
+ cellInfo.setFixedPCICells(fixedPciCells);
+ }
OofRequestBody oofRequestBody = new OofRequestBody();
oofRequestBody.setRequestInfo(requestInfo);
oofRequestBody.setCellInfo(cellInfo);
@@ -98,7 +101,7 @@ public class OofRestClient {
String requestUrl = configuration.getOofService() + configuration.getOofEndpoint();
log.info("requestUrl {}", requestUrl);
- ResponseEntity<String> response = null;
+ ResponseEntity<String> response = null;
response = SonHandlerRestTemplate.sendPostRequestToOof(requestUrl, requestBody,
new ParameterizedTypeReference<String>() {
});
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/utils/ThreadUtils.java b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/ThreadUtils.java
index 2c2a764..011b6a6 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/utils/ThreadUtils.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/ThreadUtils.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.
@@ -49,8 +49,21 @@ public class ThreadUtils {
*/
public Boolean createNewThread(List<Graph> newClusters, BlockingQueue<List<String>> childStatusQueue,
ExecutorService pool, EventHandler eventHandler,String cellId) {
-
-
+
+ if (newClusters.isEmpty()) {
+
+ BlockingQueue<Map<CellPciPair, ArrayList<CellPciPair>>> queue = new LinkedBlockingQueue<>();
+ ThreadId threadId = new ThreadId();
+ threadId.setChildThreadId(0);
+ ChildThread child = new ChildThread(childStatusQueue, new Graph(), queue, threadId,
+ new HoMetricsComponent());
+ log.info("Creating new child thread");
+ pool.execute(child);
+ waitForThreadId(threadId);
+ EventHandler.addChildThreadMap(threadId.getChildThreadId(), child);
+ eventHandler.addChildStatus(threadId.getChildThreadId(), "processingNotifications");
+ }
+
for (Graph cluster : newClusters) {
BlockingQueue<Map<CellPciPair, ArrayList<CellPciPair>>> queue = new LinkedBlockingQueue<>();