summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorkrishna <krishna.moorthy6@wipro.com>2019-05-20 17:36:59 +0530
committerVijay Venkatesh Kumar <vv770d@att.com>2019-05-20 19:22:36 +0000
commitd290a8c6849bfd957363ec4c57a477c650429971 (patch)
tree784e2804b9c053c97e7b98612e715e31178bfab9 /src/main/java
parentcf1fb180941364f253de8aea9e1c811abe8b89db (diff)
Change oof trigger functionality considering multiple PM events
Change-Id: I29ec91238b451263127822480e27c6f423635404 Issue-ID: DCAEGEN2-1513 Signed-off-by: krishna <krishna.moorthy6@wipro.com>
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java87
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/HoMetricsComponent.java28
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/PmNotificationHandler.java127
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/PmThread.java3
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/Timer.java75
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThread.java106
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.java32
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/child/StateOof.java18
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/controller/ConfigFetchFromCbs.java19
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyDmaapClient.java4
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/model/HoDetails.java23
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/utils/ThreadUtils.java2
12 files changed, 430 insertions, 94 deletions
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 a0dc6c5..5cb145a 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java
@@ -42,7 +42,8 @@ public class Configuration {
private int minConfusion;
private String sourceId;
private String callbackUrl;
- private List<String> optimizers;
+ private String pciOptimizer;
+ private String pciAnrOptimizer;
private int numSolutions;
private int bufferTime;
private int maximumClusters;
@@ -52,7 +53,53 @@ public class Configuration {
private Map<String, Object> streamsPublishes;
private int badThreshold;
private int poorThreshold;
+ private int poorCountThreshold;
+ private int badCountThreshold;
+ private int oofTriggerCountTimer;
+ private int oofTriggerCountThreshold;
+ private int policyRespTimer;
+
+ public int getPoorCountThreshold() {
+ return poorCountThreshold;
+ }
+
+ public void setPoorCountThreshold(int poorCountThreshold) {
+ this.poorCountThreshold = poorCountThreshold;
+ }
+
+ public int getBadCountThreshold() {
+ return badCountThreshold;
+ }
+
+ public void setBadCountThreshold(int badCountThreshold) {
+ this.badCountThreshold = badCountThreshold;
+ }
+
+ public int getOofTriggerCountTimer() {
+ return oofTriggerCountTimer;
+ }
+
+ public void setOofTriggerCountTimer(int oofTriggerCountTimer) {
+ this.oofTriggerCountTimer = oofTriggerCountTimer;
+ }
+
+ public int getOofTriggerCountThreshold() {
+ return oofTriggerCountThreshold;
+ }
+
+ public void setOofTriggerCountThreshold(int oofTriggerCountThreshold) {
+ this.oofTriggerCountThreshold = oofTriggerCountThreshold;
+ }
+
+ public int getPolicyRespTimer() {
+ return policyRespTimer;
+ }
+
+ public void setPolicyRespTimer(int policyRespTimer) {
+ this.policyRespTimer = policyRespTimer;
+ }
+
public int getBadThreshold() {
return badThreshold;
}
@@ -203,14 +250,6 @@ public class Configuration {
this.callbackUrl = callbackUrl;
}
- public List<String> getOptimizers() {
- return optimizers;
- }
-
- public void setOptimizers(List<String> optimizers) {
- this.optimizers = optimizers;
- }
-
public int getNumSolutions() {
return numSolutions;
}
@@ -275,16 +314,38 @@ public class Configuration {
this.configDbService = configDbService;
}
+ public String getPciOptimizer() {
+ return pciOptimizer;
+ }
+
+ public void setPciOptimizer(String pciOptimizer) {
+ this.pciOptimizer = pciOptimizer;
+ }
+
+ public String getPciAnrOptimizer() {
+ return pciAnrOptimizer;
+ }
+
+ public void setPciAnrOptimizer(String pciAnrOptimizer) {
+ this.pciAnrOptimizer = pciAnrOptimizer;
+ }
+
@Override
public String toString() {
return "Configuration [pgHost=" + pgHost + ", pgPort=" + pgPort + ", pgUsername=" + pgUsername + ", pgPassword="
+ pgPassword + ", dmaapServers=" + dmaapServers + ", configDbService=" + configDbService
+ ", oofService=" + oofService + ", cg=" + cg + ", cid=" + cid + ", pollingInterval=" + pollingInterval
+ ", pollingTimeout=" + pollingTimeout + ", minCollision=" + minCollision + ", minConfusion="
- + minConfusion + ", sourceId=" + sourceId + ", callbackUrl=" + callbackUrl + ", optimizers="
- + optimizers + ", numSolutions=" + numSolutions + ", bufferTime=" + bufferTime + ", maximumClusters="
- + maximumClusters + ", aafUsername=" + aafUsername + ", aafPassword=" + aafPassword
- + ", streamsSubscribes=" + streamsSubscribes + ", streamsPublishes=" + streamsPublishes + "]";
+ + minConfusion + ", sourceId=" + sourceId + ", callbackUrl=" + callbackUrl + ", pciOptimizer="
+ + pciOptimizer + ", pciAnrOptimizer=" + pciAnrOptimizer + ", numSolutions=" + numSolutions
+ + ", bufferTime=" + bufferTime + ", maximumClusters=" + maximumClusters + ", aafUsername=" + aafUsername
+ + ", aafPassword=" + aafPassword + ", streamsSubscribes=" + streamsSubscribes + ", streamsPublishes="
+ + streamsPublishes + ", badThreshold=" + badThreshold + ", poorThreshold=" + poorThreshold
+ + ", poorCountThreshold=" + poorCountThreshold + ", badCountThreshold=" + badCountThreshold
+ + ", oofTriggerCountTimer=" + oofTriggerCountTimer + ", oofTriggerCountThreshold="
+ + oofTriggerCountThreshold + ", policyRespTimer=" + policyRespTimer + "]";
}
+
+
}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/HoMetricsComponent.java b/src/main/java/org/onap/dcaegen2/services/sonhms/HoMetricsComponent.java
index cf1cf45..eca0930 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/HoMetricsComponent.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/HoMetricsComponent.java
@@ -27,9 +27,11 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import fj.data.Either;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import org.onap.dcaegen2.services.sonhms.dao.HandOverMetricsRepository;
+import org.onap.dcaegen2.services.sonhms.entity.HandOverMetrics;
import org.onap.dcaegen2.services.sonhms.model.HoDetails;
import org.onap.dcaegen2.services.sonhms.utils.BeanUtil;
import org.slf4j.Logger;
@@ -61,4 +63,30 @@ public class HoMetricsComponent {
return Either.right(404);
}
}
+
+ public Boolean update(String hoDetails, String srcCellId) {
+ try {
+ HandOverMetricsRepository handOverMetricsRepository = BeanUtil.getBean(HandOverMetricsRepository.class);
+ handOverMetricsRepository.updateHoMetrics(hoDetails, srcCellId);
+ return true;
+ }catch(Exception e) {
+ log.info("Exception in updating ho metrics {}",e);
+ return false;
+ }
+ }
+ public Either<List<HandOverMetrics>, Integer> getAll() {
+ HandOverMetricsRepository handOverMetricsRepository = BeanUtil.getBean(HandOverMetricsRepository.class);
+ try {
+ Iterable<HandOverMetrics> hoMetrics = handOverMetricsRepository.findAll();
+ List<HandOverMetrics> hoMetricsList = new ArrayList<>();
+ Iterator<HandOverMetrics> hoMetricsIterator = hoMetrics.iterator();
+ while (hoMetricsIterator.hasNext()) {
+ hoMetricsList.add(hoMetricsIterator.next());
+ }
+ return Either.left(hoMetricsList);
+ } catch (Exception e) {
+ log.info("error in getAll() hoMetrics");
+ return Either.right(500);
+ }
+ }
}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/PmNotificationHandler.java b/src/main/java/org/onap/dcaegen2/services/sonhms/PmNotificationHandler.java
index e2223d7..fe809ec 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/PmNotificationHandler.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/PmNotificationHandler.java
@@ -23,8 +23,13 @@ package org.onap.dcaegen2.services.sonhms;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.databind.ObjectMapper;
+
+import fj.data.Either;
+
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.UUID;
import org.onap.dcaegen2.services.sonhms.child.ChildThreadUtils;
@@ -67,34 +72,94 @@ public class PmNotificationHandler {
/**
* handle PM notifications.
*/
- public Boolean handlePmNotifications(PmNotification pmNotification, int badThreshold) {
- HandOverMetricsRepository handOverMetricsRepository = BeanUtil.getBean(HandOverMetricsRepository.class);
+ public Boolean handlePmNotifications(PmNotification pmNotification, int badThreshold, int poorThreshold,
+ int badCountThreshold) {
Boolean result;
+ Boolean newEntryFlag = false;
try {
List<HoDetails> hoDetailsList = new ArrayList<>();
List<LteCell> lteCellList = new ArrayList<>();
String srcCellId = pmNotification.getEvent().getCommonEventHeader().getSourceName();
+ /*
+ * check whether entry already exists if yes : read the hometrics and update it
+ * with latest info else store the current data
+ */
+ HoMetricsComponent hoMetricsComponent = new HoMetricsComponent();
+ Either<List<HoDetails>, Integer> hoMetrics = hoMetricsComponent.getHoMetrics(srcCellId);
+ Map<String, Integer> dstCellIdPcPair = new HashMap<>();
+ Map<String, Integer> dstCellIdBcPair = new HashMap<>();
+ if (hoMetrics.isLeft()) {
+ List<HoDetails> oldHoDetailsList = hoMetrics.left().value();
+ for (HoDetails hodetail : oldHoDetailsList) {
+ dstCellIdBcPair.put(hodetail.getDstCellId(), hodetail.getBadCount());
+ dstCellIdPcPair.put(hodetail.getDstCellId(), hodetail.getPoorCount());
+ }
+
+ } else if (hoMetrics.right().value() == 404) {
+ newEntryFlag = true;
+ log.info("no history of srcCell found");
+ }
for (AdditionalMeasurements additionalMeasurements : pmNotification.getEvent().getMeasurementFields()
.getAdditionalMeasurements()) {
int attemptsCount = Integer.parseInt(additionalMeasurements.getHashMap().get("InterEnbOutAtt_X2HO"));
int successCount = Integer.parseInt(additionalMeasurements.getHashMap().get("InterEnbOutSucc_X2HO"));
float successRate = ((float) successCount / attemptsCount) * 100;
- if (successRate >= badThreshold) {
+
+ if (successRate >= badThreshold && successRate <= poorThreshold) { // poor neighbor
HoDetails hoDetails = new HoDetails();
hoDetails.setDstCellId(additionalMeasurements.getName());
hoDetails.setAttemptsCount(attemptsCount);
hoDetails.setSuccessCount(successCount);
hoDetails.setSuccessRate(successRate);
+ int pc = 1;
+ int bc = 0;
+ if (dstCellIdPcPair.containsKey(additionalMeasurements.getName())) {
+ pc = dstCellIdPcPair.get(additionalMeasurements.getName()) + 1;
+ }
+ hoDetails.setBadCount(bc);
+ hoDetails.setPoorCount(pc);
hoDetailsList.add(hoDetails);
- log.info("not bad neighbor {}", additionalMeasurements.getName());
- } else {
+ log.info("poor neighbor {}", additionalMeasurements.getName());
+ } else if (successRate < badThreshold) { // bad neighbor
log.info(" bad neighbor {}", additionalMeasurements.getName());
- LteCell lteCell = new LteCell();
- lteCell.setBlacklisted("true");
- lteCell.setCid(additionalMeasurements.getName());
- lteCell.setPlmnId(additionalMeasurements.getHashMap().get("networkId"));
- lteCell.setPnfName(pmNotification.getEvent().getCommonEventHeader().getReportingEntityName());
- lteCellList.add(lteCell);
+ HoDetails hoDetails = new HoDetails();
+ hoDetails.setDstCellId(additionalMeasurements.getName());
+ hoDetails.setAttemptsCount(attemptsCount);
+ hoDetails.setSuccessCount(successCount);
+ hoDetails.setSuccessRate(successRate);
+ int bc = 1;
+ int pc = 0;
+ if (dstCellIdBcPair.containsKey(additionalMeasurements.getName())) {
+ bc = dstCellIdBcPair.get(additionalMeasurements.getName()) + 1;
+ }
+ if (dstCellIdPcPair.containsKey(additionalMeasurements.getName())) {
+ pc = dstCellIdPcPair.get(additionalMeasurements.getName());
+ }
+ hoDetails.setBadCount(bc);
+ hoDetails.setPoorCount(pc);
+ hoDetailsList.add(hoDetails);
+ if (bc >= badCountThreshold) {
+ LteCell lteCell = new LteCell();
+ lteCell.setBlacklisted("true");
+ lteCell.setCid(additionalMeasurements.getName());
+ lteCell.setPlmnId(additionalMeasurements.getHashMap().get("networkId"));
+ lteCell.setPnfName(pmNotification.getEvent().getCommonEventHeader().getReportingEntityName());
+ lteCellList.add(lteCell);
+ hoDetailsList.remove(hoDetails);
+ }
+
+ } else if (successRate > poorThreshold) { // good neighbor
+ HoDetails hoDetails = new HoDetails();
+ hoDetails.setDstCellId(additionalMeasurements.getName());
+ hoDetails.setAttemptsCount(attemptsCount);
+ hoDetails.setSuccessCount(successCount);
+ hoDetails.setSuccessRate(successRate);
+ int pc = 0;
+ int bc = 0;
+ hoDetails.setBadCount(bc);
+ hoDetails.setPoorCount(pc);
+ hoDetailsList.add(hoDetails);
+ log.info("good neighbor {}", additionalMeasurements.getName());
}
}
if (!lteCellList.isEmpty()) {
@@ -109,24 +174,21 @@ public class PmNotificationHandler {
result = sendAnrUpdateToPolicy(pmNotification, lteCellList);
log.info("Sent ANR update to policy {}", result);
policyTriggerFlag.setHolder("NONE");
-
- String hoDetailsString = handOverMetricsRepository.getHandOverMetrics(srcCellId);
- if (hoDetailsString != null) {
- ObjectMapper mapper = new ObjectMapper();
- String newHoDetailsString = null;
- try {
- newHoDetailsString = mapper.writeValueAsString(hoDetailsList);
- } catch (Exception e) {
- log.error("Error in writing handover metrics json ", e);
- return false;
- }
- handOverMetricsRepository.updateHoMetrics(newHoDetailsString, srcCellId);
- }
}
- if (!hoDetailsList.isEmpty()) {
+ if (!hoDetailsList.isEmpty() && newEntryFlag) {
result = saveToHandOverMetrics(hoDetailsList, srcCellId);
log.debug("save HO metrics result {} ", result);
+ } else if (!hoDetailsList.isEmpty()) {
+ String hoDetailsString = null;
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ hoDetailsString = mapper.writeValueAsString(hoDetailsList);
+ } catch (Exception e) {
+ log.error("Error in writing handover metrics json ", e);
+ return false;
+ }
+ hoMetricsComponent.update(hoDetailsString, srcCellId);
}
} catch (Exception e) {
@@ -153,7 +215,7 @@ public class PmNotificationHandler {
log.info("payload : {}", payload);
String anrUpdateString = mapper.writeValueAsString(payload);
ChildThreadUtils childUtils = new ChildThreadUtils(ConfigPolicy.getInstance(), new PnfUtils(),
- new PolicyDmaapClient(new DmaapUtils(), Configuration.getInstance()));
+ new PolicyDmaapClient(new DmaapUtils(), Configuration.getInstance()), new HoMetricsComponent());
String requestId = UUID.randomUUID().toString();
String notification = childUtils.getNotificationString(
pmNotification.getEvent().getCommonEventHeader().getReportingEntityName(), requestId,
@@ -182,15 +244,10 @@ public class PmNotificationHandler {
log.error("Error in writing handover metrics json ", e);
return false;
}
-
- if (handOverMetricsRepository.getHandOverMetrics(srcCellId) == null) {
- HandOverMetrics handOverMetrics = new HandOverMetrics();
- handOverMetrics.setHoDetails(hoDetailsString);
- handOverMetrics.setSrcCellId(srcCellId);
- handOverMetricsRepository.save(handOverMetrics);
- } else {
- handOverMetricsRepository.updateHoMetrics(hoDetailsString, srcCellId);
- }
+ HandOverMetrics handOverMetrics = new HandOverMetrics();
+ handOverMetrics.setHoDetails(hoDetailsString);
+ handOverMetrics.setSrcCellId(srcCellId);
+ handOverMetricsRepository.save(handOverMetrics);
return true;
}
}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/PmThread.java b/src/main/java/org/onap/dcaegen2/services/sonhms/PmThread.java
index 49f0c56..b2d4568 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/PmThread.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/PmThread.java
@@ -72,7 +72,8 @@ public class PmThread implements Runnable {
} else if (pmNotification.isLeft()) {
Configuration configuration = Configuration.getInstance();
Boolean result = pmNotificationHandler.handlePmNotifications(pmNotification.left().value(),
- configuration.getBadThreshold());
+ configuration.getBadThreshold(), configuration.getPoorThreshold(),
+ configuration.getBadCountThreshold());
log.info("pm notification handler result {}", result);
}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/Timer.java b/src/main/java/org/onap/dcaegen2/services/sonhms/Timer.java
new file mode 100644
index 0000000..aff5fe5
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/Timer.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 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;
+
+import java.sql.Timestamp;
+
+import javax.annotation.PostConstruct;
+import org.springframework.stereotype.Component;
+
+@Component
+public class Timer {
+
+ private Timestamp startTime;
+ private Timestamp currentTime;
+ private Boolean isTimer;
+ private int count;
+
+ @PostConstruct
+ void init() {
+ isTimer = false;
+ count = 0;
+ }
+
+ public Timestamp getStartTime() {
+ return startTime;
+ }
+
+ public void setStartTime(Timestamp startTime) {
+ this.startTime = startTime;
+ }
+
+ public Timestamp getCurrentTime() {
+ return currentTime;
+ }
+
+ public void setCurrentTime(Timestamp currentTime) {
+ this.currentTime = currentTime;
+ }
+
+ public Boolean getIsTimer() {
+ return isTimer;
+ }
+
+ public void setIsTimer(Boolean isTimer) {
+ this.isTimer = isTimer;
+ }
+
+ public int getCount() {
+ return count;
+ }
+
+ public void setCount(int count) {
+ this.count = count;
+ }
+
+} \ No newline at end of file
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 b053467..0170f90 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
@@ -21,6 +21,7 @@
package org.onap.dcaegen2.services.sonhms.child;
+import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import fj.data.Either;
@@ -42,9 +43,11 @@ import org.onap.dcaegen2.services.sonhms.ClusterDetailsComponent;
import org.onap.dcaegen2.services.sonhms.ConfigPolicy;
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.SonRequestsRepository;
import org.onap.dcaegen2.services.sonhms.dmaap.PolicyDmaapClient;
+import org.onap.dcaegen2.services.sonhms.entity.HandOverMetrics;
import org.onap.dcaegen2.services.sonhms.exceptions.ConfigDbNotFoundException;
import org.onap.dcaegen2.services.sonhms.model.AnrInput;
import org.onap.dcaegen2.services.sonhms.model.CellPciPair;
@@ -150,7 +153,7 @@ public class ChildThread implements Runnable {
ClusterUtils clusterUtils = new ClusterUtils();
Detection detect = new Detection();
ChildThreadUtils childUtils = new ChildThreadUtils(ConfigPolicy.getInstance(), new PnfUtils(),
- new PolicyDmaapClient(new DmaapUtils(), Configuration.getInstance()));
+ new PolicyDmaapClient(new DmaapUtils(), Configuration.getInstance()), new HoMetricsComponent());
try {
String networkId = cluster.getNetworkId();
@@ -217,7 +220,7 @@ public class ChildThread implements Runnable {
cellidList.add(cell);
}
UUID transactionId;
-
+
Flag policyTriggerFlag = BeanUtil.getBean(Flag.class);
while (policyTriggerFlag.getHolder().equals("PM")) {
Thread.sleep(100);
@@ -225,21 +228,55 @@ public class ChildThread implements Runnable {
policyTriggerFlag.setHolder("CHILD");
policyTriggerFlag.setNumChilds(policyTriggerFlag.getNumChilds() + 1);
- Either<List<AnrInput>, Integer> anrTriggerResponse = checkAnrTrigger(cellidList);
- if (anrTriggerResponse.isRight()) {
+ 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);
+
+ }
+ Timestamp currentTime = new Timestamp(System.currentTimeMillis());
+ Long difference = currentTime.getTime() - timerOof.getStartTime().getTime();
+ 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);
+ 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);
- if (anrTriggerResponse.right().value() == 404) {
- log.debug("No poor neighbors found");
- } else if (anrTriggerResponse.right().value() == 500) {
- log.debug("Failed to fetch HO details from DB ");
}
- transactionId = oof.triggerOof(cellidList, networkId, new ArrayList<>());
} else {
- List<AnrInput> anrInputList = anrTriggerResponse.left().value();
- log.info("Trigger oof for joint optimization");
- transactionId = oof.triggerOof(cellidList, networkId, anrInputList);
+
+ transactionId = oof.triggerOof(cellidList, networkId, new ArrayList<>());
+
+ if (difference > timerThreshold) {
+ timerOof.setIsTimer(false);
+ timerOof.setCount(0);
+ }
}
+
long childThreadId = Thread.currentThread().getId();
childUtils.saveRequest(transactionId.toString(), childThreadId);
while (!ChildThread.getResponseMap().containsKey(childThreadId)) {
@@ -248,15 +285,12 @@ public class ChildThread implements Runnable {
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);
@@ -404,34 +438,38 @@ public class ChildThread implements Runnable {
/**
* Check if ANR to be triggered.
*/
- public Either<List<AnrInput>, Integer> checkAnrTrigger(List<String> cellidList) {
+ public Either<List<AnrInput>, Integer> checkAnrTrigger() {
List<AnrInput> anrInputList = new ArrayList<>();
Configuration configuration = Configuration.getInstance();
- int poorThreshold = configuration.getPoorThreshold();
List<HoDetails> hoDetailsList;
- Either<List<HoDetails>, Integer> response;
- for (String cellId : cellidList) {
- response = hoMetricsComponent.getHoMetrics(cellId);
+ Either<List<HandOverMetrics>, Integer> hoMetrics = hoMetricsComponent.getAll();
+ if(hoMetrics.isRight()) {
+ log.error("Error in getting HO details from db");
+ return Either.right(500);
+ }
+ List<HandOverMetrics> hoMetricsList = hoMetrics.left().value();
+ for (HandOverMetrics hoMetric : hoMetricsList) {
+ String hoDetailsListString = hoMetric.getHoDetails();
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ hoDetailsList = mapper.readValue(hoDetailsListString, new TypeReference<ArrayList<HoDetails>>() {
+ });
+ } catch (Exception e) {
+ log.error("Exception in parsing HO metrics", hoDetailsListString, e);
+ continue;
+ }
List<String> removeableNeighbors = new ArrayList<>();
- if (response.isLeft()) {
- hoDetailsList = response.left().value();
- for (HoDetails hoDetail : hoDetailsList) {
- if (hoDetail.getSuccessRate() < poorThreshold) {
+ log.info("Checking poor count for src cell {}", hoMetric.getSrcCellId());
+ for (HoDetails hoDetail : hoDetailsList) {
+ if (hoDetail.getPoorCount() >= configuration.getPoorCountThreshold()) {
removeableNeighbors.add(hoDetail.getDstCellId());
}
}
- } else {
- if (response.right().value() == 400) {
- log.error("Error in getting HO details from db");
- return Either.right(500);
- } else {
- log.info("no HO metrics found");
- }
- }
+
if (!removeableNeighbors.isEmpty()) {
- AnrInput anrInput = new AnrInput(cellId, removeableNeighbors);
+ AnrInput anrInput = new AnrInput(hoMetric.getSrcCellId(), removeableNeighbors);
anrInputList.add(anrInput);
}
}
@@ -440,4 +478,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/child/ChildThreadUtils.java b/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.java
index 183de84..d567c8a 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
@@ -25,6 +25,8 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
+import fj.data.Either;
+
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -32,6 +34,7 @@ import java.util.UUID;
import org.onap.dcaegen2.services.sonhms.ConfigPolicy;
import org.onap.dcaegen2.services.sonhms.Configuration;
+import org.onap.dcaegen2.services.sonhms.HoMetricsComponent;
import org.onap.dcaegen2.services.sonhms.dao.SonRequestsRepository;
import org.onap.dcaegen2.services.sonhms.dmaap.PolicyDmaapClient;
import org.onap.dcaegen2.services.sonhms.entity.SonRequests;
@@ -42,6 +45,7 @@ import org.onap.dcaegen2.services.sonhms.model.Common;
import org.onap.dcaegen2.services.sonhms.model.Configurations;
import org.onap.dcaegen2.services.sonhms.model.Data;
import org.onap.dcaegen2.services.sonhms.model.FapService;
+import org.onap.dcaegen2.services.sonhms.model.HoDetails;
import org.onap.dcaegen2.services.sonhms.model.Lte;
import org.onap.dcaegen2.services.sonhms.model.LteCell;
import org.onap.dcaegen2.services.sonhms.model.NeighborListInUse;
@@ -61,14 +65,16 @@ public class ChildThreadUtils {
private ConfigPolicy configPolicy;
private PnfUtils pnfUtils;
private PolicyDmaapClient policyDmaapClient;
+ private HoMetricsComponent hoMetricsComponent;
/**
* Parameterized constructor.
*/
- public ChildThreadUtils(ConfigPolicy configPolicy, PnfUtils pnfUtils, PolicyDmaapClient policyDmaapClient) {
+ public ChildThreadUtils(ConfigPolicy configPolicy, PnfUtils pnfUtils, PolicyDmaapClient policyDmaapClient, HoMetricsComponent hoMetricsComponent) {
this.configPolicy = configPolicy;
this.pnfUtils = pnfUtils;
this.policyDmaapClient = policyDmaapClient;
+ this.hoMetricsComponent = hoMetricsComponent;
}
/**
@@ -219,7 +225,29 @@ public class ChildThreadUtils {
lteCellList, String.valueOf(lteCellList.size()))))))),
null);
configurations.add(configuration);
+ Either<List<HoDetails>, Integer> hoMetrics = hoMetricsComponent.getHoMetrics(cellId);
+ if(hoMetrics.isLeft()) {
+ List<HoDetails> hoDetailsList = hoMetrics.left().value();
+ for(LteCell lteCell:lteCellList) {
+ String removedNbr = lteCell.getCid();
+ for(HoDetails hoDetail:hoDetailsList) {
+ if(removedNbr.equals(hoDetail.getDstCellId())) {
+ hoDetailsList.remove(hoDetail);
+ break;
+ }
+ }
+ }
+ String hoDetailsString = null;
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ hoDetailsString = mapper.writeValueAsString(hoDetailsList);
+ } catch (Exception e) {
+ log.error("Error in writing handover metrics json ", e);
+ return false;
+ }
+ hoMetricsComponent.update(hoDetailsString, cellId);
}
+
}
Payload payload = new Payload(configurations);
ObjectMapper mapper = new ObjectMapper();
@@ -238,6 +266,8 @@ public class ChildThreadUtils {
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 acfa1a4..8eb5a40 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
@@ -66,10 +66,20 @@ public class StateOof {
Configuration config = Configuration.getInstance();
int numSolutions = config.getNumSolutions();
- List<String> optimizers = config.getOptimizers();
-
- String oofResponse = OofRestClient.queryOof(numSolutions, transactionId.toString(), "create", cellidList,
- networkId, optimizers, anrInputList);
+ List<String> pciOptimizerList = new ArrayList<>();
+ List<String> pciAnrOptimizerList = new ArrayList<>();
+
+ pciOptimizerList.add(config.getPciOptimizer());
+ pciAnrOptimizerList.add(config.getPciAnrOptimizer());
+
+ String oofResponse =null;
+ if(!anrInputList.isEmpty()) {
+ oofResponse = OofRestClient.queryOof(numSolutions, transactionId.toString(), "create", cellidList,
+ networkId, pciAnrOptimizerList, anrInputList);
+ }else {
+ oofResponse = OofRestClient.queryOof(numSolutions, transactionId.toString(), "create", cellidList,
+ networkId, pciOptimizerList, anrInputList);
+ }
log.info("Synchronous Response {}", oofResponse);
List<String> childStatus = new ArrayList<>();
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/controller/ConfigFetchFromCbs.java b/src/main/java/org/onap/dcaegen2/services/sonhms/controller/ConfigFetchFromCbs.java
index 548cb4d..7ec446c 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/controller/ConfigFetchFromCbs.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/controller/ConfigFetchFromCbs.java
@@ -114,8 +114,8 @@ public class ConfigFetchFromCbs {
String namespace = jsonObject.get("sonhandler.namespace").getAsString();
String callbackUrl = "http://" + System.getenv("HOSTNAME") + "." + namespace + ":8080/callbackUrl";
- JsonArray optimizersJson = jsonObject.getAsJsonArray("sonhandler.optimizers");
- List<String> optimizers = new Gson().fromJson(optimizersJson, listType);
+ String pciOptimizer = jsonObject.get("sonhandler.pciOptimizer").getAsString();
+ String pciAnrOptimizer = jsonObject.get("sonhandler.pciAnrOptimizer").getAsString();
String oofService = jsonObject.get("sonhandler.oof.service").getAsString();
int pollingTimeout = jsonObject.get("sonhandler.pollingTimeout").getAsInt();
@@ -123,6 +123,12 @@ public class ConfigFetchFromCbs {
int badThreshold = jsonObject.get("sonhandler.badThreshold").getAsInt();
int poorThreshold = jsonObject.get("sonhandler.poorThreshold").getAsInt();
+ int poorCountThreshold = jsonObject.get("sonhandler.poorCountThreshold").getAsInt();
+ int badCountThreshold = jsonObject.get("sonhandler.badCountThreshold").getAsInt();
+ int oofTriggerCountTimer = jsonObject.get("sonhandler.oofTriggerCountTimer").getAsInt();
+ int oofTriggerCountThreshold = jsonObject.get("sonhandler.oofTriggerCountThreshold").getAsInt();
+ int policyRespTimer = jsonObject.get("sonhandler.policyRespTimer").getAsInt();
+
configuration.setStreamsSubscribes(streamsSubscribes);
configuration.setStreamsPublishes(streamsPublishes);
configuration.setPgPassword(pgPassword);
@@ -141,11 +147,18 @@ public class ConfigFetchFromCbs {
configuration.setBufferTime(bufferTime);
configuration.setConfigDbService(configDbService);
configuration.setCallbackUrl(callbackUrl);
- configuration.setOptimizers(optimizers);
+ configuration.setPciOptimizer(pciOptimizer);
+ configuration.setPciAnrOptimizer(pciAnrOptimizer);
configuration.setOofService(oofService);
configuration.setPollingTimeout(pollingTimeout);
configuration.setBadThreshold(badThreshold);
configuration.setPoorThreshold(poorThreshold);
+ configuration.setPoorCountThreshold(poorCountThreshold);
+ configuration.setBadCountThreshold(badCountThreshold);
+ configuration.setOofTriggerCountTimer(oofTriggerCountTimer);
+ configuration.setOofTriggerCountThreshold(oofTriggerCountThreshold);
+ configuration.setPolicyRespTimer(policyRespTimer);
+
log.info("configuration from CBS {}", configuration.toString());
}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyDmaapClient.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyDmaapClient.java
index d5371eb..a0a1274 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyDmaapClient.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyDmaapClient.java
@@ -90,8 +90,8 @@ public class PolicyDmaapClient {
Timestamp currentTime = new Timestamp(System.currentTimeMillis());
Long difference = currentTime.getTime() - startTimer.getTime();
-
- while (difference < 10000) {
+ int policyRespTimer = configuration.getPolicyRespTimer(); // Timer in seconds
+ while (difference < (policyRespTimer*1000)) {
Iterable<String> policyResponseMessages;
try {
policyResponseMessages = policyResponseCambriaConsumer.fetch();
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/HoDetails.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/HoDetails.java
index 1d43f09..b6e2ab9 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/model/HoDetails.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/HoDetails.java
@@ -27,6 +27,8 @@ public class HoDetails {
private int attemptsCount;
private int successCount;
private float successRate;
+ private int poorCount;
+ private int badCount;
/**
* default constructor.
@@ -35,6 +37,27 @@ public class HoDetails {
}
+
+ public int getPoorCount() {
+ return poorCount;
+ }
+
+
+ public void setPoorCount(int poorCount) {
+ this.poorCount = poorCount;
+ }
+
+
+ public int getBadCount() {
+ return badCount;
+ }
+
+
+ public void setBadCount(int badCount) {
+ this.badCount = badCount;
+ }
+
+
public String getDstCellId() {
return dstCellId;
}
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 5889b63..2c2a764 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
@@ -88,4 +88,4 @@ public class ThreadUtils {
}
}
-}
+} \ No newline at end of file