aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dpo/blueprints/k8s-sonhms-inputs.yaml8
-rw-r--r--dpo/blueprints/k8s-sonhms.yaml35
-rw-r--r--pom.xml2
-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
-rw-r--r--src/test/java/org/onap/dcaegen2/services/sonhms/ConfigurationTest.java6
-rw-r--r--src/test/java/org/onap/dcaegen2/services/sonhms/HoMetricsComponentTest.java19
-rw-r--r--src/test/java/org/onap/dcaegen2/services/sonhms/PMNotificationHandlerTest.java6
-rw-r--r--src/test/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadTest.java30
-rw-r--r--src/test/java/org/onap/dcaegen2/services/sonhms/child/StateOofTest.java2
-rw-r--r--src/test/java/org/onap/dcaegen2/services/sonhms/child/TestChildThreadUtils.java22
-rw-r--r--src/test/java/org/onap/dcaegen2/services/sonhms/dmaap/DmaapClientTest.java1
-rw-r--r--src/test/java/org/onap/dcaegen2/services/sonhms/restclient/OofRestClientTest.java2
-rw-r--r--version.properties2
24 files changed, 542 insertions, 117 deletions
diff --git a/dpo/blueprints/k8s-sonhms-inputs.yaml b/dpo/blueprints/k8s-sonhms-inputs.yaml
index e417c01..21e0d78 100644
--- a/dpo/blueprints/k8s-sonhms-inputs.yaml
+++ b/dpo/blueprints/k8s-sonhms-inputs.yaml
@@ -18,7 +18,7 @@
pgaas_cluster_name: dcae-pg-primary.onap
database_name: sonhms
-tag_version: nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.son-handler:1.0.0
+tag_version: nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.son-handler:1.0.2
replicas: 1
aaf_username:
aaf_password:
@@ -38,7 +38,13 @@ cid: sonhms-cid
config_db: http://sdnc.onap:8181
oof: http://oof-osdf.onap:8699
pci_optimizer: pci
+pci_anr_optimizer: pci_anr
log_path: /dockerdata-nfs/son-handler
+poorCountThreshold: 3
+badCountThreshold: 3
+oofTriggerCountTimer: 30
+oofTriggerCountThreshold: 5
+policyRespTimer: 10
policy_id: com.Config_PCIMS_CONFIG_POLICY.1.xml
topic00_location: onap
topic00_client_role: son-subscriber
diff --git a/dpo/blueprints/k8s-sonhms.yaml b/dpo/blueprints/k8s-sonhms.yaml
index d77f0fc..aa4178a 100644
--- a/dpo/blueprints/k8s-sonhms.yaml
+++ b/dpo/blueprints/k8s-sonhms.yaml
@@ -30,7 +30,7 @@ inputs:
tag_version:
type: string
description: docker image name and version
- default: "nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.son-handler:1.0.0"
+ default: "nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.son-handler:1.0.2"
pgaas_cluster_name:
type: string
description: pg cluster
@@ -107,10 +107,34 @@ inputs:
type: string
description: pci optimizer name in oof
default: pci
+ pci_anr_optimizer:
+ type: string
+ description: pci and anr optimizer name in oof
+ default: pci_anr
log_path:
type: string
description: log location in host
default: /dockerdata-nfs/son-handler
+ poorCountThreshold:
+ type: integer
+ description: poor neighbor count threshold
+ default: 3
+ badCountThreshold:
+ type: integer
+ description: bad neighbor count threshold
+ default: 3
+ oofTriggerCountTimer:
+ type: integer
+ description: timer for oof triggered count in minutes
+ default: 30
+ oofTriggerCountThreshold:
+ type: integer
+ description: Threshold for oof trigger count
+ default: 5
+ policyRespTimer:
+ type: integer
+ description: policy response wait timer in seconds
+ default: 10
policy_id:
type: string
description: policy id for config policy
@@ -240,8 +264,13 @@ node_templates:
sonhandler.cid: { get_input: cid }
sonhandler.configDb.service: { get_input: config_db }
sonhandler.oof.service: { get_input: oof }
- sonhandler.optimizers:
- - { get_input: pci_optimizer }
+ sonhandler.pciOptimizer: { get_input: pci_optimizer }
+ sonhandler.pciAnrOptimizer: { get_input: pci_anr_optimizer }
+ sonhandler.poorCountThreshold: { get_input: poorCountThreshold}
+ sonhandler.badCountThreshold: { get_input: badCountThreshold}
+ sonhandler.oofTriggerCountTimer: { get_input: oofTriggerCountTimer}
+ sonhandler.oofTriggerCountThreshold: { get_input: oofTriggerCountThreshold}
+ sonhandler.policyRespTimer: { get_input: policyRespTimer}
service_calls:
sdnr-getpnfname: []
sdnr-getpci: []
diff --git a/pom.xml b/pom.xml
index 09d2f88..046dc57 100644
--- a/pom.xml
+++ b/pom.xml
@@ -27,7 +27,7 @@
<groupId>org.onap.dcaegen2.services.son-handler</groupId>
<artifactId>son-handler</artifactId>
<name>dcaegen2-services-son-handler</name>
- <version>1.0.1-SNAPSHOT</version>
+ <version>1.0.2-SNAPSHOT</version>
<!--parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.RELEASE</version> </parent -->
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
diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/ConfigurationTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/ConfigurationTest.java
index 68b94fb..f762a5b 100644
--- a/src/test/java/org/onap/dcaegen2/services/sonhms/ConfigurationTest.java
+++ b/src/test/java/org/onap/dcaegen2/services/sonhms/ConfigurationTest.java
@@ -61,7 +61,8 @@ public class ConfigurationTest {
configuration.setOofService("oofService");
configuration.setBadThreshold(50);
configuration.setPoorThreshold(70);
- configuration.setOptimizers(list);
+ configuration.setPciOptimizer("pci");
+ configuration.setPciAnrOptimizer("pci-anr");
configuration.setPollingInterval(30);
configuration.setPollingTimeout(100);
configuration.setConfigDbService("sdnrService");
@@ -77,7 +78,8 @@ public class ConfigurationTest {
assertEquals(5, configuration.getMinConfusion());
assertEquals(1, configuration.getNumSolutions());
assertEquals("oofService", configuration.getOofService());
- assertEquals(list, configuration.getOptimizers());
+ assertEquals("pci", configuration.getPciOptimizer());
+ assertEquals("pci-anr", configuration.getPciAnrOptimizer());
assertEquals("user", configuration.getPgUsername());
assertEquals("password", configuration.getPgPassword());
assertEquals("pg", configuration.getPgHost());
diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/HoMetricsComponentTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/HoMetricsComponentTest.java
index 9ac056b..4bc4a33 100644
--- a/src/test/java/org/onap/dcaegen2/services/sonhms/HoMetricsComponentTest.java
+++ b/src/test/java/org/onap/dcaegen2/services/sonhms/HoMetricsComponentTest.java
@@ -23,6 +23,7 @@ package org.onap.dcaegen2.services.sonhms;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;
import fj.data.Either;
@@ -30,6 +31,7 @@ import fj.data.Either;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.util.ArrayList;
import java.util.List;
import org.junit.BeforeClass;
@@ -38,6 +40,7 @@ import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
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.powermock.api.mockito.PowerMockito;
@@ -80,6 +83,22 @@ public class HoMetricsComponentTest {
assertEquals(400,res);
}
+ @Test
+ public void getAllTest() {
+ PowerMockito.mockStatic(BeanUtil.class);
+ PowerMockito.when(BeanUtil
+ .getBean(HandOverMetricsRepository.class)).thenReturn(handOverMetricsRepositoryMock);
+ HandOverMetrics hoMetrics = new HandOverMetrics();
+ hoMetrics.setHoDetails("hoDetails");
+ hoMetrics.setSrcCellId("cell1");
+ List<HandOverMetrics> hoList = new ArrayList<>();
+ hoList.add(hoMetrics);
+ Iterable<HandOverMetrics> response = hoList;
+ when(handOverMetricsRepositoryMock.findAll()).thenReturn(response);
+ assertTrue(hoMetricsComponent.getAll().isLeft());
+ when(handOverMetricsRepositoryMock.findAll()).thenReturn(null);
+ assertTrue(hoMetricsComponent.getAll().isRight());
+ }
private static String readFromFile(String file) {
String content = new String();
try {
diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/PMNotificationHandlerTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/PMNotificationHandlerTest.java
index cbd0265..18f9e02 100644
--- a/src/test/java/org/onap/dcaegen2/services/sonhms/PMNotificationHandlerTest.java
+++ b/src/test/java/org/onap/dcaegen2/services/sonhms/PMNotificationHandlerTest.java
@@ -99,9 +99,9 @@ public class PMNotificationHandlerTest {
when(flagMock.getHolder()).thenReturn("NONE");
when(policyDmaapClient.sendNotificationToPolicy(Mockito.anyString())).thenReturn(true);
when(policyDmaapClient.handlePolicyResponse(Mockito.anyString())).thenReturn(true);
- assertTrue(pmNotificationHandler.handlePmNotifications(pmNotification, 50));
- assertFalse(pmNotificationHandler.handlePmNotifications(null, 0));
- assertTrue(pmNotificationHandler.handlePmNotifications(pmNotification1, 50));
+ assertTrue(pmNotificationHandler.handlePmNotifications(pmNotification, 50, 70, 1));
+ assertFalse(pmNotificationHandler.handlePmNotifications(null, 0, 0,0));
+ assertTrue(pmNotificationHandler.handlePmNotifications(pmNotification1, 50, 70, 1));
}
private static String readFromFile(String file) {
diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadTest.java
index a27360e..2003c2c 100644
--- a/src/test/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadTest.java
+++ b/src/test/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadTest.java
@@ -24,6 +24,8 @@ package org.onap.dcaegen2.services.sonhms.child;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
import fj.data.Either;
import java.util.ArrayList;
@@ -33,10 +35,10 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
import org.onap.dcaegen2.services.sonhms.Configuration;
import org.onap.dcaegen2.services.sonhms.HoMetricsComponent;
+import org.onap.dcaegen2.services.sonhms.entity.HandOverMetrics;
import org.onap.dcaegen2.services.sonhms.model.HoDetails;
import org.springframework.boot.test.context.SpringBootTest;
@@ -52,21 +54,33 @@ public class ChildThreadTest {
@Test
public void checkAnrTriggerTest() {
- ArrayList<String> cellidList = new ArrayList<>();
- cellidList.add("cell1");
//PowerMockito.mockStatic(Configuration.class);
Configuration config = Configuration.getInstance() ;
config.setPoorThreshold(70);
+ config.setPoorCountThreshold(3);
//PowerMockito.when(Configuration.getInstance()).thenReturn(config);
- Either<List<HoDetails>, Integer> response = null;
+ Either<List<HandOverMetrics>, Integer> response = null;
+ List<HoDetails> hoDetailsList = new ArrayList<>();
+ List<HandOverMetrics> hoMetrics = new ArrayList<>();
HoDetails hoDetail = new HoDetails();
hoDetail.setDstCellId("dstCell1");
hoDetail.setSuccessRate(60);
- List<HoDetails> hoDetailsList = new ArrayList<>();
+ hoDetail.setPoorCount(4);
hoDetailsList.add(hoDetail);
- response = Either.left(hoDetailsList);
- when(hoMetricsComponent.getHoMetrics(Mockito.anyString())).thenReturn(response);
- assertTrue(childThread.checkAnrTrigger(cellidList).isLeft());
+ HandOverMetrics hoMetric = new HandOverMetrics();
+ hoMetric.setSrcCellId("cell1");
+ ObjectMapper mapper = new ObjectMapper();
+ String hoDetailsString = null;
+ try {
+ hoDetailsString = mapper.writeValueAsString(hoDetailsList);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ hoMetric.setHoDetails(hoDetailsString);
+ hoMetrics.add(hoMetric);
+ response = Either.left(hoMetrics);
+ when(hoMetricsComponent.getAll()).thenReturn(response);
+ assertTrue(childThread.checkAnrTrigger().isLeft());
}
}
diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/child/StateOofTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/child/StateOofTest.java
index 32bfbcf..b597311 100644
--- a/src/test/java/org/onap/dcaegen2/services/sonhms/child/StateOofTest.java
+++ b/src/test/java/org/onap/dcaegen2/services/sonhms/child/StateOofTest.java
@@ -73,7 +73,7 @@ public class StateOofTest {
}
try {
- transactionId = oof.triggerOof(cellList, "networkId", null);
+ transactionId = oof.triggerOof(cellList, "networkId", new ArrayList<>());
} catch (OofNotFoundException | InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/child/TestChildThreadUtils.java b/src/test/java/org/onap/dcaegen2/services/sonhms/child/TestChildThreadUtils.java
index 28940b3..92b2da1 100644
--- a/src/test/java/org/onap/dcaegen2/services/sonhms/child/TestChildThreadUtils.java
+++ b/src/test/java/org/onap/dcaegen2/services/sonhms/child/TestChildThreadUtils.java
@@ -28,6 +28,8 @@ import static org.mockito.Mockito.when;
import com.fasterxml.jackson.databind.ObjectMapper;
+import fj.data.Either;
+
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
@@ -47,11 +49,14 @@ import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
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.HandOverMetricsRepository;
import org.onap.dcaegen2.services.sonhms.dao.SonRequestsRepository;
import org.onap.dcaegen2.services.sonhms.dmaap.PolicyDmaapClient;
import org.onap.dcaegen2.services.sonhms.entity.SonRequests;
import org.onap.dcaegen2.services.sonhms.exceptions.ConfigDbNotFoundException;
import org.onap.dcaegen2.services.sonhms.model.CellPciPair;
+import org.onap.dcaegen2.services.sonhms.model.HoDetails;
import org.onap.dcaegen2.services.sonhms.model.PolicyNotification;
import org.onap.dcaegen2.services.sonhms.restclient.AsyncResponseBody;
import org.onap.dcaegen2.services.sonhms.restclient.SdnrRestClient;
@@ -79,6 +84,12 @@ public class TestChildThreadUtils {
@Mock
private PolicyDmaapClient policyDmaapClient;
+ @Mock
+ private HandOverMetricsRepository hoMetricRepository;
+
+ @Mock
+ private HoMetricsComponent hoMetricsComponent;
+
@InjectMocks
private ChildThreadUtils childThreadUtils2;
@@ -92,7 +103,7 @@ public class TestChildThreadUtils {
Map<String, Object> configPolicyMap = new HashMap<>();
configPolicyMap.put("PCI_MODCONFIG_POLICY_NAME", "ControlLoop-vPCI-fb41f388-a5f2-11e8-98d0-529269fb1459");
configPolicy.setConfig(configPolicyMap);
- childThreadUtils = new ChildThreadUtils(configPolicy, pnfUtils, policyDmaapClient);
+ childThreadUtils = new ChildThreadUtils(configPolicy, pnfUtils, policyDmaapClient, hoMetricsComponent);
MockitoAnnotations.initMocks(this);
}
@@ -167,6 +178,8 @@ public class TestChildThreadUtils {
public void sendToPolicyTest() throws ConfigDbNotFoundException {
PowerMockito.mockStatic(SdnrRestClient.class);
+ PowerMockito.mockStatic(BeanUtil.class);
+
String asyncRspBodyString = readFromFile("/AsyncRespBody.json");
ObjectMapper mapper = new ObjectMapper();
AsyncResponseBody async = new AsyncResponseBody ();
@@ -198,6 +211,13 @@ public class TestChildThreadUtils {
Map<String, List<Map<String,List<String>>>> expected = new HashMap<>();
expected.put("pnfName", list);
when(pnfUtils.getPnfsForAnrSolutions(async.getSolutions().getAnrSolutions())).thenReturn(expected);
+ HoDetails hoDetails = new HoDetails();
+ hoDetails.setDstCellId("EXP006");
+ List<HoDetails> hoDetailsList = new ArrayList<>();
+ hoDetailsList.add(hoDetails);
+ Either<List<HoDetails>, Integer> hoMetrics = Either.left(hoDetailsList);
+ when(hoMetricsComponent.getHoMetrics(Mockito.anyString())).thenReturn(hoMetrics);
+ when(hoMetricsComponent.update(Mockito.anyString(), Mockito.anyString())).thenReturn(true);
assertTrue(childThreadUtils2.sendToPolicy(async));
}
diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/dmaap/DmaapClientTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/dmaap/DmaapClientTest.java
index 4f28e35..2a249fd 100644
--- a/src/test/java/org/onap/dcaegen2/services/sonhms/dmaap/DmaapClientTest.java
+++ b/src/test/java/org/onap/dcaegen2/services/sonhms/dmaap/DmaapClientTest.java
@@ -76,7 +76,6 @@ public class DmaapClientTest {
configuration.setMinConfusion(5);
configuration.setNumSolutions(1);
configuration.setOofService("oofService");
- configuration.setOptimizers(list);
configuration.setPollingInterval(30);
configuration.setPollingTimeout(100);
configuration.setConfigDbService("sdnrService");
diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/OofRestClientTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/OofRestClientTest.java
index 7451ca5..8c1168b 100644
--- a/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/OofRestClientTest.java
+++ b/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/OofRestClientTest.java
@@ -71,7 +71,7 @@ public class OofRestClientTest {
configuration.setMinConfusion(5);
configuration.setNumSolutions(1);
configuration.setOofService("oofService");
- configuration.setOptimizers(list);
+ configuration.setPciOptimizer("pci");
configuration.setPollingInterval(30);
configuration.setPollingTimeout(100);
configuration.setConfigDbService("sdnrService");
diff --git a/version.properties b/version.properties
index 870aad8..7d597d7 100644
--- a/version.properties
+++ b/version.properties
@@ -20,7 +20,7 @@
###############################################################################
major=1
minor=0
-patch=1
+patch=2
base_version=${major}.${minor}.${patch}
release_version=${base_version}
snapshot_version=${base_version}-SNAPSHOT