summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dpo/blueprints/k8s-sonhms-inputs.yaml1
-rw-r--r--dpo/blueprints/k8s-sonhms.yaml5
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java30
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/HoMetricsComponent.java17
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/PmNotificationHandler.java2
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThread.java32
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.java72
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/child/StateOof.java8
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/controller/ConfigFetchFromCbs.java2
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyDmaapClient.java13
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/restclient/CellInfo.java1
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/restclient/OofRestClient.java8
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/utils/SonHandlerRestTemplate.java48
-rw-r--r--src/test/java/org/onap/dcaegen2/services/sonhms/ConfigurationTest.java10
-rw-r--r--src/test/java/org/onap/dcaegen2/services/sonhms/child/TestChildThreadUtils.java2
-rw-r--r--src/test/resources/policy_notification.json2
16 files changed, 175 insertions, 78 deletions
diff --git a/dpo/blueprints/k8s-sonhms-inputs.yaml b/dpo/blueprints/k8s-sonhms-inputs.yaml
index 44b8b2f..5659e07 100644
--- a/dpo/blueprints/k8s-sonhms-inputs.yaml
+++ b/dpo/blueprints/k8s-sonhms-inputs.yaml
@@ -37,6 +37,7 @@ cg: sonhms-cg
cid: sonhms-cid
config_db: http://sdnc.onap:8181
oof: http://oof-osdf.onap:8699
+oof_endpoint: /api/oof/v1/pci
pci_optimizer: pci
pci_anr_optimizer: pci_anr
log_path: /dockerdata-nfs/son-handler
diff --git a/dpo/blueprints/k8s-sonhms.yaml b/dpo/blueprints/k8s-sonhms.yaml
index 0c7ab81..5242577 100644
--- a/dpo/blueprints/k8s-sonhms.yaml
+++ b/dpo/blueprints/k8s-sonhms.yaml
@@ -103,6 +103,10 @@ inputs:
oof:
type: string
description: oof location
+ oof_endpoint:
+ type: string
+ description: oof endpoint
+ default: /api/oof/v1/pci
pci_optimizer:
type: string
description: pci optimizer name in oof
@@ -264,6 +268,7 @@ node_templates:
sonhandler.cid: { get_input: cid }
sonhandler.configDb.service: { get_input: config_db }
sonhandler.oof.service: { get_input: oof }
+ sonhandler.oof.endpoint: { get_input: oof_endpoint }
sonhandler.pciOptimizer: { get_input: pci_optimizer }
sonhandler.pciAnrOptimizer: { get_input: pci_anr_optimizer }
sonhandler.poorCountThreshold: { get_input: poorCountThreshold}
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 5cb145a..faa1b4e 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java
@@ -34,6 +34,7 @@ public class Configuration {
private List<String> dmaapServers;
private String configDbService;
private String oofService;
+ private String oofEndpoint;
private String cg;
private String cid;
private int pollingInterval;
@@ -330,20 +331,29 @@ public class Configuration {
this.pciAnrOptimizer = pciAnrOptimizer;
}
+ public String getOofEndpoint() {
+ return oofEndpoint;
+ }
+
+ public void setOofEndpoint(String oofEndpoint) {
+ this.oofEndpoint = oofEndpoint;
+ }
+
@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 + ", 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 + "]";
+ + ", oofService=" + oofService + ", oofEndpoint=" + oofEndpoint + ", cg=" + cg + ", cid=" + cid
+ + ", pollingInterval=" + pollingInterval + ", pollingTimeout=" + pollingTimeout + ", minCollision="
+ + minCollision + ", minConfusion=" + 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 eca0930..801eaa3 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/HoMetricsComponent.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/HoMetricsComponent.java
@@ -64,16 +64,23 @@ public class HoMetricsComponent {
}
}
+ /**
+ * Update HO metrics.
+ */
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);
+ 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;
}
}
+
+ /**
+ * Get all HO metrics.
+ */
public Either<List<HandOverMetrics>, Integer> getAll() {
HandOverMetricsRepository handOverMetricsRepository = BeanUtil.getBean(HandOverMetricsRepository.class);
try {
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 fe809ec..b9ab254 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/PmNotificationHandler.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/PmNotificationHandler.java
@@ -235,7 +235,6 @@ public class PmNotificationHandler {
}
private Boolean saveToHandOverMetrics(List<HoDetails> hoDetailsList, String srcCellId) {
- HandOverMetricsRepository handOverMetricsRepository = BeanUtil.getBean(HandOverMetricsRepository.class);
ObjectMapper mapper = new ObjectMapper();
String hoDetailsString = null;
try {
@@ -247,6 +246,7 @@ public class PmNotificationHandler {
HandOverMetrics handOverMetrics = new HandOverMetrics();
handOverMetrics.setHoDetails(hoDetailsString);
handOverMetrics.setSrcCellId(srcCellId);
+ HandOverMetricsRepository handOverMetricsRepository = BeanUtil.getBean(HandOverMetricsRepository.class);
handOverMetricsRepository.save(handOverMetrics);
return true;
}
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 0170f90..87c5081 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
@@ -49,6 +49,7 @@ 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.exceptions.OofNotFoundException;
import org.onap.dcaegen2.services.sonhms.model.AnrInput;
import org.onap.dcaegen2.services.sonhms.model.CellPciPair;
import org.onap.dcaegen2.services.sonhms.model.ClusterMap;
@@ -227,7 +228,7 @@ public class ChildThread implements Runnable {
}
policyTriggerFlag.setHolder("CHILD");
policyTriggerFlag.setNumChilds(policyTriggerFlag.getNumChilds() + 1);
-
+
Timer timerOof = BeanUtil.getBean(Timer.class);
if (!timerOof.getIsTimer()) {
log.info("Starting timer");
@@ -238,13 +239,13 @@ public class ChildThread implements Runnable {
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);
+ 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);
@@ -258,7 +259,6 @@ public class ChildThread implements Runnable {
}
transactionId = oof.triggerOof(cellidList, networkId, new ArrayList<>());
-
} else {
log.info("ANR trigger response left {}", anrTriggerResponse.left().value());
List<AnrInput> anrInputList = anrTriggerResponse.left().value();
@@ -268,9 +268,9 @@ public class ChildThread implements Runnable {
}
} else {
-
+
transactionId = oof.triggerOof(cellidList, networkId, new ArrayList<>());
-
+
if (difference > timerThreshold) {
timerOof.setIsTimer(false);
timerOof.setCount(0);
@@ -330,8 +330,17 @@ public class ChildThread implements Runnable {
}
+ } 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();
@@ -444,7 +453,7 @@ public class ChildThread implements Runnable {
Configuration configuration = Configuration.getInstance();
List<HoDetails> hoDetailsList;
Either<List<HandOverMetrics>, Integer> hoMetrics = hoMetricsComponent.getAll();
- if(hoMetrics.isRight()) {
+ if (hoMetrics.isRight()) {
log.error("Error in getting HO details from db");
return Either.right(500);
}
@@ -462,11 +471,10 @@ public class ChildThread implements Runnable {
List<String> removeableNeighbors = new ArrayList<>();
log.info("Checking poor count for src cell {}", hoMetric.getSrcCellId());
for (HoDetails hoDetail : hoDetailsList) {
- if (hoDetail.getPoorCount() >= configuration.getPoorCountThreshold()) {
- removeableNeighbors.add(hoDetail.getDstCellId());
- }
+ if (hoDetail.getPoorCount() >= configuration.getPoorCountThreshold()) {
+ removeableNeighbors.add(hoDetail.getDstCellId());
}
-
+ }
if (!removeableNeighbors.isEmpty()) {
AnrInput anrInput = new AnrInput(hoMetric.getSrcCellId(), removeableNeighbors);
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 d567c8a..852d087 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
@@ -70,7 +70,8 @@ public class ChildThreadUtils {
/**
* Parameterized constructor.
*/
- public ChildThreadUtils(ConfigPolicy configPolicy, PnfUtils pnfUtils, PolicyDmaapClient policyDmaapClient, HoMetricsComponent hoMetricsComponent) {
+ public ChildThreadUtils(ConfigPolicy configPolicy, PnfUtils pnfUtils, PolicyDmaapClient policyDmaapClient,
+ HoMetricsComponent hoMetricsComponent) {
this.configPolicy = configPolicy;
this.pnfUtils = pnfUtils;
this.policyDmaapClient = policyDmaapClient;
@@ -120,11 +121,22 @@ public class ChildThreadUtils {
public String getNotificationString(String pnfName, String requestId, String payloadString, Long alarmStartTime,
String action) {
- String closedLoopControlName = "ControlLoop-vPCI-fb41f388-a5f2-11e8-98d0-529269fb1459";
- try {
- closedLoopControlName = (String) configPolicy.getConfig().get("PCI_MODCONFIG_POLICY_NAME");
- } catch (NullPointerException e) {
- log.error("Config policy not found, Using default");
+ String closedLoopControlName = "";
+ if (action.equals("ModifyConfig")) {
+ closedLoopControlName = "ControlLoop-vPCI-fb41f388-a5f2-11e8-98d0-529269fb1459";
+ try {
+ closedLoopControlName = (String) configPolicy.getConfig().get("PCI_MODCONFIG_POLICY_NAME");
+ } catch (NullPointerException e) {
+ log.error("Config policy not found, Using default");
+ }
+ }
+ else {
+ closedLoopControlName = "ControlLoop-vSONH-7d4baf04-8875-4d1f-946d-06b874048b61";
+ try {
+ closedLoopControlName = (String) configPolicy.getConfig().get("PCI_MODCONFIGANR_POLICY_NAME");
+ } catch (NullPointerException e) {
+ log.error("Config policy not found, Using default");
+ }
}
PolicyNotification policyNotification = new PolicyNotification(closedLoopControlName, requestId, alarmStartTime,
@@ -226,12 +238,12 @@ public class ChildThreadUtils {
null);
configurations.add(configuration);
Either<List<HoDetails>, Integer> hoMetrics = hoMetricsComponent.getHoMetrics(cellId);
- if(hoMetrics.isLeft()) {
+ if (hoMetrics.isLeft()) {
List<HoDetails> hoDetailsList = hoMetrics.left().value();
- for(LteCell lteCell:lteCellList) {
+ for (LteCell lteCell : lteCellList) {
String removedNbr = lteCell.getCid();
- for(HoDetails hoDetail:hoDetailsList) {
- if(removedNbr.equals(hoDetail.getDstCellId())) {
+ for (HoDetails hoDetail : hoDetailsList) {
+ if (removedNbr.equals(hoDetail.getDstCellId())) {
hoDetailsList.remove(hoDetail);
break;
}
@@ -246,27 +258,27 @@ public class ChildThreadUtils {
return false;
}
hoMetricsComponent.update(hoDetailsString, cellId);
+ }
+
}
-
- }
- Payload payload = new Payload(configurations);
- ObjectMapper mapper = new ObjectMapper();
- mapper.setSerializationInclusion(Include.NON_NULL);
- String payloadString = null;
- try {
- payloadString = mapper.writeValueAsString(payload);
- } catch (JsonProcessingException e) {
- log.error("Exception in writing anrupdate string", e);
- }
- String requestId = UUID.randomUUID().toString();
- String notification = getNotificationString(pnfName, requestId, payloadString,
- System.currentTimeMillis(), "ModifyConfigANR");
- 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");
-
+ Payload payload = new Payload(configurations);
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.setSerializationInclusion(Include.NON_NULL);
+ String payloadString = null;
+ try {
+ payloadString = mapper.writeValueAsString(payload);
+ } catch (JsonProcessingException e) {
+ log.error("Exception in writing anrupdate string", e);
+ }
+ String requestId = UUID.randomUUID().toString();
+ String notification = getNotificationString(pnfName, requestId, payloadString,
+ System.currentTimeMillis(), "ModifyConfigANR");
+ 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 8eb5a40..a00c166 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
@@ -71,12 +71,12 @@ public class StateOof {
pciOptimizerList.add(config.getPciOptimizer());
pciAnrOptimizerList.add(config.getPciAnrOptimizer());
-
- String oofResponse =null;
- if(!anrInputList.isEmpty()) {
+
+ String oofResponse = null;
+ if (!anrInputList.isEmpty()) {
oofResponse = OofRestClient.queryOof(numSolutions, transactionId.toString(), "create", cellidList,
networkId, pciAnrOptimizerList, anrInputList);
- }else {
+ } else {
oofResponse = OofRestClient.queryOof(numSolutions, transactionId.toString(), "create", cellidList,
networkId, pciOptimizerList, anrInputList);
}
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 7ec446c..c2e7b63 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
@@ -118,6 +118,7 @@ public class ConfigFetchFromCbs {
String pciAnrOptimizer = jsonObject.get("sonhandler.pciAnrOptimizer").getAsString();
String oofService = jsonObject.get("sonhandler.oof.service").getAsString();
+ String oofEndpoint = jsonObject.get("sonhandler.oof.endpoint").getAsString();
int pollingTimeout = jsonObject.get("sonhandler.pollingTimeout").getAsInt();
int badThreshold = jsonObject.get("sonhandler.badThreshold").getAsInt();
@@ -150,6 +151,7 @@ public class ConfigFetchFromCbs {
configuration.setPciOptimizer(pciOptimizer);
configuration.setPciAnrOptimizer(pciAnrOptimizer);
configuration.setOofService(oofService);
+ configuration.setOofEndpoint(oofEndpoint);
configuration.setPollingTimeout(pollingTimeout);
configuration.setBadThreshold(badThreshold);
configuration.setPoorThreshold(poorThreshold);
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 a0a1274..1a8456f 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
@@ -38,16 +38,15 @@ import org.slf4j.Logger;
public class PolicyDmaapClient {
private static final Logger log = org.slf4j.LoggerFactory.getLogger(PolicyDmaapClient.class);
-
+
private DmaapUtils dmaapUtils;
-
+
private Configuration configuration;
-
-
+
public PolicyDmaapClient(DmaapUtils dmaapUtils, Configuration configuration) {
this.dmaapUtils = dmaapUtils;
this.configuration = configuration;
- }
+ }
/**
* Method stub for sending notification to policy.
@@ -71,7 +70,7 @@ public class PolicyDmaapClient {
}
return true;
}
-
+
/**
* Handles policy response.
*/
@@ -91,7 +90,7 @@ public class PolicyDmaapClient {
Timestamp currentTime = new Timestamp(System.currentTimeMillis());
Long difference = currentTime.getTime() - startTimer.getTime();
int policyRespTimer = configuration.getPolicyRespTimer(); // Timer in seconds
- while (difference < (policyRespTimer*1000)) {
+ while (difference < (policyRespTimer * 1000)) {
Iterable<String> policyResponseMessages;
try {
policyResponseMessages = policyResponseCambriaConsumer.fetch();
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 2501e53..ccca473 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
@@ -26,6 +26,7 @@ import java.util.List;
import org.onap.dcaegen2.services.sonhms.model.AnrInput;
+
public class CellInfo {
String networkId = null;
List<String> cellIdList = new ArrayList<>();
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 97668ed..d6b6c74 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
@@ -96,15 +96,19 @@ public class OofRestClient {
}
log.info("requestBody{}", requestBody);
- String requestUrl = configuration.getOofService() + "/api/oof/pci/v1";
- log.debug("requestUrl {}", requestUrl);
+ String requestUrl = configuration.getOofService() + configuration.getOofEndpoint();
+ log.info("requestUrl {}", requestUrl);
ResponseEntity<String> response = null;
response = SonHandlerRestTemplate.sendPostRequestToOof(requestUrl, requestBody,
new ParameterizedTypeReference<String>() {
});
+
if (response == null) {
throw new OofNotFoundException("Request to oof failed");
}
+ else if (response.getStatusCodeValue() != 202) {
+ throw new OofNotFoundException("Request to oof failed with status code" + response.getStatusCodeValue());
+ }
log.info("response {}", response);
return response.getBody();
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/utils/SonHandlerRestTemplate.java b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/SonHandlerRestTemplate.java
index c46d912..d32a78c 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/utils/SonHandlerRestTemplate.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/SonHandlerRestTemplate.java
@@ -21,8 +21,24 @@
package org.onap.dcaegen2.services.sonhms.utils;
+import java.security.KeyManagementException;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
import java.util.Collections;
+import javax.net.ssl.SSLContext;
+
+import org.apache.http.config.Registry;
+import org.apache.http.config.RegistryBuilder;
+import org.apache.http.conn.socket.ConnectionSocketFactory;
+import org.apache.http.conn.socket.PlainConnectionSocketFactory;
+import org.apache.http.conn.ssl.NoopHostnameVerifier;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.conn.ssl.SSLContexts;
+import org.apache.http.conn.ssl.TrustStrategy;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.impl.conn.BasicHttpClientConnectionManager;
import org.slf4j.Logger;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpEntity;
@@ -31,9 +47,11 @@ import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
+import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
+@SuppressWarnings("deprecation")
@Component
public class SonHandlerRestTemplate {
@@ -42,9 +60,9 @@ public class SonHandlerRestTemplate {
private static final Logger log = org.slf4j.LoggerFactory.getLogger(SonHandlerRestTemplate.class);
private SonHandlerRestTemplate() {
-
+
}
-
+
/**
* Send Post Request.
*/
@@ -64,7 +82,6 @@ public class SonHandlerRestTemplate {
}
}
-
/**
* Send Get Request.
*/
@@ -114,12 +131,33 @@ public class SonHandlerRestTemplate {
headers.add(AUTH, "Basic cGNpX3Rlc3Q6cGNpX3Rlc3Rwd2Q=");
HttpEntity<Object> requestEntity = new HttpEntity<>(requestBody, headers);
try {
- RestTemplate restTemplate = BeanUtil.getBean(RestTemplate.class);
+ RestTemplate restTemplate = new RestTemplate(useApacheHttpClientWithSelfSignedSupport());
return restTemplate.exchange(requestUrl, HttpMethod.POST, requestEntity, responseType);
} catch (Exception e) {
- log.debug(EXCEPTION_MSG, e);
+ log.error(EXCEPTION_MSG, e);
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
}
+ private static HttpComponentsClientHttpRequestFactory useApacheHttpClientWithSelfSignedSupport() {
+
+ TrustStrategy acceptingTrustStrategy = (cert, authType) -> true;
+ SSLContext sslContext = null;
+ try {
+ sslContext = SSLContexts.custom().loadTrustMaterial(null, acceptingTrustStrategy).build();
+ } catch (KeyManagementException | NoSuchAlgorithmException | KeyStoreException e) {
+ log.error(EXCEPTION_MSG, e);
+ }
+ SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE);
+ Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
+ .register("https", sslsf).register("http", new PlainConnectionSocketFactory()).build();
+ BasicHttpClientConnectionManager connectionManager = new BasicHttpClientConnectionManager(
+ socketFactoryRegistry);
+ CloseableHttpClient httpClient = HttpClients.custom().setSSLSocketFactory(sslsf)
+ .setConnectionManager(connectionManager).build();
+ HttpComponentsClientHttpRequestFactory useApacheHttpClient = new HttpComponentsClientHttpRequestFactory();
+ useApacheHttpClient.setHttpClient(httpClient);
+ return useApacheHttpClient;
+ }
+
}
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 f762a5b..8fb4087 100644
--- a/src/test/java/org/onap/dcaegen2/services/sonhms/ConfigurationTest.java
+++ b/src/test/java/org/onap/dcaegen2/services/sonhms/ConfigurationTest.java
@@ -59,8 +59,13 @@ public class ConfigurationTest {
configuration.setMinConfusion(5);
configuration.setNumSolutions(1);
configuration.setOofService("oofService");
+ configuration.setOofEndpoint("/api/oof/v1/pci");
+ configuration.setOofTriggerCountTimer(30);
+ configuration.setOofTriggerCountThreshold(5);
configuration.setBadThreshold(50);
configuration.setPoorThreshold(70);
+ configuration.setBadCountThreshold(3);
+ configuration.setPoorCountThreshold(3);
configuration.setPciOptimizer("pci");
configuration.setPciAnrOptimizer("pci-anr");
configuration.setPollingInterval(30);
@@ -78,6 +83,9 @@ public class ConfigurationTest {
assertEquals(5, configuration.getMinConfusion());
assertEquals(1, configuration.getNumSolutions());
assertEquals("oofService", configuration.getOofService());
+ assertEquals("/api/oof/v1/pci", configuration.getOofEndpoint());
+ assertEquals(30, configuration.getOofTriggerCountTimer());
+ assertEquals(5, configuration.getOofTriggerCountThreshold());
assertEquals("pci", configuration.getPciOptimizer());
assertEquals("pci-anr", configuration.getPciAnrOptimizer());
assertEquals("user", configuration.getPgUsername());
@@ -91,6 +99,8 @@ public class ConfigurationTest {
assertEquals("sourceId", configuration.getSourceId());
assertEquals(50, configuration.getBadThreshold());
assertEquals(70, configuration.getPoorThreshold());
+ assertEquals(3, configuration.getBadCountThreshold());
+ assertEquals(3, configuration.getPoorCountThreshold());
assertEquals(subscribes, configuration.getStreamsSubscribes());
assertEquals(subscribes, configuration.getStreamsPublishes());
}
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 92b2da1..f8a6ae2 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
@@ -163,7 +163,7 @@ public class TestChildThreadUtils {
String requestId = "a4130fd5-2291-4a83-8992-04e4c9f32731";
Long alarmStart = Long.parseLong("1542445563201");
- String result = childThreadUtils.getNotificationString(pnfName, requestId, "payloadString", alarmStart, "action");
+ String result = childThreadUtils.getNotificationString(pnfName, requestId, "payloadString", alarmStart, "ModifyConfig");
PolicyNotification actual = new PolicyNotification();
try {
actual = mapper.readValue(result, PolicyNotification.class);
diff --git a/src/test/resources/policy_notification.json b/src/test/resources/policy_notification.json
index b99a8b9..35fe06c 100644
--- a/src/test/resources/policy_notification.json
+++ b/src/test/resources/policy_notification.json
@@ -14,5 +14,5 @@
"generic-vnf.is-closed-loop-disabled": "false",
"generic-vnf.vnf-id": "ncserver23"
},
- "Action": "action"
+ "Action": "ModifyConfig"
}