--- /dev/null
+SONHMS
+
+### Build Instructions
+
+This project is organized as a mvn project and has "org.onap.dcaegen2" as parent project. The build generate a jar and package into docker container.
+
+```
+git clone https://gerrit.onap.org/r/dcaegen2/services/son-handler
+mvn clean install
+```
+
+
+### Environment variables in Docker Container
+
+
+Variables coming from deployment system:
+
+- APP_NAME - son-handler application name that will be registered with consul
+- CONSUL_PROTOCOL - Consul protocol by default set to **http**, if it is need to change it then that can be set to different value
+- CONSUL_HOST - used with conjunction with CBSPOLLTIMER, should be a host address (without port! e.g my-ip-or-host) where Consul service lies
+- CBS_PROTOCOL - Config Binding Service protocol by default set to **http**, if it is need to change it then that can be set to different value
+- CONFIG_BINDING_SERVICE - used with conjunction with CBSPOLLTIMER, should be a name of CBS as it is registered in Consul
+- HOSTNAME - used with conjunction with CBSPOLLTIMER, should be a name of sonhms application as it is registered in CBS catalog
+
+### Release images
+For R1 - image/version pushed to nexus3
+```
+nexus3.onap.org:10001/snapshots/onap/org.onap.dcaegen2.services.son-handler 1.0.0
+```
+
+### Deployment
+son handler can be manually deployed in dcae environment using cloudify blueprint.
+
+login to bootstrap container in dcae deployment
+
+To install :
+ cfy install -b sonhms -d sonhms -i <inputs filepath> <blueprint filepath>
+
+To uninstall:
+ cfy uninstall sonhms
+ cfy blueprints delete sonhms
+
+
pgaas_cluster_name: dcae-pg-primary.onap
database_name: sonhms
-tag_version: nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.son-handler:latest
+tag_version: nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.son-handler:1.0.0
replicas: 1
aaf_username:
aaf_password:
max_clusters: 5
bad_threshold: 50
poor_threshold: 70
-dmaap: message-router
+namespace: onap
+dmaap: message-router.onap
buffer_time: 60
cg: sonhms-cg
cid: sonhms-cid
-config_db: http://sdnc.onap.svc.cluster.local:8181
-oof: http://oof.onap.svc.cluster.local:8080
+config_db: http://sdnc.onap:8181
+oof: http://oof-osdf.onap:8080
pci_optimizer: pci
log_path: /dockerdata-nfs/son-handler
topic00_location: onap
tag_version:
type: string
description: docker image name and version
- default: "nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.son-handler:latest"
+ default: "nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.son-handler:1.0.0"
pgaas_cluster_name:
type: string
description: pg cluster
type: integer
description: threshold for poor neighbors
default: 70
+ namespace:
+ type: String
+ description: namespace
+ default: onap
dmaap:
type: string
description: dmaap server
- host:
path: { get_input: log_path }
container:
- bind: /var/log/onap
+ bind: /home/sonhms/logs
mode: rw
properties:
image:
sonhandler.maximumClusters: { get_input: max_clusters }
sonhandler.badThreshold: { get_input: bad_threshold }
sonhandler.poorThreshold: { get_input: poor_threshold }
+ sonhandler.namespace: { get_input: namespace }
sonhandler.sourceId: SONHMS
sonhandler.dmaap.server:
- { get_input: dmaap }
"type": "message router"
},
{
- "format": "FM_ALARM_FROM_VES",
- "version": "1.0.0",
+ "format": "VES_specification",
+ "version": "7.30.1",
"config_key": "fault_management_topic",
"type": "message router"
},
{
- "format": "PM_ALARM_FROM_VES",
- "version": "1.0.0",
+ "format": "VES_specification",
+ "version": "7.30.1",
"config_key": "performance_management_topic",
"type": "message router"
},
<?xml version="1.0" encoding="UTF-8"?>
-<!-- ============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========================================================= -->
+<!--
+/*******************************************************************************
+ * ============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=========================================================
+ *
+ *******************************************************************************/
+ -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
- <sdk.version>1.1.4-SNAPSHOT</sdk.version>
+ <sdk.version>1.1.4</sdk.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</resources>
<runs>
<!-- Maven is loosing file permissions during artifacts copy -->
+ <run>adduser --disabled-password sonhms </run>
<run>chmod +x /bin/entrypoint.sh</run>
<run>mv /bin/*.jar /bin/application.jar</run>
<run>chmod -R 777 /bin</run>
- <run>mkdir /var/log/onap</run>
- <run>chmod -R 777 /var/log/onap</run>
</runs>
<exposes>
<expose>8080</expose>
/*******************************************************************************
- * ============LICENSE_START=======================================================
- * pcims
+ * ============LICENSE_START=======================================================
+ * son-handler
* ================================================================================
- * Copyright (C) 2018 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=========================================================
- ******************************************************************************/
+ * 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;
private String networkId;
private int collisions;
private int confusions;
+
public String getNetworkId() {
return networkId;
}
+
public void setNetworkId(String networkId) {
this.networkId = networkId;
}
+
public int getCollisions() {
return collisions;
}
+
public void setCollisions(int collisions) {
this.collisions = collisions;
}
+
public int getConfusions() {
return confusions;
}
+
public void setConfusions(int confusions) {
this.confusions = confusions;
}
-
+
}
/*******************************************************************************
- * ============LICENSE_START=======================================================
- * pcims
+ * ============LICENSE_START=======================================================
+ * son-handler
* ================================================================================
- * Copyright (C) 2018 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=========================================================
- ******************************************************************************/
+ * 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;
+ alarmAdditionalInformation + "]";
}
- private int faultFieldsVersion;
+ private double faultFieldsVersion;
private String alarmCondition;
private String eventSourceType;
private String specificProblem;
this.alarmAdditionalInformation = alarmAdditionalInformation;
}
- public int getFaultFieldsVersion() {
+ public double getFaultFieldsVersion() {
return faultFieldsVersion;
}
- public void setFaultFieldsVersion(int faultFieldsVersion) {
+ public void setFaultFieldsVersion(double faultFieldsVersion) {
this.faultFieldsVersion = faultFieldsVersion;
}
@Autowired
private NewFmNotification newFmNotification;
+
+
/**
* main thread initialization.
log.debug("initializing main thread");
Thread thread = new Thread(new MainThread(newNotification, newFmNotification));
thread.start();
- Thread pmThread = new Thread(new PMThread(newPmNotification));
+ Thread pmThread = new Thread(new PmThread(newPmNotification));
pmThread.start();
}
}
/*******************************************************************************
- * ============LICENSE_START=======================================================
- * pcims
+ * ============LICENSE_START=======================================================
+ * son-handler
* ================================================================================
- * Copyright (C) 2018 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=========================================================
- ******************************************************************************/
+ * 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 com.fasterxml.jackson.databind.ObjectMapper;
import java.util.ArrayList;
import java.util.List;
+import java.util.UUID;
+
+import org.onap.dcaegen2.services.sonhms.child.ChildThreadUtils;
+import org.onap.dcaegen2.services.sonhms.child.PnfUtils;
import org.onap.dcaegen2.services.sonhms.dao.HandOverMetricsRepository;
import org.onap.dcaegen2.services.sonhms.dmaap.PolicyDmaapClient;
import org.onap.dcaegen2.services.sonhms.entity.HandOverMetrics;
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.Flag;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class PMNotificationHandler {
+public class PmNotificationHandler {
private static Logger log = LoggerFactory.getLogger(DmaapNotificationsComponent.class);
PolicyDmaapClient policyDmaapClient;
- public PMNotificationHandler() {
+ public PmNotificationHandler() {
}
- public PMNotificationHandler(PolicyDmaapClient policyDmaapClient) {
+ public PmNotificationHandler(PolicyDmaapClient policyDmaapClient) {
this.policyDmaapClient = policyDmaapClient;
}
/**
- * handle pm notifications.
+ * handle PM notifications.
*/
public Boolean handlePmNotifications(PMNotification pmNotification, int badThreshold) {
HandOverMetricsRepository handOverMetricsRepository = BeanUtil.getBean(HandOverMetricsRepository.class);
List<HoDetails> hoDetailsList = new ArrayList<>();
List<LteCell> lteCellList = new ArrayList<>();
String srcCellId = pmNotification.getEvent().getCommonEventHeader().getSourceName();
- for (AdditionalMeasurements additionalMeasurements : pmNotification.getEvent().getMeasurement()
+ for (AdditionalMeasurements additionalMeasurements : pmNotification.getEvent().getMeasurementFields()
.getAdditionalMeasurements()) {
int attemptsCount = Integer
- .parseInt(additionalMeasurements.getArrayOfNamedHashMap().get(1).get("InterEnbOutAtt_X2HO"));
+ .parseInt(additionalMeasurements.getHashMap().get("InterEnbOutAtt_X2HO"));
int successCount = Integer
- .parseInt(additionalMeasurements.getArrayOfNamedHashMap().get(2).get("InterEnbOutSucc_X2HO"));
+ .parseInt(additionalMeasurements.getHashMap().get("InterEnbOutSucc_X2HO"));
float successRate = ((float) successCount / attemptsCount) * 100;
if (successRate >= badThreshold) {
HoDetails hoDetails = new HoDetails();
hoDetails.setSuccessCount(successCount);
hoDetails.setSuccessRate(successRate);
hoDetailsList.add(hoDetails);
- log.info("not bad neighbor {}",additionalMeasurements.getName());
+ log.info("not bad neighbor {}", additionalMeasurements.getName());
} else {
- log.info(" bad neighbor {}",additionalMeasurements.getName());
+ log.info(" bad neighbor {}", additionalMeasurements.getName());
LteCell lteCell = new LteCell();
lteCell.setBlacklisted("true");
lteCell.setCid(additionalMeasurements.getName());
- lteCell.setPlmnId(additionalMeasurements.getArrayOfNamedHashMap().get(0).get("networkId"));
+ lteCell.setPlmnId(additionalMeasurements.getHashMap().get("networkId"));
lteCell.setPnfName(pmNotification.getEvent().getCommonEventHeader().getReportingEntityName());
lteCellList.add(lteCell);
}
}
if (!lteCellList.isEmpty()) {
log.info("triggering policy to remove bad neighbors");
+ Flag policyTriggerFlag = BeanUtil.getBean(Flag.class);
+
+ while (policyTriggerFlag.getHolder().equals("CHILD")) {
+ Thread.sleep(100);
+ }
+
+ policyTriggerFlag.setHolder("PM");
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();
log.error("Error in writing handover metrics json ", e);
return false;
}
- handOverMetricsRepository.updateHoMetrics(newHoDetailsString, srcCellId);
+ handOverMetricsRepository.updateHoMetrics(newHoDetailsString, srcCellId);
}
}
if (!hoDetailsList.isEmpty()) {
new NeighborListInUse(null, lteCellList, String.valueOf(lteCellList.size()))))))));
configurations.add(configuration);
Payload payload = new Payload(configurations);
- log.info("payload : {}", payload);
+ log.info("payload : {}", payload);
String anrUpdateString = mapper.writeValueAsString(payload);
+ ChildThreadUtils childUtils = new ChildThreadUtils(ConfigPolicy.getInstance(), new PnfUtils(),
+ new PolicyDmaapClient());
+ String notification = childUtils.getNotificationString(pmNotification.getEvent().getCommonEventHeader().getReportingEntityName(), UUID.randomUUID().toString(), anrUpdateString,
+ System.currentTimeMillis(), "ModifyConfigANR");
+ log.info("Policy Notification: {}", notification);
+ Boolean result = policyDmaapClient.sendNotificationToPolicy(notification);
+ log.info("send notification to policy result {} ", result);
- Boolean result = policyDmaapClient.sendNotificationToPolicy(anrUpdateString);
- log.debug("send notification to policy result {} ", result);
} catch (Exception e) {
log.error("Exception in sending Anr update to policy ", e);
return false;
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 {
+ } else {
handOverMetricsRepository.updateHoMetrics(hoDetailsString, srcCellId);
}
return true;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class PMThread implements Runnable {
+public class PmThread implements Runnable {
- private static Logger log = LoggerFactory.getLogger(PMThread.class);
+ private static Logger log = LoggerFactory.getLogger(PmThread.class);
private NewPmNotification newPmNotification;
+
private DmaapNotificationsComponent dmaapNotificationsComponent;
- private PMNotificationHandler pmNotificationHandler;
+ private PmNotificationHandler pmNotificationHandler;
/**
* parameterized constructor.
*/
- public PMThread(NewPmNotification newPmNotification) {
+ public PmThread(NewPmNotification newPmNotification) {
super();
this.newPmNotification = newPmNotification;
dmaapNotificationsComponent = new DmaapNotificationsComponent();
- pmNotificationHandler = new PMNotificationHandler(new PolicyDmaapClient());
+ pmNotificationHandler = new PmNotificationHandler(new PolicyDmaapClient());
}
@Override
import org.onap.dcaegen2.services.sonhms.model.AnrInput;
import org.onap.dcaegen2.services.sonhms.model.CellPciPair;
import org.onap.dcaegen2.services.sonhms.model.ClusterMap;
+import org.onap.dcaegen2.services.sonhms.model.Flag;
import org.onap.dcaegen2.services.sonhms.model.HoDetails;
import org.onap.dcaegen2.services.sonhms.model.ThreadId;
import org.onap.dcaegen2.services.sonhms.restclient.AsyncResponseBody;
}
MDC.put("logFileName", Thread.currentThread().getName());
- log.debug("Starting child thread");
+ log.info("Starting child thread");
StateOof oof = new StateOof(childStatusUpdate);
ClusterUtils clusterUtils = new ClusterUtils();
// update cluster in DB
clusterUtils.updateCluster(cluster);
+ collisionConfusionResult = detect.detectCollisionConfusion(cluster);
}
- collisionConfusionResult = detect.detectCollisionConfusion(cluster);
}
ArrayList<String> cellidList = new ArrayList<>();
cellidList.add(cell);
}
UUID transactionId;
+
+ Flag policyTriggerFlag = BeanUtil.getBean(Flag.class);
+ while (policyTriggerFlag.getHolder().equals("PM")) {
+ Thread.sleep(100);
+ }
+ policyTriggerFlag.setHolder("CHILD");
+ policyTriggerFlag.setNumChilds(policyTriggerFlag.getNumChilds() + 1);
+
Either<List<AnrInput>, Integer> anrTriggerResponse = checkAnrTrigger(cellidList);
if (anrTriggerResponse.isRight()) {
- if (anrTriggerResponse.right().value() == 404)
+
+ if (anrTriggerResponse.right().value() == 404) {
log.debug("No poor neighbors found");
- else if (anrTriggerResponse.right().value() == 500)
+ } 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);
}
long childThreadId = Thread.currentThread().getId();
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);
}
return clusterMapList;
}
+ /**
+ * Check if ANR to be triggered.
+ */
public Either<List<AnrInput>, Integer> checkAnrTrigger(List<String> cellidList) {
List<AnrInput> anrInputList = new ArrayList<>();
import org.onap.dcaegen2.services.sonhms.model.PolicyNotification;
import org.onap.dcaegen2.services.sonhms.model.Ran;
import org.onap.dcaegen2.services.sonhms.model.X0005b9Lte;
-import org.onap.dcaegen2.services.sonhms.restclient.AnrSolutions;
import org.onap.dcaegen2.services.sonhms.restclient.AsyncResponseBody;
import org.onap.dcaegen2.services.sonhms.restclient.SdnrRestClient;
import org.onap.dcaegen2.services.sonhms.restclient.Solutions;
* get policy notification string from oof result.
*
*/
- public String getNotificationString(String pnfName, List<CellPciPair> cellPciPairs, String requestId,
- Long alarmStartTime) {
- ArrayList<Configurations> configurations = new ArrayList<>();
- for (CellPciPair cellPciPair : cellPciPairs) {
- String cellId = cellPciPair.getCellId();
- int pci = cellPciPair.getPhysicalCellId();
- Configurations configuration = new Configurations(new Data(new FapService(cellId,
- new X0005b9Lte(pci, pnfName), new CellConfig(new Lte(new Ran(new Common(cellId), null))))));
- configurations.add(configuration);
- }
-
- Payload payload = new Payload(configurations);
- ObjectMapper mapper = new ObjectMapper();
- mapper.setSerializationInclusion(Include.NON_NULL);
- String payloadString = "";
- try {
- payloadString = mapper.writeValueAsString(payload);
- } catch (JsonProcessingException e) {
- log.debug("JSON processing exception: {}", e);
- }
-
+ 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");
}
PolicyNotification policyNotification = new PolicyNotification(closedLoopControlName, requestId, alarmStartTime,
- pnfName);
+ pnfName, action);
policyNotification.setClosedLoopControlName(closedLoopControlName);
policyNotification.setPayload(payloadString);
+ ObjectMapper mapper = new ObjectMapper();
String notification = "";
try {
* @throws ConfigDbNotFoundException
* when config db is unreachable
*/
- public void sendToPolicy(AsyncResponseBody async) throws ConfigDbNotFoundException {
+ public Boolean sendToPolicy(AsyncResponseBody async) throws ConfigDbNotFoundException {
if (log.isDebugEnabled()) {
log.debug(async.toString());
Solutions solutions;
solutions = async.getSolutions();
-
if (!solutions.getPciSolutions().isEmpty()) {
Map<String, List<CellPciPair>> pnfs = pnfUtils.getPnfs(solutions);
-
for (Map.Entry<String, List<CellPciPair>> entry : pnfs.entrySet()) {
String pnfName = entry.getKey();
List<CellPciPair> cellPciPairs = entry.getValue();
+ ArrayList<Configurations> configurations = new ArrayList<>();
+ for (CellPciPair cellPciPair : cellPciPairs) {
+ String cellId = cellPciPair.getCellId();
+ int pci = cellPciPair.getPhysicalCellId();
+ Configurations configuration = new Configurations(new Data(new FapService(cellId,
+ new X0005b9Lte(pci, pnfName), new CellConfig(new Lte(new Ran(new Common(cellId), null))))));
+ configurations.add(configuration);
+ }
+
+ Payload payload = new Payload(configurations);
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.setSerializationInclusion(Include.NON_NULL);
+ String payloadString = "";
+ try {
+ payloadString = mapper.writeValueAsString(payload);
+ } catch (JsonProcessingException e) {
+ log.debug("JSON processing exception: {}", e);
+ }
- String notification = getNotificationString(pnfName, cellPciPairs, UUID.randomUUID().toString(),
- System.currentTimeMillis());
- log.debug("Policy Notification: {}", notification);
- PolicyDmaapClient policy = new PolicyDmaapClient();
- boolean status = policy.sendNotificationToPolicy(notification);
+ String notification = getNotificationString(pnfName, UUID.randomUUID().toString(), payloadString,
+ System.currentTimeMillis(), "ModifyConfig");
+ log.info("Policy Notification: {}", notification);
+ boolean status = policyDmaapClient.sendNotificationToPolicy(notification);
log.debug("sent Message: {}", status);
if (status) {
log.debug("Message sent to policy");
}
}
if (!solutions.getAnrSolutions().isEmpty()) {
-
+ Map<String, List<Map<String,List<String>>>> anrPnfs;
List<Configurations> configurations = new ArrayList<>();
- for (AnrSolutions anrSolution : solutions.getAnrSolutions()) {
- String cellId = anrSolution.getCellId();
- List<LteCell> lteCellList = new ArrayList<>();
- for (String removeableNeighbor : anrSolution.getRemoveableNeighbors()) {
- LteCell lteCell = new LteCell();
- lteCell.setBlacklisted("true");
- lteCell.setPlmnId(solutions.getNetworkId());
- lteCell.setCid(removeableNeighbor);
- int pci = SdnrRestClient.getPci(cellId);
- String pnfName = SdnrRestClient.getPnfName(cellId);
- lteCell.setPhyCellId(pci);
- lteCell.setPnfName(pnfName);
- lteCellList.add(lteCell);
+ anrPnfs = pnfUtils.getPnfsForAnrSolutions(solutions.getAnrSolutions());
+ for(Map.Entry<String, List<Map<String,List<String>>>> entry : anrPnfs.entrySet()) {
+ String pnfName = entry.getKey();
+ for(Map<String,List<String>> cellRemNeighborsPair : anrPnfs.get(pnfName)) {
+ for(Map.Entry<String, List<String>> entry1 : cellRemNeighborsPair.entrySet()) {
+ String cellId = entry1.getKey();
+ List<LteCell> lteCellList = new ArrayList<>();
+ for(String removeableNeighbor : entry1.getValue()) {
+ LteCell lteCell = new LteCell();
+ lteCell.setBlacklisted("true");
+ lteCell.setPlmnId(solutions.getNetworkId());
+ lteCell.setCid(removeableNeighbor);
+ int pci = SdnrRestClient.getPci(cellId);
+ lteCell.setPhyCellId(pci);
+ lteCell.setPnfName(pnfName);
+ lteCellList.add(lteCell);
+ }
+ Configurations configuration = new Configurations(
+ new Data(new FapService(cellId, null, new CellConfig(new Lte(new Ran(new Common(cellId),
+ new NeighborListInUse(null, lteCellList, String.valueOf(lteCellList.size()))))))));
+ configurations.add(configuration);
+ }
}
- Configurations configuration = new Configurations(
- new Data(new FapService(cellId, null, new CellConfig(new Lte(new Ran(new Common(cellId),
- new NeighborListInUse(null, lteCellList, String.valueOf(lteCellList.size()))))))));
- configurations.add(configuration);
- }
- Payload payload = new Payload(configurations);
- ObjectMapper mapper = new ObjectMapper();
- mapper.setSerializationInclusion(Include.NON_NULL);
- String anrUpdateString = null;
- try {
- anrUpdateString = mapper.writeValueAsString(payload);
- } catch (JsonProcessingException e) {
- log.error("Exception in writing anrupdate string", e);
+ 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 notification = getNotificationString(pnfName, UUID.randomUUID().toString(), payloadString,
+ System.currentTimeMillis(), "ModifyConfigANR");
+ log.info("Policy Notification: {}", notification);
+ Boolean result = policyDmaapClient.sendNotificationToPolicy(notification);
+ log.info("send notification to policy result {} ", result);
}
- Boolean result = policyDmaapClient.sendNotificationToPolicy(anrUpdateString);
- log.debug("send notification to policy result {} ", result);
+
}
+ return true;
}
}
import org.onap.dcaegen2.services.sonhms.entity.CellInfo;
import org.onap.dcaegen2.services.sonhms.exceptions.ConfigDbNotFoundException;
import org.onap.dcaegen2.services.sonhms.model.CellPciPair;
+import org.onap.dcaegen2.services.sonhms.restclient.AnrSolutions;
import org.onap.dcaegen2.services.sonhms.restclient.PciSolutions;
import org.onap.dcaegen2.services.sonhms.restclient.SdnrRestClient;
import org.onap.dcaegen2.services.sonhms.restclient.Solutions;
import org.onap.dcaegen2.services.sonhms.utils.BeanUtil;
+import org.slf4j.Logger;
public class PnfUtils {
+ private static final Logger log = org.slf4j.LoggerFactory.getLogger(ChildThreadUtils.class);
+
/**
* get pnfs.
*
}
return pnfs;
}
+
+ /**
+ * get pnfs for ANR solutions
+ *
+ */
+ public Map<String, List<Map<String,List<String>>>> getPnfsForAnrSolutions(List<AnrSolutions> anrSolutions) throws ConfigDbNotFoundException {
+
+ Map<String, List<Map<String,List<String>>>> anrPnfs = new HashMap<>();
+
+ List<String> removeableNeighbors;
+ for(AnrSolutions anrSolution : anrSolutions) {
+ String cellId = anrSolution.getCellId();
+ String pnfName = SdnrRestClient.getPnfName(cellId);
+ removeableNeighbors = anrSolution.getRemoveableNeighbors();
+ Map<String,List<String>> cellRemNeighborsPair = new HashMap<>();
+ cellRemNeighborsPair.put(cellId, removeableNeighbors);
+ if(anrPnfs.containsKey(pnfName)) {
+ anrPnfs.get(pnfName).add(cellRemNeighborsPair);
+ }else {
+ List<Map<String,List<String>>> anrCells = new ArrayList<>();
+ anrCells.add(cellRemNeighborsPair);
+ anrPnfs.put(pnfName, anrCells);
+ }
+ }
+ log.info("anr Pnfs {}",anrPnfs.toString());
+ return anrPnfs;
+
+ }
}
log.info("Updating configuration from CBS");
Configuration configuration = Configuration.getInstance();
- log.debug("configuration from CBS {}", jsonObject);
+ log.info("configuration from CBS {}", jsonObject);
Type mapType = new TypeToken<Map<String, Object>>() {}.getType();
int bufferTime = jsonObject.get("sonhandler.bufferTime").getAsInt();
String cid = jsonObject.get("sonhandler.cid").getAsString();
String configDbService = jsonObject.get("sonhandler.configDb.service").getAsString();
-
- String callbackUrl = "http://" + System.getenv("HOSTNAME") + ":8080/callbackUrl";
+ 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);
configuration.setPollingTimeout(pollingTimeout);
configuration.setBadThreshold(badThreshold);
configuration.setPoorThreshold(poorThreshold);
+ log.info("configuration from CBS {}", configuration.toString());
+
}
}
package org.onap.dcaegen2.services.sonhms.model;
-import java.util.List;
import java.util.Map;
public class AdditionalMeasurements {
String name;
- List<Map<String,String>> arrayOfNamedHashMap;
+ Map<String,String> hashMap ;
public AdditionalMeasurements() {
public void setName(String name) {
this.name = name;
}
- public List<Map<String, String>> getArrayOfNamedHashMap() {
- return arrayOfNamedHashMap;
+ public Map<String, String> getHashMap() {
+ return hashMap;
}
- public void setArrayOfNamedHashMap(List<Map<String, String>> arrayOfNamedHashMap) {
- this.arrayOfNamedHashMap = arrayOfNamedHashMap;
+ public void setHashMap(Map<String, String> hashMap) {
+ this.hashMap = hashMap;
}
@Override
public String toString() {
- return "AdditionalMeasurements [name=" + name + ", arrayOfNamedHashMap=" + arrayOfNamedHashMap + "]";
+ return "AdditionalMeasurements [name=" + name + ", hashMap=" + hashMap + "]";
}
-
+
+
}
public class Event {
CommonEventHeader commonEventHeader;
- Measurement measurement;
+ MeasurementFields measurementFields;
public Event() {
this.commonEventHeader = commonEventHeader;
}
- public Measurement getMeasurement() {
- return measurement;
+ public MeasurementFields getMeasurementFields() {
+ return measurementFields;
}
- public void setMeasurement(Measurement measurement) {
- this.measurement = measurement;
+ public void setMeasurementFields(MeasurementFields measurementFields) {
+ this.measurementFields = measurementFields;
}
+
+
}
--- /dev/null
+/*******************************************************************************
+ * ============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.model;
+
+import javax.annotation.PostConstruct;
+
+import org.springframework.stereotype.Component;
+
+@Component
+public class Flag {
+
+ private String holder;
+ private int numChilds;
+
+ @PostConstruct
+ void setup() {
+ holder = "NONE";
+ numChilds = 0;
+ }
+
+ public String getHolder() {
+ return holder;
+ }
+
+ public void setHolder(String holder) {
+ this.holder = holder;
+ }
+
+ public int getNumChilds() {
+ return numChilds;
+ }
+
+ public void setNumChilds(int numChilds) {
+ this.numChilds = numChilds;
+ }
+
+}
import java.util.List;
-public class Measurement {
+public class MeasurementFields {
String measurementInterval;
+ String measurementFieldsVersion;
+
List<AdditionalMeasurements> additionalMeasurements;
/**
* default constructor
*/
- public Measurement() {
+ public MeasurementFields() {
}
public String getMeasurementInterval() {
this.additionalMeasurements = additionalMeasurements;
}
+ public String getMeasurementFieldsVersion() {
+ return measurementFieldsVersion;
+ }
+ public void setMeasurementFieldsVersion(String measurementFieldsVersion) {
+ this.measurementFieldsVersion = measurementFieldsVersion;
+ }
+
}
* Constructor.
*
*/
- public PolicyNotification(String closedLoopControlName, String requestId, Long alarmStartTime, String pnfName) {
+ public PolicyNotification(String closedLoopControlName, String requestId, Long alarmStartTime, String pnfName, String action) {
this.closedLoopControlName = closedLoopControlName;
this.requestId = requestId;
this.closedLoopEventClient = "microservice.PCI";
this.closedLoopAlarmStart = alarmStartTime;
this.from = "PCIMS";
this.version = "1.0.2";
- this.action = "ModifyConfig";
+ this.action = action;
this.target = "generic-vnf.vnf-id";
this.targetType = "VNF";
this.aai = new HashMap<>();
requestInfo.setRequestType(requestType);
requestInfo.setNumSolutions(numSolutions);
requestInfo.setOptimizers(optimizers);
- Map<String,String> callbackHeader = new HashMap<>();
+ Map<String, String> callbackHeader = new HashMap<>();
callbackHeader.put("Content-Type", "application/json");
requestInfo.setCallbackHeader(callbackHeader);
ConfigPolicy config = ConfigPolicy.getInstance();
log.debug("No config policy available. Using default timeout 60 sec");
}
requestInfo.setTimeout(timeout);
-
+
CellInfo cellInfo = new CellInfo();
cellInfo.setCellIdList(cellIdList);
cellInfo.setNetworkId(networkId);
cellInfo.setTrigger("NbrListChange");
- if(!anrInputList.isEmpty())
+ if (!anrInputList.isEmpty()) {
cellInfo.setAnrInputList(anrInputList);
+ }
OofRequestBody oofRequestBody = new OofRequestBody();
oofRequestBody.setRequestInfo(requestInfo);
oofRequestBody.setCellInfo(cellInfo);
requestBody = mapper.writeValueAsString(oofRequestBody);
} catch (JsonProcessingException e) {
log.error("Exception when forming JSON String {}", e);
-
+
}
- log.debug("requestBody{}", requestBody);
+ log.info("requestBody{}", requestBody);
- String requestUrl = configuration.getOofService() + "/api/oof/v1/pci";
+ String requestUrl = configuration.getOofService() + "/api/oof/pci/v1";
log.debug("requestUrl {}", requestUrl);
ResponseEntity<String> response = null;
response = SonHandlerRestTemplate.sendPostRequestToOof(requestUrl, requestBody,
if (response == null) {
throw new OofNotFoundException("Request to oof failed");
}
- log.debug("response {}", response);
+ log.info("response {}", response);
return response.getBody();
}
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.ResponseEntity;
-
-
public class SdnrRestClient {
private static final String DATETIMEFORMAT = "yyyy-MM-dd HH:mm:ss";
}
- /**
- * Method to get cell list from SDNR.
- *
- * @throws ConfigDbNotFoundException
- * when request to configDB fails
- */
- public static String getCellList(String networkId) throws ConfigDbNotFoundException {
- Configuration configuration = Configuration.getInstance();
- String ts = new SimpleDateFormat(DATETIMEFORMAT).format(new Time(System.currentTimeMillis()));
- String requestUrl = configuration.getConfigDbService() + "/SDNCConfigDBAPI/getCellList" + "/" + networkId + "/"
- + ts;
- return sendRequest(requestUrl);
- }
-
/**
* Method to get neibhbour list from SDNR.
*
public static List<CellPciPair> getNbrList(String cellId) throws ConfigDbNotFoundException {
Configuration configuration = Configuration.getInstance();
String ts = new SimpleDateFormat(DATETIMEFORMAT).format(new Time(System.currentTimeMillis()));
- String requestUrl = configuration.getConfigDbService() + "/SDNCConfigDBAPI/getNbrList" + "/" + cellId + "/"
- + ts;
+ String requestUrl = configuration.getConfigDbService() + "/api/sdnc-config-db/v3/getNbrList" + "/" + cellId
+ + "/" + ts;
log.debug("request url: {}", requestUrl);
String response = sendRequest(requestUrl);
List<CellPciPair> nbrList = new ArrayList<>();
- JSONArray nbrListObj = new JSONArray(response);
+ JSONObject responseJson = new JSONObject(response);
+ JSONArray nbrListObj = responseJson.getJSONArray("nbrList");
for (int i = 0; i < nbrListObj.length(); i++) {
JSONObject cellObj = nbrListObj.getJSONObject(i);
- CellPciPair cell = new CellPciPair(cellObj.getString("cellId"), cellObj.getInt("pciValue"));
- nbrList.add(cell);
+ if (cellObj.getBoolean("ho")) {
+ CellPciPair cell = new CellPciPair(cellObj.getString("targetCellId"), cellObj.getInt("pciValue"));
+ nbrList.add(cell);
+ }
}
return nbrList;
public static int getPci(String cellId) throws ConfigDbNotFoundException {
Configuration configuration = Configuration.getInstance();
String ts = new SimpleDateFormat(DATETIMEFORMAT).format(new Time(System.currentTimeMillis()));
- String requestUrl = configuration.getConfigDbService() + "/SDNCConfigDBAPI/getPCI" + "/" + cellId + "/"
+ String requestUrl = configuration.getConfigDbService() + "/api/sdnc-config-db/v3/getPCI" + "/" + cellId + "/"
+ ts;
String response = sendRequest(requestUrl);
JSONObject respObj = new JSONObject(response);
public static String getPnfName(String cellId) throws ConfigDbNotFoundException {
Configuration configuration = Configuration.getInstance();
String ts = new SimpleDateFormat(DATETIMEFORMAT).format(new Time(System.currentTimeMillis()));
- String requestUrl = configuration.getConfigDbService() + "/SDNCConfigDBAPI/getPnfName" + "/" + cellId + "/"
- + ts;
+ String requestUrl = configuration.getConfigDbService() + "/api/sdnc-config-db/v3/getPnfId" + "/" + cellId + "/"
+ + ts;
String response = sendRequest(requestUrl);
JSONObject responseObject = new JSONObject(response);
return responseObject.getString("value");
}
-
/**
* Method to send request.
*/
private static String sendRequest(String url) throws ConfigDbNotFoundException {
ResponseEntity<String> response = SonHandlerRestTemplate.sendGetRequest(url,
- new ParameterizedTypeReference<String>() {});
+ new ParameterizedTypeReference<String>() {
+ });
if (response == null) {
throw new ConfigDbNotFoundException("Cannot reach Config DB");
}
- return response.getBody();
+ return response.getBody();
}
}
/*******************************************************************************
- * ============LICENSE_START=======================================================
- * pcims
+ * ============LICENSE_START=======================================================
+ * son-handler
* ================================================================================
- * Copyright (C) 2018 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=========================================================
- ******************************************************************************/
+ * 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.utils;
<?xml version="1.0" encoding="UTF-8"?>
-<!-- ============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========================================================= -->
-<configuration>
- <appender name="FILE-THREAD" class="ch.qos.logback.classic.sift.SiftingAppender">
- <discriminator>
- <key>logFileName</key>
- <defaultValue>log</defaultValue>
- </discriminator>
+<!--
+/*******************************************************************************
+ * ============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=========================================================
+ *
+ *******************************************************************************/
+ -->
+ <configuration>
+
+ <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
+ <layout class="ch.qos.logback.classic.PatternLayout">
+ <Pattern>
+ %d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n
+ </Pattern>
+ </layout>
+ </appender>
+
+ <root level="info">
+ <appender-ref ref="CONSOLE"/>
+ </root>
- <sift>
- <appender name="file-${logFileName}"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>/var/log/onap/son-handler/${logFileName}.log</file>
- <rollingPolicy
- class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
- <fileNamePattern>${logFileName}.%i.log.zip</fileNamePattern>
- <minIndex>1</minIndex>
- <maxIndex>5</maxIndex>
- </rollingPolicy>
- <triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <maxFileSize>5MB</maxFileSize>
- </triggeringPolicy>
- <encoder>
- <pattern>%d{dd-MM-yyyy HH:mm:ss.SSS} %magenta([%thread])
- %highlight(%-5level) %logger{36}.%M - %msg%n</pattern>
- </encoder>
- </appender>
- </sift>
- </appender>
- <root level="info">
- <appender-ref ref="FILE-THREAD" />
- </root>
</configuration>
/*******************************************************************************
- * ============LICENSE_START=======================================================
- * pcims
+ * ============LICENSE_START=======================================================
+ * son-handler
* ================================================================================
- * Copyright (C) 2018 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=========================================================
- ******************************************************************************/
+ * 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;
faultFields.setEventSeverity("eventSeverity");
faultFields.setEventSourceType("eventSourceType");
- faultFields.setFaultFieldsVersion(0);
+ faultFields.setFaultFieldsVersion(4.0);
faultFields.setAlarmAdditionalInformation(alarmAdditionalInformation);
faultFields.setSpecificProblem("specificProblem");
assertEquals("alarmCondition", faultFields.getAlarmCondition());
assertEquals(1, faultFields.getAlarmAdditionalInformation().getCollisions());
assertEquals(3, faultFields.getAlarmAdditionalInformation().getConfusions());
- assertEquals(0, faultFields.getFaultFieldsVersion());
+ assertEquals(4.0, faultFields.getFaultFieldsVersion(), 0);
assertEquals("eventSeverity", faultFields.getEventSeverity());
assertEquals("eventSourceType", faultFields.getEventSourceType());
assertEquals("networkId", faultFields.getAlarmAdditionalInformation().getNetworkId());
/*******************************************************************************
- * ============LICENSE_START=======================================================
- * pcims
+ * ============LICENSE_START=======================================================
+ * son-handler
* ================================================================================
- * Copyright (C) 2018 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=========================================================
- ******************************************************************************/
+ * 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 org.onap.dcaegen2.services.sonhms.dao.HandOverMetricsRepository;
import org.onap.dcaegen2.services.sonhms.dmaap.PolicyDmaapClient;
import org.onap.dcaegen2.services.sonhms.entity.HandOverMetrics;
+import org.onap.dcaegen2.services.sonhms.model.Flag;
import org.onap.dcaegen2.services.sonhms.model.PMNotification;
import org.onap.dcaegen2.services.sonhms.utils.BeanUtil;
import org.powermock.api.mockito.PowerMockito;
@Mock
HandOverMetricsRepository handOverMetricsRepositoryMock;
+ @Mock
+ Flag flagMock;
+
@InjectMocks
- PMNotificationHandler pmNotificationHandler;
+ PmNotificationHandler pmNotificationHandler;
@Mock
PolicyDmaapClient policyDmaapClient;
PowerMockito.mockStatic(BeanUtil.class);
PowerMockito.when(BeanUtil
.getBean(HandOverMetricsRepository.class)).thenReturn(handOverMetricsRepositoryMock);
+ PowerMockito.when(BeanUtil
+ .getBean(Flag.class)).thenReturn(flagMock);
when(handOverMetricsRepositoryMock.save(new HandOverMetrics())).thenReturn(null);
+ when(flagMock.getHolder()).thenReturn("NONE");
when(policyDmaapClient.sendNotificationToPolicy(Mockito.anyString())).thenReturn(true);
assertTrue(pmNotificationHandler.handlePmNotifications(pmNotification, 50));
assertFalse(pmNotificationHandler.handlePmNotifications(null, 0));
import org.onap.dcaegen2.services.sonhms.model.PolicyNotification;
import org.onap.dcaegen2.services.sonhms.restclient.AsyncResponseBody;
import org.onap.dcaegen2.services.sonhms.restclient.SdnrRestClient;
-import org.onap.dcaegen2.services.sonhms.restclient.Solutions;
import org.onap.dcaegen2.services.sonhms.utils.BeanUtil;
import org.onap.dcaegen2.services.sonhms.utils.ClusterUtilsTest;
import org.powermock.api.mockito.PowerMockito;
String requestId = "a4130fd5-2291-4a83-8992-04e4c9f32731";
Long alarmStart = Long.parseLong("1542445563201");
- String result = childThreadUtils.getNotificationString(pnfName, cellPciPairs, requestId, alarmStart);
+ String result = childThreadUtils.getNotificationString(pnfName, requestId, "payloadString", alarmStart, "action");
PolicyNotification actual = new PolicyNotification();
try {
actual = mapper.readValue(result, PolicyNotification.class);
pciPairList.add(cell2);
pciPairList.add(cell3);
pnfsMap.put("pnf1", pciPairList);
- when(pnfUtils.getPnfs(Mockito.any(Solutions.class))).thenReturn(pnfsMap);
- childThreadUtils.sendToPolicy(async);
+ when(pnfUtils.getPnfs(async.getSolutions())).thenReturn(pnfsMap);
+ List<String> remNeighbors = new ArrayList<>();
+ remNeighbors.add("EXP006");
+ Map<String,List<String>> cellRemNeighborsPair = new HashMap<>();
+ cellRemNeighborsPair.put("EXP003", remNeighbors);
+ List<Map<String,List<String>>> list = new ArrayList<>();
+ list.add(cellRemNeighborsPair);
+ Map<String, List<Map<String,List<String>>>> expected = new HashMap<>();
+ expected.put("pnfName", list);
+ when(pnfUtils.getPnfsForAnrSolutions(async.getSolutions().getAnrSolutions())).thenReturn(expected);
+ assertTrue(childThreadUtils2.sendToPolicy(async));
+
}
private static String readFromFile(String file) {
import static org.junit.Assert.assertEquals;
+import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.BufferedReader;
import org.onap.dcaegen2.services.sonhms.entity.CellInfo;
import org.onap.dcaegen2.services.sonhms.exceptions.ConfigDbNotFoundException;
import org.onap.dcaegen2.services.sonhms.model.CellPciPair;
+import org.onap.dcaegen2.services.sonhms.restclient.AnrSolutions;
import org.onap.dcaegen2.services.sonhms.restclient.SdnrRestClient;
import org.onap.dcaegen2.services.sonhms.restclient.Solutions;
import org.onap.dcaegen2.services.sonhms.utils.BeanUtil;
private static final Logger log = org.slf4j.LoggerFactory.getLogger(TestPnfUtils.class);
private static Solutions solutions = new Solutions();
+ private static List<AnrSolutions> anrSolutions = new ArrayList<>();
private static Optional<CellInfo> cellInfo;
private static Optional<CellInfo> cellInfoNull;
String solutionsString=readFromFile("/solutions.json");
+ String anrSolutionsString = readFromFile("/anrSolutions.json");
ObjectMapper mapper = new ObjectMapper();
try {
solutions=mapper.readValue(solutionsString, Solutions.class);
+ anrSolutions = mapper.readValue(anrSolutionsString, new TypeReference<ArrayList<AnrSolutions>>() {
+ });
} catch (IOException e) {
log.debug("Exception in StateOof Test "+e);
e.printStackTrace();
e.printStackTrace();
}
}
+
+ @Test
+ public void testGetPnfsForAnrSolutions() {
+ Map<String, List<Map<String,List<String>>>> actual = null ;
+ Map<String, List<Map<String,List<String>>>> expected = new HashMap<>();
+ try {
+ PowerMockito.mockStatic(SdnrRestClient.class);
+ PowerMockito.when(SdnrRestClient.getPnfName(Mockito.anyString())).thenReturn("ncServer1");
+ actual = pnfUtils.getPnfsForAnrSolutions(anrSolutions);
+ } catch (ConfigDbNotFoundException e) {
+ e.printStackTrace();
+ }
+ List<String> remNeighbors1 = new ArrayList<>();
+ List<String> remNeighbors2 = new ArrayList<>();
+ remNeighbors1.add("cell2");
+ remNeighbors1.add("cell3");
+ remNeighbors2.add("cell9");
+ Map<String,List<String>> cellRemNeighborsPair1 = new HashMap<>();
+ Map<String,List<String>> cellRemNeighborsPair2 = new HashMap<>();
+ cellRemNeighborsPair1.put("cell1", remNeighbors1);
+ cellRemNeighborsPair2.put("cell8", remNeighbors2);
+ List<Map<String,List<String>>> list = new ArrayList<>();
+ list.add(cellRemNeighborsPair1);
+ list.add(cellRemNeighborsPair2);
+ expected.put("ncServer1", list);
+ assertEquals(expected, actual);
+ }
private static String readFromFile(String file) {
String content = new String();
try {
import org.onap.dcaegen2.services.sonhms.Configuration;
import org.onap.dcaegen2.services.sonhms.exceptions.ConfigDbNotFoundException;
import org.onap.dcaegen2.services.sonhms.model.CellPciPair;
-import org.onap.dcaegen2.services.sonhms.utils.BeanUtil;
import org.onap.dcaegen2.services.sonhms.utils.SonHandlerRestTemplate;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
MockitoAnnotations.initMocks(this);
}
- @Test
- public void getCellListTest() {
-
- String responseBody="[\n" +
- " \"string\"\n" +
- "]";
- PowerMockito.mockStatic(SonHandlerRestTemplate.class);
- PowerMockito.mockStatic(BeanUtil.class);
- PowerMockito.mockStatic(Configuration.class);
- PowerMockito.when(Configuration.getInstance()).thenReturn(configuration);
- PowerMockito.when(SonHandlerRestTemplate.sendGetRequest(Mockito.anyString(),Matchers.<ParameterizedTypeReference<String>>any()))
- .thenReturn(ResponseEntity.ok(responseBody));
- try {
- String result=SdnrRestClient.getCellList("12345");
- assertEquals(ResponseEntity.ok(responseBody).getBody(),result);
- } catch (ConfigDbNotFoundException e) {
- log.debug("ConfigDbNotFoundException {}",e.toString());;
- }
-
- }
@Test
public void getNbrListTest() {
- String responseBody="[\n" +
- " {\n" +
- " \"cellId\": \"string\",\n" +
- " \"pciValue\": 0\n" +
- " }\n" +
- "]";
+ String responseBody="{\n" +
+ " \"cellId\": \"string\",\n" +
+ " \"nbrList\": [\n" +
+ " {\n" +
+ " \"ho\": true,\n" +
+ " \"pciValue\": 0,\n" +
+ " \"targetCellId\": \"string\"\n" +
+ " }\n" +
+ " ]\n" +
+ "}";
PowerMockito.mockStatic(SonHandlerRestTemplate.class);
PowerMockito.mockStatic(Configuration.class);
PowerMockito.when(Configuration.getInstance()).thenReturn(configuration);
List<CellPciPair> result=SdnrRestClient.getNbrList("1");
List<CellPciPair> nbrList = new ArrayList<>();
String response=ResponseEntity.ok(responseBody).getBody();
- JSONArray nbrListObj = new JSONArray(response);
+ JSONObject responseJson = new JSONObject(response);
+ JSONArray nbrListObj = responseJson.getJSONArray("nbrList");
for (int i = 0; i < nbrListObj.length(); i++) {
JSONObject cellObj = nbrListObj.getJSONObject(i);
- CellPciPair cell = new CellPciPair(cellObj.getString("cellId"), cellObj.getInt("pciValue"));
- nbrList.add(cell);
+ if (cellObj.getBoolean("ho")) {
+ CellPciPair cell = new CellPciPair(cellObj.getString("targetCellId"), cellObj.getInt("pciValue"));
+ nbrList.add(cell);
+ }
}
assertEquals(nbrList,result);
} catch (ConfigDbNotFoundException e) {
--- /dev/null
+[
+ {
+ "cellId":"cell1",
+ "removeableNeighbors":[
+ "cell2",
+ "cell3"
+ ]
+ },
+ {
+ "cellId":"cell8",
+ "removeableNeighbors":[
+ "cell9"
+ ]
+ }
+]
-
- {
- "event":{
+{
+ "event":{
"commonEventHeader":{
- "version":"4.0",
- "domain":"measurement",
- "eventName":"Measurement_RansimAgent-Wipro_HandoffMetric",
- "eventId":"measurement000001",
- "sequence":0,
- "priority":"Normal",
- "reportingEntityId":"cc305d54-75b4-431b-adb2-eb6b9e541234",
- "reportingEntityName":"ncserver1",
- "sourceId":"de305d54-75b4-431b-adb2-eb6b9e546456",
- "sourceName":"Chn0001",
- "startEpochMicrosec":1551772223000000,
- "lastEpochMicrosec":1551790542000000,
- "nfNamingCode":"RansimAgent",
- "nfVendorName":"Wipro",
- "vesEventListenerVersion":"7.0.1",
- "timeZoneOffset":"UTC-05:30"
+ "version":"4.0.1",
+ "domain":"measurement",
+ "eventName":"Measurement_RansimAgent-Wipro_HandoffMetric",
+ "eventId":"measurement000001",
+ "sequence":0,
+ "priority":"Normal",
+ "reportingEntityId":"cc305d54-75b4-431b-adb2-eb6b9e541234",
+ "reportingEntityName":"ncserver1",
+ "sourceId":"de305d54-75b4-431b-adb2-eb6b9e546456",
+ "sourceName":"Chn0001",
+ "startEpochMicrosec":1551772223000000,
+ "lastEpochMicrosec":1551790542000000,
+ "nfNamingCode":"RansimAgent",
+ "nfVendorName":"Wipro",
+ "vesEventListenerVersion":"7.0.1",
+ "timeZoneOffset":"UTC-05:30"
},
- "measurement":{
- "measurementInterval":180,
- "additionalMeasurements":[
- {
- "arrayOfNamedHashMap":[
- {
- "networkId":"plmnid1"
- },
- {
- "InterEnbOutAtt_X2HO":"200"
- },
- {
- "InterEnbOutSucc_X2HO":"190"
- }
- ],
- "name":"Chn0014"
- },
- {
- "arrayOfNamedHashMap":[
- {
- "networkId":"plmnid1"
- },
- {
- "InterEnbOutAtt_X2HO":"300"
- },
- {
- "InterEnbOutSucc_X2HO":"210"
- }
- ],
- "name":"Chn0013"
- }
- ]
+ "measurementFields":{
+ "measurementInterval":180,
+ "measurementFieldsVersion":"4.0",
+ "additionalMeasurements":[
+ {
+ "hashMap":{
+ "networkId":"plmnid1",
+ "InterEnbOutAtt_X2HO":"200",
+ "InterEnbOutSucc_X2HO":"190"
+ },
+ "name":"Chn0014"
+ },
+ {
+ "hashMap":{
+ "networkId":"plmnid1",
+ "InterEnbOutAtt_X2HO":"300",
+ "InterEnbOutSucc_X2HO":"210"
+ },
+ "name":"Chn0013"
+ }
+ ]
}
- }
- }
+ }
+}
\ No newline at end of file
-{
- "event": {
- "commonEventHeader": {
- "version": "4.0",
- "domain": "measurement",
- "eventName": "Measurement_RansimAgent-Wipro_HandoffMetric",
- "eventId": "measurement000002",
- "sequence": 0,
- "priority": "Normal",
- "reportingEntityId": "cc305d54-75b4-431b-adb2-eb6b9e544567",
- "reportingEntityName": "ncserver1",
- "sourceId": "de305d54-75b4-431b-adb2-eb6b9e546456",
- "sourceName": "Chn0002",
- "startEpochMicrosec": 1551772223000000,
- "lastEpochMicrosec": 1551790542000000,
- "nfNamingCode": "RansimAgent",
- "nfVendorName": "Wipro",
- "vesEventListenerVersion": "7.0.1",
- "timeZoneOffset": "UTC-05:30"
+
+ {
+ "event":{
+ "commonEventHeader":{
+ "version":"4.0.1",
+ "domain":"measurement",
+ "eventName":"Measurement_RansimAgent-Wipro_HandoffMetric",
+ "eventId":"measurement000001",
+ "sequence":0,
+ "priority":"Normal",
+ "reportingEntityId":"cc305d54-75b4-431b-adb2-eb6b9e541234",
+ "reportingEntityName":"ncserver1",
+ "sourceId":"de305d54-75b4-431b-adb2-eb6b9e546456",
+ "sourceName":"Chn0002",
+ "startEpochMicrosec":1551772223000000,
+ "lastEpochMicrosec":1551790542000000,
+ "nfNamingCode":"RansimAgent",
+ "nfVendorName":"Wipro",
+ "vesEventListenerVersion":"7.0.1",
+ "timeZoneOffset":"UTC-05:30"
},
- "measurement": {
- "measurementInterval": 180,
- "additionalMeasurements": [
- {
- "arrayOfNamedHashMap": [
- {
- "networkId":"plmnid1"
- },
- {
- "InterEnbOutAtt_X2HO":"300"
- },
- {
- "InterEnbOutSucc_X2HO":"100"
- }
- ],
- "name": "Chn0004"
- },
- {
- "arrayOfNamedHashMap": [
- {
- "networkId":"plmnid1"
- },
- {
- "InterEnbOutAtt_X2HO":"250"
- },
- {
- "InterEnbOutSucc_X2HO":"100"
- }
- ],
- "name": "Chn0001"
- }
- ]
+ "measurementFields":{
+ "measurementInterval":180,
+ "measurementFieldsVersion":"4.0",
+ "additionalMeasurements":[
+ {
+ "hashMap":{
+ "networkId":"plmnid1",
+ "InterEnbOutAtt_X2HO":"300",
+ "InterEnbOutSucc_X2HO":"100"
+ },
+ "name":"Chn0004"
+ },
+ {
+ "hashMap":{
+ "networkId":"plmnid1",
+ "InterEnbOutAtt_X2HO":"250",
+ "InterEnbOutSucc_X2HO":"100"
+ },
+ "name":"Chn0001"
+ }
+ ]
}
- }
- }
+ }
+}
\ No newline at end of file
"requestID": "a4130fd5-2291-4a83-8992-04e4c9f32731",
"from": "PCIMS",
"version": "1.0.2",
- "payload": "{\"Configurations\":[{\"data\":{\"FAPService\":{\"alias\":\"Chn0330\",\"X0005b9Lte\":{\"phyCellIdInUse\":6,\"pnfName\":\"ncserver23\"},\"CellConfig\":{\"LTE\":{\"RAN\":{\"Common\":{\"CellIdentity\":\"Chn0330\"}}}}}}},{\"data\":{\"FAPService\":{\"alias\":\"Chn0331\",\"X0005b9Lte\":{\"phyCellIdInUse\":7,\"pnfName\":\"ncserver23\"},\"CellConfig\":{\"LTE\":{\"RAN\":{\"Common\":{\"CellIdentity\":\"Chn0331\"}}}}}}}]}",
+ "payload": "payloadString",
"AAI": {
"generic-vnf.prov-status": "ACTIVE",
"generic-vnf.is-closed-loop-disabled": "false",
"generic-vnf.vnf-id": "ncserver23"
},
- "Action": "ModifyConfig"
+ "Action": "action"
}