- 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
+For R4 - image/version pushed to nexus3
```
nexus3.onap.org:10001/snapshots/onap/org.onap.dcaegen2.services.son-handler 1.0.0
```
login to bootstrap container in dcae deployment
+Copy the blueprints to the bootstrap container.
+
+The blueprint can be found under dpo/blueprints in the son-handler project.
+
To install :
cfy install -b sonhms -d sonhms -i <inputs filepath> <blueprint filepath>
cg: sonhms-cg
cid: sonhms-cid
config_db: http://sdnc.onap:8181
-oof: http://oof-osdf.onap:8080
+oof: http://oof-osdf.onap:8699
pci_optimizer: pci
log_path: /dockerdata-nfs/son-handler
+policy_id: com.Config_PCIMS_CONFIG_POLICY.1.xml
topic00_location: onap
topic00_client_role: son-subscriber
topic00_client_id: sdnr-son-1
topic03_client_role: son-subscriber
topic03_client_id: sdnr-son-1
topic03_url: https://message-router.onap.svc.cluster.local:3905/events/DCAE_CL_OUTPUT
+topic04_location: onap
+topic04_client_role: son-subscriber
+topic04_client_id: sdnr-son-1
+topic04_url: https://message-router.onap.svc.cluster.local:3905/events/DCAE_CL_RSP
- "http://www.getcloudify.org/spec/cloudify/3.4/types.yaml"
- https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/k8splugin/1.4.5/k8splugin_types.yaml
- https://nexus.onap.org/service/local/repositories/raw/content/org.onap.ccsdk.platform.plugins/type_files/pgaas/1.1.0/pgaas_types.yaml
+ - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/dcaepolicyplugin/2.3.0/dcaepolicyplugin_types.yaml
inputs:
replicas:
type: integer
description: threshold for poor neighbors
default: 70
namespace:
- type: String
+ type: string
description: namespace
default: onap
dmaap:
type: string
description: log location in host
default: /dockerdata-nfs/son-handler
+ policy_id:
+ type: string
+ description: policy id for config policy
topic00_location:
topic01_location:
topic02_location:
topic03_location:
+ topic04_location:
topic00_client_role:
topic01_client_role:
topic02_client_role:
topic03_client_role:
+ topic04_client_role:
topic00_client_id:
topic01_client_id:
topic02_client_id:
topic03_client_id:
+ topic04_client_id:
topic00_url:
topic01_url:
topic02_url:
topic03_url:
+ topic04_url:
+
node_templates:
pgaasvm:
client_id: { get_input: topic02_client_id }
topic_url: { get_input: topic02_url }
type: message-router
+ dcae_cl_response_topic:
+ aaf_username: { get_input: aaf_username }
+ aaf_password: { get_input: aaf_password }
+ dmaap_info:
+ location: { get_input: topic04_location }
+ client_role: { get_input: topic04_client_role }
+ client_id: { get_input: topic04_client_id }
+ topic_url: { get_input: topic04_url }
+ type: message-router
streams_publishes:
CL_topic:
aaf_username: { get_input: aaf_username }
relationships:
- type: cloudify.relationships.depends_on
target: pgaasvm
-
+ - type: cloudify.relationships.depends_on
+ target: son_policy
+
+ son_policy:
+ type: dcae.nodes.policy
+ properties:
+ policy_id:
+ get_input: policy_id
+
"location": "onap",
"topic_url": "https://HOSTNAME:3905/events/DCAE_CL_OUTPUT"
}
- }
+ },
+ "CL_RSP_topic": {
+ "type": "message_router",
+ "aaf_username": "",
+ "aaf_password": "",
+ "dmaap_info": {
+ "client_role": "son-subscriber",
+ "client_id": "policy-son-1",
+ "location": "onap",
+ "topic_url": "https://HOSTNAME:3905/events/DCAE_CL_RSP"
+ }
+ }
}
{
- "dataformatversion": "1.0.0",
- "jsonschema": {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "additionalproperties": true,
- "description": "",
- "properties": {
- "requestId": {
- "description": "",
- "type": "string"
- },
- "requestStatus": {
- "description": "",
- "type": "string"
- },
- "solutions": {
- "description": "",
- "items": {
- "additionalproperties": true,
- "description": "",
- "properties": {
- "finishTime": {
- "description": "",
- "type": "string"
- },
- "networkId": {
- "description": "",
- "type": "string"
- },
- "pciSolutions": {
- "description": "",
- "items": {
- "additionalproperties": true,
- "description": "",
- "properties": {
- "cellId": {
- "description": "",
- "type": "string"
- },
- "pci": {
- "description": "",
- "type": "string"
- }
- },
- "required": [
- "cellId",
- "pci"
- ],
- "type": "object"
- },
- "type": "array"
- },
- "startTime": {
- "description": "",
- "type": "string"
- }
- },
- "required": [
- "finishTime",
- "networkId",
- "pciSolutions",
- "startTime"
- ],
- "type": "object"
- },
- "type": "array"
- },
- "statusMessage": {
- "description": "",
- "type": "string"
- },
- "transactionId": {
- "description": "",
- "type": "string"
- }
- },
- "required": [
- "requestId",
- "requestStatus",
- "solutions",
- "statusMessage",
- "transactionId"
- ],
- "type": "object"
- },
- "self": {
- "description": "",
- "name": "SON_OOF_ASYNC_RESP",
- "version": "1.0.0"
- }
+ "dataformatversion": "1.0.0",
+ "jsonschema": {
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "additionalproperties": true,
+ "description": "",
+ "properties": {
+ "requestId": {
+ "description": "",
+ "type": "string"
+ },
+ "requestStatus": {
+ "description": "",
+ "type": "string"
+ },
+ "solutions": {
+ "additionalproperties": true,
+ "description": "",
+ "properties": {
+ "anrSolutions": {
+ "description": "",
+ "items": {
+ "additionalproperties": true,
+ "description": "",
+ "properties": {
+ "cellId": {
+ "description": "",
+ "type": "string"
+ },
+ "removeableNeighbors": {
+ "description": "",
+ "items": {
+ "description": "",
+ "type": "string"
+ },
+ "type": "array"
+ }
+ },
+ "required": [
+ "cellId",
+ "removeableNeighbors"
+ ],
+ "type": "object"
+ },
+ "type": "array"
+ },
+ "networkId": {
+ "description": "",
+ "type": "string"
+ },
+ "pciSolutions": {
+ "description": "",
+ "items": {
+ "additionalproperties": true,
+ "description": "",
+ "properties": {
+ "cellId": {
+ "description": "",
+ "type": "string"
+ },
+ "pci": {
+ "description": "",
+ "type": "string"
+ }
+ },
+ "required": [
+ "cellId",
+ "pci"
+ ],
+ "type": "object"
+ },
+ "type": "array"
+ }
+ },
+ "required": [
+ "anrSolutions",
+ "networkId",
+ "pciSolutions"
+ ],
+ "type": "object"
+ },
+ "statusMessage": {
+ "description": "",
+ "type": "string"
+ },
+ "transactionId": {
+ "description": "",
+ "type": "string"
+ }
+ },
+ "required": [
+ "requestId",
+ "requestStatus",
+ "solutions",
+ "statusMessage",
+ "transactionId"
+ ],
+ "type": "object"
+ },
+ "self": {
+ "description": "",
+ "name": "SON_OOF_ASYNC_RESP",
+ "version": "1.0.0"
+ }
}
--- /dev/null
+{
+ "dataformatversion": "1.0.0",
+ "jsonschema": {
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "additionalproperties": true,
+ "description": "",
+ "properties": {
+ "closedLoopControlName": {
+ "description": "",
+ "type": "string"
+ },
+ "from": {
+ "description": "",
+ "type": "string"
+ },
+ "payload": {
+ "description": "",
+ "type": "string"
+ },
+ "policyName": {
+ "description": "",
+ "type": "string"
+ },
+ "policyVersion": {
+ "description": "",
+ "type": "string"
+ },
+ "requestID": {
+ "description": "",
+ "type": "string"
+ },
+ "target": {
+ "description": "",
+ "type": "string"
+ },
+ "version": {
+ "description": "",
+ "type": "string"
+ }
+ },
+ "required": [
+ "closedLoopControlName",
+ "from",
+ "payload",
+ "policyName",
+ "policyVersion",
+ "requestID",
+ "target",
+ "version"
+ ],
+ "type": "object"
+ },
+ "self": {
+ "description": "",
+ "name": "POLICY_TO_SON_DMAAP",
+ "version": "1.0.0"
+ }
+}
{
- "dataformatversion": "1.0.0",
- "jsonschema": {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "additionalproperties": true,
- "description": "",
- "properties": {
- "cellInfo": {
- "additionalproperties": true,
- "description": "",
- "properties": {
- "cellIdList": {
- "description": "",
- "items": {
- "description": "",
- "type": "string"
- },
- "type": "array"
- },
- "networkId": {
- "description": "",
- "type": "string"
- }
- },
- "required": [
- "cellIdList",
- "networkId"
- ],
- "type": "object"
- },
- "requestInfo": {
- "additionalproperties": true,
- "description": "",
- "properties": {
- "callbackUrl": {
- "description": "",
- "type": "string"
- },
- "numSolutions": {
- "description": "",
- "type": "integer"
- },
- "optimizers": {
- "description": "",
- "items": {
- "description": "",
- "type": "string"
- },
- "type": "array"
- },
- "requestId": {
- "description": "",
- "type": "string"
- },
- "requestType": {
- "description": "",
- "type": "string"
- },
- "sourceId": {
- "description": "",
- "type": "string"
- },
- "timeout": {
- "description": "",
- "type": "integer"
- },
- "transactionId": {
- "description": "",
- "type": "string"
- }
- },
- "required": [
- "callbackUrl",
- "numSolutions",
- "optimizers",
- "requestId",
- "requestType",
- "sourceId",
- "timeout",
- "transactionId"
- ],
- "type": "object"
- }
- },
- "required": [
- "cellInfo",
- "requestInfo"
- ],
- "type": "object"
- },
- "self": {
- "description": "",
- "name": "SON_TO_OOF_REST_REQ",
- "version": "1.0.0"
- }
+ "dataformatversion": "1.0.0",
+ "jsonschema": {
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "additionalproperties": true,
+ "description": "",
+ "properties": {
+ "cellInfo": {
+ "additionalproperties": true,
+ "description": "",
+ "properties": {
+ "anrInputList": {
+ "description": "",
+ "items": {
+ "additionalproperties": true,
+ "description": "",
+ "properties": {
+ "cellId": {
+ "description": "",
+ "type": "string"
+ },
+ "removeableNeighbors": {
+ "description": "",
+ "items": {
+ "description": "",
+ "type": "string"
+ },
+ "type": "array"
+ }
+ },
+ "required": [
+ "cellId",
+ "removeableNeighbors"
+ ],
+ "type": "object"
+ },
+ "type": "array"
+ },
+ "cellIdList": {
+ "description": "",
+ "items": {
+ "description": "",
+ "type": "string"
+ },
+ "type": "array"
+ },
+ "networkId": {
+ "description": "",
+ "type": "integer"
+ },
+ "trigger": {
+ "description": "",
+ "type": "string"
+ }
+ },
+ "required": [
+ "anrInputList",
+ "cellIdList",
+ "networkId",
+ "trigger"
+ ],
+ "type": "object"
+ },
+ "requestInfo": {
+ "additionalproperties": true,
+ "description": "",
+ "properties": {
+ "callbackHeader": {
+ "additionalproperties": true,
+ "description": "",
+ "properties": {
+ "blob": {
+ "description": "",
+ "type": "string"
+ }
+ },
+ "required": [
+ "blob"
+ ],
+ "type": "object"
+ },
+ "callbackUrl": {
+ "description": "",
+ "type": "string"
+ },
+ "numSolutions": {
+ "description": "",
+ "type": "integer"
+ },
+ "optimizers": {
+ "description": "",
+ "items": {
+ "description": "",
+ "type": "string"
+ },
+ "type": "array"
+ },
+ "requestId": {
+ "description": "",
+ "type": "string"
+ },
+ "requestType": {
+ "description": "",
+ "type": "string"
+ },
+ "sourceId": {
+ "description": "",
+ "type": "string"
+ },
+ "timeout": {
+ "description": "",
+ "type": "integer"
+ },
+ "transactionId": {
+ "description": "",
+ "type": "string"
+ }
+ },
+ "required": [
+ "callbackHeader",
+ "callbackUrl",
+ "numSolutions",
+ "optimizers",
+ "requestId",
+ "requestType",
+ "sourceId",
+ "timeout",
+ "transactionId"
+ ],
+ "type": "object"
+ }
+ },
+ "required": [
+ "cellInfo",
+ "requestInfo"
+ ],
+ "type": "object"
+ },
+ "self": {
+ "description": "",
+ "name": "SON_TO_OOF_REST_REQ",
+ "version": "1.0.0"
+ }
}
-
"version": "1.0.0",
"route": "/callbackUrl",
"type": "http"
- }
+ },
+ {
+ "format": "POLICY_TO_SON_DMAAP",
+ "version": "1.0.0",
+ "config_key": "CL_RSP_topic",
+ "type": "message router"
+ }
],
"publishes": [
{
"designer_editable": false
},
{
- "name": "sonhandler.callbackUrl",
- "value": "http://sonhms.onap:8080/callbackUrl",
- "description": "sonhms callback url",
+ "name": "sonhandler.namespace",
+ "value": "onap",
+ "description": "namespace where MS will be deployed",
"sourced_at_deployment": false,
"policy_editable": false,
"designer_editable": false
<version>1.4.0.RELEASE</version>
</dependency>
-
-
- <!-- https://mvnrepository.com/artifact/org.codehaus.jackson/jackson-mapper-asl -->
- <dependency>
- <groupId>org.codehaus.jackson</groupId>
- <artifactId>jackson-mapper-asl</artifactId>
- <version>1.9.13</version>
- </dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
import org.onap.dcaegen2.services.sonhms.dao.DmaapNotificationsRepository;
import org.onap.dcaegen2.services.sonhms.dao.PerformanceNotificationsRepository;
import org.onap.dcaegen2.services.sonhms.model.Notification;
-import org.onap.dcaegen2.services.sonhms.model.PMNotification;
+import org.onap.dcaegen2.services.sonhms.model.PmNotification;
import org.onap.dcaegen2.services.sonhms.utils.BeanUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static Logger log = LoggerFactory.getLogger(DmaapNotificationsComponent.class);
/**
- * Get sdnr notifications
+ * Get sdnr notifications.
*/
public Either<Notification, Integer> getSdnrNotifications() {
DmaapNotificationsRepository dmaapNotificationsRepository = BeanUtil
}
/**
- * Get pm notifications
+ * Get pm notifications.
*/
- public Either<PMNotification,Integer> getPmNotifications(){
- PerformanceNotificationsRepository pmNotificationRepository = BeanUtil.getBean(PerformanceNotificationsRepository.class);
+ public Either<PmNotification,Integer> getPmNotifications() {
+ PerformanceNotificationsRepository pmNotificationRepository =
+ BeanUtil.getBean(PerformanceNotificationsRepository.class);
String pmNotificationString = pmNotificationRepository.getPerformanceNotificationFromQueue();
if (pmNotificationString == null) {
return Either.right(404);
}
ObjectMapper mapper = new ObjectMapper();
- PMNotification pmNotification = new PMNotification();
+ PmNotification pmNotification = new PmNotification();
try {
- pmNotification = mapper.readValue(pmNotificationString, PMNotification.class);
+ pmNotification = mapper.readValue(pmNotificationString, PmNotification.class);
return Either.left(pmNotification);
- } catch(IOException e) {
+ } catch (IOException e) {
log.error("Exception in parsing pm notification ",pmNotificationString,e);
return Either.right(400);
}
* ============LICENSE_END=========================================================
*
*******************************************************************************/
+
package org.onap.dcaegen2.services.sonhms;
public class Event {
- private CommonEventHeader commonEventHeader;
- private FaultFields faultFields;
- public CommonEventHeader getCommonEventHeader() {
- return commonEventHeader;
- }
- public void setCommonEventHeader(CommonEventHeader commonEventHeader) {
- this.commonEventHeader = commonEventHeader;
- }
- public FaultFields getFaultFields() {
- return faultFields;
- }
- public void setFaultFields(FaultFields faultFields) {
- this.faultFields = faultFields;
- }
+ private CommonEventHeader commonEventHeader;
+ private FaultFields faultFields;
+
+ public CommonEventHeader getCommonEventHeader() {
+ return commonEventHeader;
+ }
+
+ public void setCommonEventHeader(CommonEventHeader commonEventHeader) {
+ this.commonEventHeader = commonEventHeader;
+ }
+
+ public FaultFields getFaultFields() {
+ return faultFields;
+ }
+
+ public void setFaultFields(FaultFields faultFields) {
+ this.faultFields = faultFields;
+ }
+
@Override
public String toString() {
return "Event [commonEventHeader=" + commonEventHeader + ", faultFields=" + faultFields + "]";
}
-
-
+
}
faultNotificationtoClusterMapping.setCollisionConfusionMap(collisionConfusionMap);
// matching cells
- if (faultNotificationtoClusterMapping.getCellsinCluster() != null && !faultNotificationtoClusterMapping.getCellsinCluster().isEmpty()) {
+ if (faultNotificationtoClusterMapping.getCellsinCluster() != null
+ && !faultNotificationtoClusterMapping.getCellsinCluster().isEmpty()) {
try {
handleMatchedFmCells(faultNotificationtoClusterMapping, clusterDetails);
} catch (ConfigDbNotFoundException e) {
}
// unmatched new cells
- if (faultNotificationtoClusterMapping.getNewCells() != null && !faultNotificationtoClusterMapping.getNewCells().isEmpty()) {
+ if (faultNotificationtoClusterMapping.getNewCells() != null
+ && !faultNotificationtoClusterMapping.getNewCells().isEmpty()) {
handleUnmatchedFmCells(faultNotificationtoClusterMapping, networkId);
}
/**
* handle unmatched fm cells.
*
- * @param networkId2
- * @param faultNotificationtoClusterMapping
*/
private void handleUnmatchedFmCells(FaultNotificationtoClusterMapping faultNotificationtoClusterMapping,
String networkId) {
.get(cellId);
log.info("Handle Unmatching cells for FM notificatins,collisionConfusionCount{}", collisionConfusionCount);
- Either<Graph, Integer> existingCluster = clusterUtils.getClusterForFMCell(cellId, newClusters);
+ Either<Graph, Integer> existingCluster = clusterUtils.getClusterForFmCell(cellId, newClusters);
if (existingCluster.isRight()) {
try {
Map<CellPciPair, ArrayList<CellPciPair>> clusterMap = clusterUtils.findClusterMap(cellId);
public class FaultFields {
- @Override
+ @Override
public String toString() {
return "FaultFields [faultFieldsVersion=" + faultFieldsVersion + ", alarmCondition=" + alarmCondition
+ ", eventSourceType=" + eventSourceType + ", specificProblem=" + specificProblem + ", eventSeverity="
}
private double faultFieldsVersion;
- private String alarmCondition;
- private String eventSourceType;
- private String specificProblem;
- private String eventSeverity;
- private String vfStatus;
- private AlarmAdditionalInformation alarmAdditionalInformation;
-
+ private String alarmCondition;
+ private String eventSourceType;
+ private String specificProblem;
+ private String eventSeverity;
+ private String vfStatus;
+ private AlarmAdditionalInformation alarmAdditionalInformation;
public AlarmAdditionalInformation getAlarmAdditionalInformation() {
return alarmAdditionalInformation;
}
public double getFaultFieldsVersion() {
- return faultFieldsVersion;
- }
+ return faultFieldsVersion;
+ }
- public void setFaultFieldsVersion(double faultFieldsVersion) {
- this.faultFieldsVersion = faultFieldsVersion;
- }
+ public void setFaultFieldsVersion(double faultFieldsVersion) {
+ this.faultFieldsVersion = faultFieldsVersion;
+ }
- public String getAlarmCondition() {
- return alarmCondition;
- }
+ public String getAlarmCondition() {
+ return alarmCondition;
+ }
- public void setAlarmCondition(String alarmCondition) {
- this.alarmCondition = alarmCondition;
- }
+ public void setAlarmCondition(String alarmCondition) {
+ this.alarmCondition = alarmCondition;
+ }
- public String getEventSourceType() {
- return eventSourceType;
- }
+ public String getEventSourceType() {
+ return eventSourceType;
+ }
- public void setEventSourceType(String eventSourceType) {
- this.eventSourceType = eventSourceType;
- }
+ public void setEventSourceType(String eventSourceType) {
+ this.eventSourceType = eventSourceType;
+ }
- public String getSpecificProblem() {
- return specificProblem;
- }
+ public String getSpecificProblem() {
+ return specificProblem;
+ }
- public void setSpecificProblem(String specificProblem) {
- this.specificProblem = specificProblem;
- }
+ public void setSpecificProblem(String specificProblem) {
+ this.specificProblem = specificProblem;
+ }
- public String getEventSeverity() {
- return eventSeverity;
- }
+ public String getEventSeverity() {
+ return eventSeverity;
+ }
- public void setEventSeverity(String eventSeverity) {
- this.eventSeverity = eventSeverity;
- }
+ public void setEventSeverity(String eventSeverity) {
+ this.eventSeverity = eventSeverity;
+ }
- public String getVfStatus() {
- return vfStatus;
- }
+ public String getVfStatus() {
+ return vfStatus;
+ }
- public void setVfStatus(String vfStatus) {
- this.vfStatus = vfStatus;
- }
+ public void setVfStatus(String vfStatus) {
+ this.vfStatus = vfStatus;
+ }
}
public class FaultNotificationComponent {
- private static Logger log = LoggerFactory.getLogger(FaultNotificationComponent.class);
+ private static Logger log = LoggerFactory.getLogger(FaultNotificationComponent.class);
- /**
- * Get fault notifications.
- */
- public Either<List<FaultEvent>,Integer> getFaultNotifications() {
- FaultNotificationsRepository faultNotificationsRepository = BeanUtil
- .getBean(FaultNotificationsRepository.class);
- String notificationString = faultNotificationsRepository.getFaultNotificationFromQueue();
- log.info("get fault notifications method");
- if (notificationString == null) {
- return Either.right(404);
- }
- ObjectMapper mapper = new ObjectMapper();
- FaultEvent faultEvent = new FaultEvent();
- List<FaultEvent> faultEvents = new ArrayList<>();
- try {
- faultEvent = mapper.readValue(notificationString,FaultEvent.class);
+ /**
+ * Get fault notifications.
+ */
+ public Either<List<FaultEvent>, Integer> getFaultNotifications() {
+ FaultNotificationsRepository faultNotificationsRepository = BeanUtil
+ .getBean(FaultNotificationsRepository.class);
+ String notificationString = faultNotificationsRepository.getFaultNotificationFromQueue();
+ log.info("get fault notifications method");
+ if (notificationString == null) {
+ return Either.right(404);
+ }
+ ObjectMapper mapper = new ObjectMapper();
+ FaultEvent faultEvent = new FaultEvent();
+ List<FaultEvent> faultEvents = new ArrayList<>();
+ try {
+ faultEvent = mapper.readValue(notificationString, FaultEvent.class);
log.info("Parsing FM notification");
-
+
} catch (IOException e) {
log.error("Exception in parsing Notification {}", e);
return Either.right(400);
}
-
- faultEvents.add(faultEvent);
-
- return Either.left(faultEvents);
- }
+ faultEvents.add(faultEvent);
+
+ return Either.left(faultEvents);
+
+ }
}
public class FaultNotificationtoClusterMapping {
public Map<String, String> getCellsinCluster() {
- return cellsinCluster;
- }
+ return cellsinCluster;
+ }
+
+ public void setCellsinCluster(Map<String, String> cellsinCluster) {
+ this.cellsinCluster = cellsinCluster;
+ }
- public void setCellsinCluster(Map<String, String> cellsinCluster) {
- this.cellsinCluster = cellsinCluster;
- }
+ public List<String> getNewCells() {
+ return newCells;
+ }
- public List<String> getNewCells() {
- return newCells;
- }
+ public void setNewCells(List<String> newCells) {
+ this.newCells = newCells;
+ }
- public void setNewCells(List<String> newCells) {
- this.newCells = newCells;
- }
-
- private Map<String, ArrayList<Integer>> collisionConfusionMap;
+ private Map<String, ArrayList<Integer>> collisionConfusionMap;
- //map that returns cellid and its matching cluster id
+ // map that returns cellid and its matching cluster id
- public Map<String, ArrayList<Integer>> getCollisionConfusionMap() {
+ public Map<String, ArrayList<Integer>> getCollisionConfusionMap() {
return collisionConfusionMap;
}
}
private Map<String, String> cellsinCluster;
-
- //cells that dont match
+
+ // cells that dont match
private List<String> newCells;
}
log.error("Exception in parsing HO metrics", hoDetailsString, e);
return Either.right(400);
}
- } else
+ } else {
return Either.right(404);
+ }
}
}
private EventHandler eventHandler;
- private Map<String, FaultEvent> bufferedFMNotificationCells;
+ private Map<String, FaultEvent> bufferedFmNotificationCells;
private List<String> sdnrNotificationCells;
faultNotificationComponent = new FaultNotificationComponent();
sdnrNotificationCells = new ArrayList<>();
fmNotificationToBuffer = new ArrayList<>();
- bufferedFMNotificationCells = new HashMap<>();
+ bufferedFmNotificationCells = new HashMap<>();
eventHandler = new EventHandler(childStatusQueue,
Executors.newFixedThreadPool(Configuration.getInstance().getMaximumClusters()), new HashMap<>(),
new ClusterUtils(), new ThreadUtils());
if (difference > 5000) {
log.info("FM handling difference > 5000");
- for (String sdnrCell: sdnrNotificationCells) {
- bufferedFMNotificationCells.remove(sdnrCell);
+ for (String sdnrCell : sdnrNotificationCells) {
+ bufferedFmNotificationCells.remove(sdnrCell);
}
-
- log.info("FM bufferedFMNotificationCells {}", bufferedFMNotificationCells.values());
- List<FaultEvent> fmNotificationsToHandle = new ArrayList<>(
- bufferedFMNotificationCells.values());
+
+ log.info("FM bufferedFMNotificationCells {}", bufferedFmNotificationCells.values());
+ List<FaultEvent> fmNotificationsToHandle = new ArrayList<>(bufferedFmNotificationCells.values());
Boolean result = eventHandler.handleFaultNotification(fmNotificationsToHandle);
- bufferedFMNotificationCells = new HashMap<>();
+ bufferedFmNotificationCells = new HashMap<>();
isTimer = false;
log.info("FM notification handling {}", result);
}
} else {
for (FaultEvent fmNotification : fmNotifications.left().value()) {
faultCellId = fmNotification.getEvent().getCommonEventHeader().getSourceName();
- bufferedFMNotificationCells.put(faultCellId, fmNotification);
+ bufferedFmNotificationCells.put(faultCellId, fmNotification);
log.info("Buffered FM cell {}", faultCellId);
log.info("fmNotification{}", fmNotification);
}
log.info("bufferedFMNotificationCells before staring timer {}",
- bufferedFMNotificationCells.keySet());
+ bufferedFmNotificationCells.keySet());
- for (String sdnrCell: sdnrNotificationCells) {
- bufferedFMNotificationCells.remove(sdnrCell);
+ for (String sdnrCell : sdnrNotificationCells) {
+ bufferedFmNotificationCells.remove(sdnrCell);
}
-
+
startTimer = new Timestamp(System.currentTimeMillis());
isTimer = true;
- log.info("Buffered FM cell {}", bufferedFMNotificationCells.keySet());
+ log.info("Buffered FM cell {}", bufferedFmNotificationCells.keySet());
}
}
@Component
public class NewPmNotification {
-
+
private Boolean newNotif;
-
+
@PostConstruct
public void init() {
- newNotif=false;
+ newNotif = false;
}
public Boolean getNewNotif() {
- return newNotif;
- }
+ return newNotif;
+ }
public void setNewNotif(Boolean newNotif) {
- this.newNotif = newNotif;
+ this.newNotif = newNotif;
}
- public NewPmNotification(Boolean newNotif) {
+ public NewPmNotification(Boolean newNotif) {
super();
this.newNotif = newNotif;
}
-
+
public NewPmNotification() {
-
+
}
}
import org.onap.dcaegen2.services.sonhms.model.Lte;
import org.onap.dcaegen2.services.sonhms.model.LteCell;
import org.onap.dcaegen2.services.sonhms.model.NeighborListInUse;
-import org.onap.dcaegen2.services.sonhms.model.PMNotification;
import org.onap.dcaegen2.services.sonhms.model.Payload;
+import org.onap.dcaegen2.services.sonhms.model.PmNotification;
import org.onap.dcaegen2.services.sonhms.model.Ran;
import org.onap.dcaegen2.services.sonhms.utils.BeanUtil;
+import org.onap.dcaegen2.services.sonhms.utils.DmaapUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class PmNotificationHandler {
- private static Logger log = LoggerFactory.getLogger(DmaapNotificationsComponent.class);
+ private static Logger log = LoggerFactory.getLogger(PmNotificationHandler.class);
PolicyDmaapClient policyDmaapClient;
public PmNotificationHandler() {
/**
* handle PM notifications.
*/
- public Boolean handlePmNotifications(PMNotification pmNotification, int badThreshold) {
+ public Boolean handlePmNotifications(PmNotification pmNotification, int badThreshold) {
HandOverMetricsRepository handOverMetricsRepository = BeanUtil.getBean(HandOverMetricsRepository.class);
Boolean result;
try {
String srcCellId = pmNotification.getEvent().getCommonEventHeader().getSourceName();
for (AdditionalMeasurements additionalMeasurements : pmNotification.getEvent().getMeasurementFields()
.getAdditionalMeasurements()) {
- int attemptsCount = Integer
- .parseInt(additionalMeasurements.getHashMap().get("InterEnbOutAtt_X2HO"));
- int successCount = Integer
- .parseInt(additionalMeasurements.getHashMap().get("InterEnbOutSucc_X2HO"));
+ int attemptsCount = Integer.parseInt(additionalMeasurements.getHashMap().get("InterEnbOutAtt_X2HO"));
+ int successCount = Integer.parseInt(additionalMeasurements.getHashMap().get("InterEnbOutSucc_X2HO"));
float successRate = ((float) successCount / attemptsCount) * 100;
if (successRate >= badThreshold) {
HoDetails hoDetails = new HoDetails();
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);
}
}
- private Boolean sendAnrUpdateToPolicy(PMNotification pmNotification, List<LteCell> lteCellList) {
+ private Boolean sendAnrUpdateToPolicy(PmNotification pmNotification, List<LteCell> lteCellList) {
ObjectMapper mapper = new ObjectMapper();
try {
mapper.setSerializationInclusion(Include.NON_NULL);
ArrayList<Configurations> configurations = new ArrayList<>();
String cellId = pmNotification.getEvent().getCommonEventHeader().getSourceName();
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()))))))));
+ new Data(new FapService(cellId, null,
+ new CellConfig(new Lte(new Ran(new Common(cellId),
+ new NeighborListInUse(null, lteCellList, String.valueOf(lteCellList.size()))))))),
+ null);
configurations.add(configuration);
Payload payload = new Payload(configurations);
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");
+ new PolicyDmaapClient(new DmaapUtils(), Configuration.getInstance()));
+ String requestId = UUID.randomUUID().toString();
+ String notification = childUtils.getNotificationString(
+ pmNotification.getEvent().getCommonEventHeader().getReportingEntityName(), requestId,
+ anrUpdateString, System.currentTimeMillis(), "ModifyConfigANR");
log.info("Policy Notification: {}", notification);
Boolean result = policyDmaapClient.sendNotificationToPolicy(notification);
log.info("send notification to policy result {} ", result);
-
+ // getting policy response
+ policyDmaapClient.handlePolicyResponse(requestId);
+ log.info("handled policy response");
+
} catch (Exception e) {
log.error("Exception in sending Anr update to policy ", e);
return false;
import fj.data.Either;
import org.onap.dcaegen2.services.sonhms.dmaap.PolicyDmaapClient;
-import org.onap.dcaegen2.services.sonhms.model.PMNotification;
+import org.onap.dcaegen2.services.sonhms.model.PmNotification;
+import org.onap.dcaegen2.services.sonhms.utils.DmaapUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
super();
this.newPmNotification = newPmNotification;
dmaapNotificationsComponent = new DmaapNotificationsComponent();
- pmNotificationHandler = new PmNotificationHandler(new PolicyDmaapClient());
+ pmNotificationHandler = new PmNotificationHandler(new PolicyDmaapClient(new DmaapUtils(),
+ Configuration.getInstance()));
}
@Override
Thread.sleep(1000);
if (newPmNotification.getNewNotif()) {
log.info("New PM notification from Dmaap");
- Either<PMNotification, Integer> pmNotification = dmaapNotificationsComponent.getPmNotifications();
+ Either<PmNotification, Integer> pmNotification = dmaapNotificationsComponent.getPmNotifications();
if (pmNotification.isRight()) {
if (pmNotification.right().value() == 400) {
log.error("error parsing pm notifications");
import org.onap.dcaegen2.services.sonhms.restclient.AsyncResponseBody;
import org.onap.dcaegen2.services.sonhms.utils.BeanUtil;
import org.onap.dcaegen2.services.sonhms.utils.ClusterUtils;
+import org.onap.dcaegen2.services.sonhms.utils.DmaapUtils;
import org.slf4j.Logger;
import org.slf4j.MDC;
ClusterUtils clusterUtils = new ClusterUtils();
Detection detect = new Detection();
ChildThreadUtils childUtils = new ChildThreadUtils(ConfigPolicy.getInstance(), new PnfUtils(),
- new PolicyDmaapClient());
+ new PolicyDmaapClient(new DmaapUtils(), Configuration.getInstance()));
try {
String networkId = cluster.getNetworkId();
Boolean trigger = childUtils.triggerOrWait(collisionConfusionResult);
ConfigPolicy configPolicy = ConfigPolicy.getInstance();
- int timer = 60;
+ double timer = 60;
try {
- timer = (int) configPolicy.getConfig().get("PCI_NEIGHBOR_CHANGE_CLUSTER_TIMEOUT_IN_SECS");
+ timer = (double) configPolicy.getConfig().get("PCI_NEIGHBOR_CHANGE_CLUSTER_TIMEOUT_IN_SECS");
} catch (NullPointerException e) {
log.info("Policy config not available. Using default timeout - 60 seconds");
}
* get policy notification string from oof result.
*
*/
- public String getNotificationString(String pnfName, String requestId, String payloadString,
- Long alarmStartTime, String action) {
-
+ 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.setClosedLoopControlName(closedLoopControlName);
policyNotification.setPayload(payloadString);
ObjectMapper mapper = new ObjectMapper();
+ mapper.setSerializationInclusion(Include.NON_NULL);
String notification = "";
try {
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))))));
+ new X0005b9Lte(pci, pnfName), new CellConfig(new Lte(new Ran(new Common(cellId), null))))),
+ null);
configurations.add(configuration);
}
log.debug("JSON processing exception: {}", e);
}
- String notification = getNotificationString(pnfName, UUID.randomUUID().toString(), payloadString,
+ String requestId = UUID.randomUUID().toString();
+
+ String notification = getNotificationString(pnfName, requestId, payloadString,
System.currentTimeMillis(), "ModifyConfig");
log.info("Policy Notification: {}", notification);
boolean status = policyDmaapClient.sendNotificationToPolicy(notification);
} else {
log.debug("Sending notification to policy failed");
}
+ policyDmaapClient.handlePolicyResponse(requestId);
+ log.info("handled policy response in ModifyConfig");
}
}
if (!solutions.getAnrSolutions().isEmpty()) {
- Map<String, List<Map<String,List<String>>>> anrPnfs;
+ Map<String, List<Map<String, List<String>>>> anrPnfs;
List<Configurations> configurations = new ArrayList<>();
anrPnfs = pnfUtils.getPnfsForAnrSolutions(solutions.getAnrSolutions());
- for(Map.Entry<String, List<Map<String,List<String>>>> entry : anrPnfs.entrySet()) {
+ 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);
- }
+ 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()))))))),
+ null);
+ configurations.add(configuration);
+ }
}
Payload payload = new Payload(configurations);
ObjectMapper mapper = new ObjectMapper();
} catch (JsonProcessingException e) {
log.error("Exception in writing anrupdate string", e);
}
- String notification = getNotificationString(pnfName, UUID.randomUUID().toString(), payloadString,
+ 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");
+
}
-
+
}
return true;
}
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);
*/
public Map<String, List<CellPciPair>> getPnfs(Solutions solutions) throws ConfigDbNotFoundException {
- Map<String, List<CellPciPair>> pnfs = new HashMap<>();
+ Map<String, List<CellPciPair>> pnfs = new HashMap<>();
List<PciSolutions> pciSolutions = solutions.getPciSolutions();
for (PciSolutions pciSolution : pciSolutions) {
- String cellId = pciSolution.getCellId();
- int pci = pciSolution.getPci();
+ String cellId = pciSolution.getCellId();
+ int pci = pciSolution.getPci();
- String pnfName = "";
- CellInfoRepository cellInfoRepository = BeanUtil.getBean(CellInfoRepository.class);
- Optional<CellInfo> cellInfo = cellInfoRepository.findById(cellId);
- if (cellInfo.isPresent()) {
- pnfName = cellInfo.get().getPnfName();
- } else {
- pnfName = SdnrRestClient.getPnfName(cellId);
- cellInfoRepository.save(new CellInfo(cellId, pnfName));
- }
- if (pnfs.containsKey(pnfName)) {
- pnfs.get(pnfName).add(new CellPciPair(cellId, pci));
- } else {
- List<CellPciPair> cellPciPairs = new ArrayList<>();
- cellPciPairs.add(new CellPciPair(cellId, pci));
- pnfs.put(pnfName, cellPciPairs);
- }
+ String pnfName = "";
+ CellInfoRepository cellInfoRepository = BeanUtil.getBean(CellInfoRepository.class);
+ Optional<CellInfo> cellInfo = cellInfoRepository.findById(cellId);
+ if (cellInfo.isPresent()) {
+ pnfName = cellInfo.get().getPnfName();
+ } else {
+ pnfName = SdnrRestClient.getPnfName(cellId);
+ cellInfoRepository.save(new CellInfo(cellId, pnfName));
+ }
+ if (pnfs.containsKey(pnfName)) {
+ pnfs.get(pnfName).add(new CellPciPair(cellId, pci));
+ } else {
+ List<CellPciPair> cellPciPairs = new ArrayList<>();
+ cellPciPairs.add(new CellPciPair(cellId, pci));
+ pnfs.put(pnfName, cellPciPairs);
+ }
}
return pnfs;
}
-
+
/**
- * get pnfs for ANR solutions
+ * 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<>();
-
+ 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) {
+ for (AnrSolutions anrSolution : anrSolutions) {
String cellId = anrSolution.getCellId();
String pnfName = SdnrRestClient.getPnfName(cellId);
removeableNeighbors = anrSolution.getRemoveableNeighbors();
- Map<String,List<String>> cellRemNeighborsPair = new HashMap<>();
+ Map<String, List<String>> cellRemNeighborsPair = new HashMap<>();
cellRemNeighborsPair.put(cellId, removeableNeighbors);
- if(anrPnfs.containsKey(pnfName)) {
+ if (anrPnfs.containsKey(pnfName)) {
anrPnfs.get(pnfName).add(cellRemNeighborsPair);
- }else {
- List<Map<String,List<String>>> anrCells = new ArrayList<>();
+ } else {
+ List<Map<String, List<String>>> anrCells = new ArrayList<>();
anrCells.add(cellRemNeighborsPair);
anrPnfs.put(pnfName, anrCells);
}
}
- log.info("anr Pnfs {}",anrPnfs.toString());
+ log.info("anr Pnfs {}", anrPnfs);
return anrPnfs;
-
+
}
}
public class StateOof {
private static final Logger log = org.slf4j.LoggerFactory.getLogger(StateOof.class);
private BlockingQueue<List<String>> childStatusUpdate;
+
public StateOof() {
}
/**
* Triggers OOF for pci.
- * @throws OofNotFoundException when trigger oof fails
+ *
+ * @throws OofNotFoundException
+ * when trigger oof fails
*/
- public UUID triggerOof(List<String> cellidList,
- String networkId, List<AnrInput> anrInputList) throws OofNotFoundException, InterruptedException {
-
+ public UUID triggerOof(List<String> cellidList, String networkId, List<AnrInput> anrInputList)
+ throws OofNotFoundException, InterruptedException {
+
log.info("Triggering oof");
-
+
log.debug("the cells triggering the oof are {}", cellidList);
UUID transactionId = UUID.randomUUID();
Thread.currentThread().interrupt();
}
-
+
return transactionId;
}
-
}
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
public class ConfigFetchFromCbs {
private static Logger log = LoggerFactory.getLogger(ConfigFetchFromCbs.class);
RequestDiagnosticContext diagnosticContext = RequestDiagnosticContext.create();
// Read necessary properties from the environment
final EnvProperties env = EnvProperties.fromEnvironment();
- log.debug("environments {}",env);
+ log.debug("environments {}", env);
ConfigPolicy configPolicy = ConfigPolicy.getInstance();
-
+
// Create the client and use it to get the configuration
final CbsRequest request = CbsRequests.getAll(diagnosticContext);
- CbsClientFactory.createCbsClient(env).flatMap(cbsClient -> cbsClient.get(request))
- .subscribe(jsonObject -> {
- log.debug("configuration from CBS {}", jsonObject);
- JsonObject config = jsonObject.getAsJsonObject("config");
-
- updateConfigurationFromJsonObject(config);
-
- Type mapType = new TypeToken<Map<String, Object>>() {}.getType();
- JsonObject policyJson = jsonObject.getAsJsonObject("policy");
- Map<String,Object> policy = new Gson().fromJson(policyJson, mapType);
- configPolicy.setConfig(policy);
- }, throwable -> log.warn("Ooops", throwable)) ;
+ CbsClientFactory.createCbsClient(env).flatMap(cbsClient -> cbsClient.get(request)).subscribe(jsonObject -> {
+ log.info("configuration and policy from CBS {}", jsonObject);
+ JsonObject config = jsonObject.getAsJsonObject("config");
+
+ updateConfigurationFromJsonObject(config);
+
+ Type mapType = new TypeToken<Map<String, Object>>() {
+ }.getType();
+ JsonObject policyJson = jsonObject.getAsJsonObject("policies").getAsJsonArray("items").get(0)
+ .getAsJsonObject().getAsJsonObject("config");
+ Map<String, Object> policy = new Gson().fromJson(policyJson, mapType);
+ configPolicy.setConfig(policy);
+ log.info("Config policy {}", configPolicy);
+ }, throwable -> log.warn("Ooops", throwable));
}
private void updateConfigurationFromJsonObject(JsonObject jsonObject) {
-
+
log.info("Updating configuration from CBS");
Configuration configuration = Configuration.getInstance();
- log.info("configuration from CBS {}", jsonObject);
-
- Type mapType = new TypeToken<Map<String, Object>>() {}.getType();
-
+
+ Type mapType = new TypeToken<Map<String, Object>>() {
+ }.getType();
+
JsonObject subscribes = jsonObject.getAsJsonObject("streams_subscribes");
Map<String, Object> streamsSubscribes = new Gson().fromJson(subscribes, mapType);
-
+
JsonObject publishes = jsonObject.getAsJsonObject("streams_publishes");
Map<String, Object> streamsPublishes = new Gson().fromJson(publishes, mapType);
-
+
int pgPort = jsonObject.get("postgres.port").getAsInt();
int pollingInterval = jsonObject.get("sonhandler.pollingInterval").getAsInt();
String pgPassword = jsonObject.get("postgres.password").getAsString();
String pgHost = jsonObject.get("postgres.host").getAsString();
JsonArray servers = jsonObject.getAsJsonArray("sonhandler.dmaap.server");
- Type listType = new TypeToken<List<String>>() {}.getType();
+ Type listType = new TypeToken<List<String>>() {
+ }.getType();
List<String> dmaapServers = new Gson().fromJson(servers, listType);
-
+
String cg = jsonObject.get("sonhandler.cg").getAsString();
int bufferTime = jsonObject.get("sonhandler.bufferTime").getAsInt();
String cid = jsonObject.get("sonhandler.cid").getAsString();
String configDbService = jsonObject.get("sonhandler.configDb.service").getAsString();
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);
-
+ List<String> optimizers = new Gson().fromJson(optimizersJson, listType);
+
String oofService = jsonObject.get("sonhandler.oof.service").getAsString();
int pollingTimeout = jsonObject.get("sonhandler.pollingTimeout").getAsInt();
package org.onap.dcaegen2.services.sonhms.dao;
import org.onap.dcaegen2.services.sonhms.entity.HandOverMetrics;
+import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.Transactional;
@Repository
+@Transactional
public interface HandOverMetricsRepository extends CrudRepository<HandOverMetrics, String> {
- @Query(nativeQuery=true,
- value="SELECT ho_details FROM handover_metrics WHERE src_cell_id=?1")
+ @Query(nativeQuery = true, value = "SELECT ho_details FROM handover_metrics WHERE src_cell_id=?1")
public String getHandOverMetrics(String srcCellId);
- @Query(nativeQuery=true,
- value="UPDATE handover_metrics SET ho_details=?1 where src_cell_id=?2")
+ @Modifying
+ @Query(nativeQuery = true, value = "UPDATE handover_metrics SET ho_details=?1 where src_cell_id=?2")
public void updateHoMetrics(String hoDetails, String srcCellId);
}
@Repository
public interface PerformanceNotificationsRepository extends CrudRepository<PerformanceNotifications, String> {
-
- @Query(nativeQuery = true,
- value = "DELETE FROM performance_notifications "
- + "WHERE notification = ( SELECT notification FROM performance_notifications ORDER BY "
- + "created_at FOR UPDATE SKIP LOCKED LIMIT 1 ) RETURNING notification;")
+
+ @Query(nativeQuery = true, value = "DELETE FROM performance_notifications "
+ + "WHERE notification = ( SELECT notification FROM performance_notifications ORDER BY "
+ + "created_at FOR UPDATE SKIP LOCKED LIMIT 1 ) RETURNING notification;")
public String getPerformanceNotificationFromQueue();
// create notification consumers for FM
NotificationConsumer fmNotificationConsumer = new NotificationConsumer(fmNotifCambriaConsumer,
- new FMNotificationCallback());
+ new FmNotificationCallback());
// start fm notification consumer threads
executorPool = Executors.newScheduledThreadPool(10);
executorPool.scheduleAtFixedRate(fmNotificationConsumer, 0, configuration.getPollingInterval(),
// create notification consumers for PM
NotificationConsumer pmNotificationConsumer = new NotificationConsumer(pmNotifCambriaConsumer,
- new PMNotificationCallback());
+ new PmNotificationCallback());
// start pm notification consumer threads
executorPool = Executors.newScheduledThreadPool(10);
executorPool.scheduleAtFixedRate(pmNotificationConsumer, 0, configuration.getPollingInterval(),
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class FMNotificationCallback extends NotificationCallback{
-
- private static Logger log = LoggerFactory.getLogger(FMNotificationCallback.class);
-
- @Override
- public void activateCallBack(String msg){
- handleNotification(msg);
- }
-
- private void handleNotification(String msg) {
-
- FaultNotificationsRepository faultNotificationsRepository=BeanUtil
- .getBean(FaultNotificationsRepository.class);
-
- NewFmNotification newNotification=BeanUtil.getBean(NewFmNotification.class);
- FaultNotifications faultNotification = new FaultNotifications();
- faultNotification.setNotification(msg);
- if (log.isDebugEnabled()) {
- log.debug(faultNotification.toString());
- }
- faultNotificationsRepository.save(faultNotification);
- newNotification.setNewNotif(true);
- }
+public class FmNotificationCallback extends NotificationCallback {
+
+ private static Logger log = LoggerFactory.getLogger(FmNotificationCallback.class);
+
+ @Override
+ public void activateCallBack(String msg) {
+ handleNotification(msg);
+ }
+
+ private void handleNotification(String msg) {
+
+ FaultNotificationsRepository faultNotificationsRepository = BeanUtil
+ .getBean(FaultNotificationsRepository.class);
+
+
+ FaultNotifications faultNotification = new FaultNotifications();
+ faultNotification.setNotification(msg);
+ if (log.isDebugEnabled()) {
+ log.debug(faultNotification.toString());
+ }
+ NewFmNotification newNotification = BeanUtil.getBean(NewFmNotification.class);
+ faultNotificationsRepository.save(faultNotification);
+ newNotification.setNewNotif(true);
+ }
}
public abstract class NotificationCallback {
- public abstract void activateCallBack(String msg);
-
+ public abstract void activateCallBack(String msg);
+
}
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class PMNotificationCallback extends NotificationCallback {
-
- private static Logger log = LoggerFactory.getLogger(PMNotificationCallback.class);
-
- @Override
- public void activateCallBack(String msg){
- handleNotification(msg);
- }
-
- private void handleNotification(String msg) {
-
- PerformanceNotificationsRepository performanceNotificationsRepository=BeanUtil.getBean(PerformanceNotificationsRepository.class);
- NewPmNotification newNotification=BeanUtil.getBean(NewPmNotification.class);
- PerformanceNotifications performanceNotification = new PerformanceNotifications();
- performanceNotification.setNotification(msg);
- log.info("Performance notification {}", performanceNotification);
- performanceNotificationsRepository.save(performanceNotification);
- newNotification.setNewNotif(true);
- }
+public class PmNotificationCallback extends NotificationCallback {
+ private static Logger log = LoggerFactory.getLogger(PmNotificationCallback.class);
+
+ @Override
+ public void activateCallBack(String msg) {
+ handleNotification(msg);
+ }
+
+ private void handleNotification(String msg) {
+
+ PerformanceNotificationsRepository performanceNotificationsRepository = BeanUtil
+ .getBean(PerformanceNotificationsRepository.class);
+ PerformanceNotifications performanceNotification = new PerformanceNotifications();
+ performanceNotification.setNotification(msg);
+ log.info("Performance notification {}", performanceNotification);
+ NewPmNotification newNotification = BeanUtil.getBean(NewPmNotification.class);
+ performanceNotificationsRepository.save(performanceNotification);
+ newNotification.setNewNotif(true);
+ }
}
package org.onap.dcaegen2.services.sonhms.dmaap;
import com.att.nsa.cambria.client.CambriaBatchingPublisher;
+import com.att.nsa.cambria.client.CambriaConsumer;
+import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
+import java.sql.Timestamp;
import java.util.Map;
import org.onap.dcaegen2.services.sonhms.Configuration;
+import org.onap.dcaegen2.services.sonhms.model.Payload;
+import org.onap.dcaegen2.services.sonhms.model.PolicyNotification;
import org.onap.dcaegen2.services.sonhms.utils.DmaapUtils;
+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.
*/
@SuppressWarnings("unchecked")
public boolean sendNotificationToPolicy(String msg) {
- dmaapUtils = new DmaapUtils();
- Map<String, Object> streamsPublishes = Configuration.getInstance().getStreamsPublishes();
+ Map<String, Object> streamsPublishes = configuration.getStreamsPublishes();
String policyTopicUrl = ((Map<String, String>) ((Map<String, Object>) streamsPublishes.get("CL_topic"))
.get("dmaap_info")).get("topic_url");
String[] policyTopicSplit = policyTopicUrl.split("\\/");
String policyTopic = policyTopicSplit[policyTopicSplit.length - 1];
- Configuration configuration = Configuration.getInstance();
CambriaBatchingPublisher cambriaBatchingPublisher;
try {
}
return true;
}
+
+ /**
+ * Handles policy response.
+ */
+ @SuppressWarnings("unchecked")
+ public Boolean handlePolicyResponse(String requestId) {
+
+ Map<String, Object> streamSubscribes = configuration.getStreamsSubscribes();
+ String policyResponseTopicUrl = ((Map<String, String>) ((Map<String, Object>) streamSubscribes
+ .get("dcae_cl_response_topic")).get("dmaap_info")).get("topic_url");
+ String[] policyResponseTopicUrlSplit = policyResponseTopicUrl.split("\\/");
+ String policyResponseTopic = policyResponseTopicUrlSplit[policyResponseTopicUrlSplit.length - 1];
+ log.debug("policyResponse Topic : {}", policyResponseTopic);
+ CambriaConsumer policyResponseCambriaConsumer = null;
+ policyResponseCambriaConsumer = dmaapUtils.buildConsumer(configuration, policyResponseTopic);
+ Timestamp startTimer = new Timestamp(System.currentTimeMillis());
+
+ Timestamp currentTime = new Timestamp(System.currentTimeMillis());
+ Long difference = currentTime.getTime() - startTimer.getTime();
+
+ while (difference < 10000) {
+ Iterable<String> policyResponseMessages;
+ try {
+ policyResponseMessages = policyResponseCambriaConsumer.fetch();
+ for (String msg : policyResponseMessages) {
+ ObjectMapper mapper = new ObjectMapper();
+ PolicyNotification policyResponse = mapper.readValue(msg, PolicyNotification.class);
+ if (requestId.equals(policyResponse.getRequestId())) {
+ String payload = policyResponse.getPayload();
+ Payload payloadObject = mapper.readValue(payload, Payload.class);
+ int status = payloadObject.getConfiguration().get(0).getStatus().getCode();
+ String statusToString = Integer.toString(status);
+ log.info("response from policy, status code {}", statusToString);
+
+ }
+ return true;
+ }
+ } catch (IOException e) {
+ log.info("caught io exception while fetching policy response");
+ }
+ currentTime = new Timestamp(System.currentTimeMillis());
+ difference = currentTime.getTime() - startTimer.getTime();
+ }
+ log.info("no response from policy, timer expired");
+ return true;
+
+ }
}
@Entity
@Table(name = "PERFORMANCE_NOTIFICATIONS")
public class PerformanceNotifications {
-
- @Id
+
+ @Id
@Column(name = "notification", columnDefinition = "text")
private String notification;
this.createdAt = createdAt;
}
-
}
import java.util.Map;
public class AdditionalMeasurements {
-
+
String name;
- Map<String,String> hashMap ;
-
+ Map<String, String> hashMap;
+
public AdditionalMeasurements() {
-
+
}
+
public String getName() {
return name;
}
+
public void setName(String name) {
this.name = name;
}
+
public Map<String, String> getHashMap() {
return hashMap;
}
+
public void setHashMap(Map<String, String> hashMap) {
this.hashMap = hashMap;
}
+
@Override
public String toString() {
return "AdditionalMeasurements [name=" + name + ", hashMap=" + hashMap + "]";
}
-
-
-
+
}
String cellId;
List<String> removeableNeighbors;
-
+
public AnrInput() {
-
+
}
+
/**
* Parameterized Constructor.
*/
this.cellId = cellId;
this.removeableNeighbors = removeableNeighbors;
}
+
public String getCellId() {
return cellId;
}
+
public void setCellId(String cellId) {
this.cellId = cellId;
}
+
public List<String> getRemoveableNeighbors() {
return removeableNeighbors;
}
+
public void setRemoveableNeighbors(List<String> removeableNeighbors) {
this.removeableNeighbors = removeableNeighbors;
}
-
-
+
}
@JsonProperty("data")
private Data data;
+ @JsonProperty("Status")
+ private Status status;
+
/**
* constructor.
*
public Configurations() {
}
+
/**
* Parameterized constructor.
*
*/
- public Configurations(Data data) {
+ public Configurations(Data data, Status status) {
super();
this.data = data;
+ this.status = status;
}
+
public Data getData() {
return data;
}
+
public void setData(Data data) {
this.data = data;
}
-
-
+ public Status getStatus() {
+ return status;
+ }
+
+ public void setStatus(Status status) {
+ this.status = status;
+ }
}
package org.onap.dcaegen2.services.sonhms.model;
public class HoDetails {
-
+
private String dstCellId;
private int attemptsCount;
private int successCount;
private float successRate;
-
+
/**
- * default constructor
+ * default constructor.
*/
public HoDetails() {
-
+
}
-
+
public String getDstCellId() {
return dstCellId;
}
+
public void setDstCellId(String dstCellId) {
this.dstCellId = dstCellId;
}
+
public int getAttemptsCount() {
return attemptsCount;
}
+
public void setAttemptsCount(int attemptsCount) {
this.attemptsCount = attemptsCount;
}
+
public int getSuccessCount() {
return successCount;
}
+
public void setSuccessCount(int successCount) {
this.successCount = successCount;
}
+
public float getSuccessRate() {
return successRate;
}
+
public void setSuccessRate(float successRate) {
this.successRate = successRate;
}
-
}
import com.fasterxml.jackson.annotation.JsonProperty;
public class LteNeighborListInUseLteCell {
+
@JsonProperty("pnfName")
private String pnfName;
}
+ /**
+ * constructor.
+ */
public LteNeighborListInUseLteCell(String pnfName, String enable, String alias, String mustInclude, String plmnId,
String cid, int phyCellId, String blacklisted) {
super();
String measurementInterval;
String measurementFieldsVersion;
-
+
List<AdditionalMeasurements> additionalMeasurements;
-
+
/**
- * default constructor
+ * default constructor.
*/
public MeasurementFields() {
-
+
}
+
public String getMeasurementInterval() {
return measurementInterval;
}
public void setAdditionalMeasurements(List<AdditionalMeasurements> additionalMeasurements) {
this.additionalMeasurements = additionalMeasurements;
}
-
+
public String getMeasurementFieldsVersion() {
return measurementFieldsVersion;
}
+
public void setMeasurementFieldsVersion(String measurementFieldsVersion) {
this.measurementFieldsVersion = measurementFieldsVersion;
}
-
}
package org.onap.dcaegen2.services.sonhms.model;
-public class PMNotification {
+public class PmNotification {
Event event;
-
+
/**
- * default constructor
+ * default constructor.
*/
- public PMNotification() {
-
+ public PmNotification() {
+
}
-
+
public Event getEvent() {
return event;
}
+
public void setEvent(Event event) {
this.event = event;
}
-
-
-
+
}
private long closedLoopAlarmStart;
private String closedLoopEventClient;
private String closedLoopEventStatus;
-
+
@JsonProperty("target_type")
private String targetType;
private String from;
private String version;
+
+ private String policyName;
+ private String policyVersion;
@JsonProperty("Action")
private String action;
/**
* Constructor.
- *
*/
- public PolicyNotification(String closedLoopControlName, String requestId, Long alarmStartTime, String pnfName, String action) {
+ public PolicyNotification(String closedLoopControlName, String requestId, Long alarmStartTime, String pnfName,
+ String action) {
this.closedLoopControlName = closedLoopControlName;
this.requestId = requestId;
this.closedLoopEventClient = "microservice.PCI";
}
return (this.hashCode() == obj.hashCode());
}
+
+ public String getPolicyName() {
+ return policyName;
+ }
+
+ public void setPolicyName(String policyName) {
+ this.policyName = policyName;
+ }
+
+ public String getPolicyVersion() {
+ return policyVersion;
+ }
+
+ public void setPolicyVersion(String policyVersion) {
+ this.policyVersion = policyVersion;
+ }
--- /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 com.fasterxml.jackson.annotation.JsonProperty;
+
+
+public class Status {
+ @JsonProperty("Code")
+ private int code;
+
+ @JsonProperty("Value")
+ private String value;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+}
import java.util.List;
public class AnrSolutions {
-
+
String cellId;
List<String> removeableNeighbors = new ArrayList<>();
-
+
public AnrSolutions() {
-
+
}
-
+
+ /**
+ * constructor.
+ */
public AnrSolutions(String cellId, List<String> removeableNeighbors) {
super();
this.cellId = cellId;
public String getCellId() {
return cellId;
}
+
public void setCellId(String cellId) {
this.cellId = cellId;
}
+
public List<String> getRemoveableNeighbors() {
return removeableNeighbors;
}
+
public void setRemoveableNeighbors(List<String> removeableNeighbors) {
this.removeableNeighbors = removeableNeighbors;
}
+
@Override
public String toString() {
return "AnrSolutions [cellId=" + cellId + ", removeableNeighbors=" + removeableNeighbors + "]";
}
-
}
import java.util.Map;
import java.util.UUID;
-import org.onap.dcaegen2.services.sonhms.ConfigPolicy;
import org.onap.dcaegen2.services.sonhms.Configuration;
import org.onap.dcaegen2.services.sonhms.exceptions.OofNotFoundException;
import org.onap.dcaegen2.services.sonhms.model.AnrInput;
Map<String, String> callbackHeader = new HashMap<>();
callbackHeader.put("Content-Type", "application/json");
requestInfo.setCallbackHeader(callbackHeader);
- ConfigPolicy config = ConfigPolicy.getInstance();
int timeout = 60;
- try {
- timeout = (int) config.getConfig().get("PCI_NEIGHBOR_CHANGE_CLUSTER_TIMEOUT_IN_SECS");
- } catch (NullPointerException e) {
- log.debug("No config policy available. Using default timeout 60 sec");
- }
requestInfo.setTimeout(timeout);
CellInfo cellInfo = new CellInfo();
int pci;
public PciSolutions() {
-
+
}
+
public String getCellId() {
return cellId;
}
import java.util.List;
public class Solutions {
-
+
String networkId = null;
List<PciSolutions> pciSolutions = new ArrayList<>();
List<AnrSolutions> anrSolutions = new ArrayList<>();
-
+
public Solutions() {
-
+
}
+
public String getNetworkId() {
return networkId;
}
this.pciSolutions = pciSolutions;
}
+
public List<AnrSolutions> getAnrSolutions() {
return anrSolutions;
}
+ "]";
}
-
-
-
}
/**
* Get clusters for FM Cell.
*/
- public Either<Graph, Integer> getClusterForFMCell(String cellId, List<Graph> newClusters) {
+ public Either<Graph, Integer> getClusterForFmCell(String cellId, List<Graph> newClusters) {
if (newClusters.isEmpty()) {
log.info("getClusterForFMCell 404");
return Either.right(404);
return clusterCells;
}
- // generic create cluster for both fm and sdnr
-
+
+ /**
+ * Create cluster.
+ */
public Graph createCluster(Map<CellPciPair, ArrayList<CellPciPair>> clusterMap) throws ConfigDbNotFoundException {
Graph cluster = new Graph();
import java.util.List;
import java.util.Map;
-import org.hibernate.sql.ConditionFragment;
import org.junit.Test;
import org.onap.dcaegen2.services.sonhms.dao.DmaapNotificationsRepository;
import org.onap.dcaegen2.services.sonhms.dao.PerformanceNotificationsRepository;
import org.onap.dcaegen2.services.sonhms.model.Notification;
-import org.onap.dcaegen2.services.sonhms.model.PMNotification;
+import org.onap.dcaegen2.services.sonhms.model.PmNotification;
import org.onap.dcaegen2.services.sonhms.utils.BeanUtil;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
.thenReturn(performanceNotificationsRepositoryMock);
when(performanceNotificationsRepositoryMock.getPerformanceNotificationFromQueue()).thenReturn(pmNotificationString);
- Either<PMNotification,Integer> result = component.getPmNotifications();
+ Either<PmNotification,Integer> result = component.getPmNotifications();
assertTrue(result.isLeft());
assertNotNull(result.left().value());
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.model.PmNotification;
import org.onap.dcaegen2.services.sonhms.utils.BeanUtil;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
private static String pmNotificationsString ;
private static String pmNotificationsString1 ;
- private static PMNotification pmNotification;
- private static PMNotification pmNotification1;
+ private static PmNotification pmNotification;
+ private static PmNotification pmNotification1;
@BeforeClass
public static void setup() {
pmNotificationsString=readFromFile("/pmNotification.json");
pmNotificationsString1=readFromFile("/pmNotification1.json");
ObjectMapper mapper = new ObjectMapper();
- pmNotification = new PMNotification();
- pmNotification1 = new PMNotification();
+ pmNotification = new PmNotification();
+ pmNotification1 = new PmNotification();
try {
- pmNotification = mapper.readValue(pmNotificationsString, PMNotification.class);
- pmNotification1 = mapper.readValue(pmNotificationsString1, PMNotification.class);
+ pmNotification = mapper.readValue(pmNotificationsString, PmNotification.class);
+ pmNotification1 = mapper.readValue(pmNotificationsString1, PmNotification.class);
} catch(Exception e) {
e.printStackTrace();
}
when(handOverMetricsRepositoryMock.save(new HandOverMetrics())).thenReturn(null);
when(flagMock.getHolder()).thenReturn("NONE");
when(policyDmaapClient.sendNotificationToPolicy(Mockito.anyString())).thenReturn(true);
+ when(policyDmaapClient.handlePolicyResponse(Mockito.anyString())).thenReturn(true);
assertTrue(pmNotificationHandler.handlePmNotifications(pmNotification, 50));
assertFalse(pmNotificationHandler.handlePmNotifications(null, 0));
assertTrue(pmNotificationHandler.handlePmNotifications(pmNotification1, 50));
pciPairList.add(cell2);
pciPairList.add(cell3);
pnfsMap.put("pnf1", pciPairList);
+ when(policyDmaapClient.handlePolicyResponse(Mockito.anyString())).thenReturn(true);
when(pnfUtils.getPnfs(async.getSolutions())).thenReturn(pnfsMap);
List<String> remNeighbors = new ArrayList<>();
remNeighbors.add("EXP006");
--- /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.dmaap;
+
+import static org.junit.Assert.*;
+
+import com.att.nsa.cambria.client.CambriaBatchingPublisher;
+import com.att.nsa.cambria.client.CambriaConsumer;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.dcaegen2.services.sonhms.Configuration;
+import org.onap.dcaegen2.services.sonhms.utils.ClusterUtilsTest;
+import org.onap.dcaegen2.services.sonhms.utils.DmaapUtils;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@RunWith(MockitoJUnitRunner.class)
+@SpringBootTest(classes = PolicyDmaapClient.class)
+public class PolicyDmaapClientTest {
+
+ @Mock
+ Configuration configurationMock;
+
+ @Mock
+ DmaapUtils dmaapUtilsMock;
+
+ @InjectMocks
+ PolicyDmaapClient policyDmaapClient;
+
+ @Mock
+ CambriaConsumer policyResponseCambriaConsumerMock;
+
+ @Mock
+ CambriaBatchingPublisher cambriaBatchingPublisherMock;
+
+ @Mock
+ NotificationProducer notificationProducerMock;
+
+ @Before
+ public void setup() {
+ policyDmaapClient = new PolicyDmaapClient(dmaapUtilsMock, configurationMock);
+ }
+
+ @Test
+ public void handlePolicyResponseTest() {
+
+ Map<String, Object> streamsSubscribes = new HashMap<>();
+ Map<String, String> topics = new HashMap<>();
+ Map<String, Object> dmaapInfo = new HashMap<>();
+ topics.put("topic_url", "https://message-router.onap.svc.cluster.local:3905/events/DCAE_CL_RSP");
+ dmaapInfo.put("dmaap_info", topics);
+ streamsSubscribes.put("dcae_cl_response_topic", dmaapInfo);
+ System.out.println(streamsSubscribes);
+ String policyResponseString = readFromFile("/policy_response.json");
+ List<String> responseMsgs = new ArrayList<>();
+ responseMsgs.add(policyResponseString);
+ Iterable<String> msgs = () -> new Iterator<String>() {
+ private int index = 0;
+
+ @Override
+ public boolean hasNext() {
+ return responseMsgs.size() > index;
+ }
+
+ @Override
+ public String next() {
+ return responseMsgs.get(index++);
+ }
+ };
+ Mockito.when(configurationMock.getStreamsSubscribes()).thenReturn(streamsSubscribes);
+ Mockito.when(dmaapUtilsMock.buildConsumer(configurationMock, "DCAE_CL_RSP")).thenReturn(policyResponseCambriaConsumerMock);
+ try {
+ Mockito.when(policyResponseCambriaConsumerMock.fetch()).thenReturn(msgs);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ assertTrue(policyDmaapClient.handlePolicyResponse("9d2d790e-a5f0-11e8-98d0-529269fb1459"));
+ }
+
+ @Test
+ public void sendNotificationToPolicyTest() {
+ Map<String, Object> streamsPublishes = new HashMap<>();
+ Map<String, String> topics = new HashMap<>();
+ Map<String, Object> dmaapInfo = new HashMap<>();
+ topics.put("topic_url", "https://message-router.onap.svc.cluster.local:3905/events/DCAE_CL_OUTPUT");
+ dmaapInfo.put("dmaap_info", topics);
+ streamsPublishes.put("CL_topic", dmaapInfo);
+ Mockito.when(configurationMock.getStreamsPublishes()).thenReturn(streamsPublishes);
+ Mockito.when(dmaapUtilsMock.buildPublisher(configurationMock, "DCAE_CL_OUTPUT")).thenReturn(cambriaBatchingPublisherMock);
+ try {
+ Mockito.when(cambriaBatchingPublisherMock.send("", "hello")).thenReturn(0);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ assertTrue(policyDmaapClient.sendNotificationToPolicy("hello"));
+
+ }
+
+ private static String readFromFile(String file) {
+ String content = new String();
+ try {
+
+ InputStream is = ClusterUtilsTest.class.getResourceAsStream(file);
+ BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(is));
+ content = bufferedReader.readLine();
+ String temp;
+ while ((temp = bufferedReader.readLine()) != null) {
+ content = content.concat(temp);
+ }
+ content = content.trim();
+ bufferedReader.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ content = null;
+ }
+ return content;
+ }
+}
} catch (IOException e) {
e.printStackTrace();
}
-
- assertNotEquals(notif, notif1);
+
+ Notification notif2 = new Notification("9d2d790e-a5f0-11e8-98d0-529269fb1459", "{}", "SDNR", "1.0.2", "NeighborListModified", payload) ;
+ assertEquals(notif2.getPayload(), notif.getPayload());
+ assertNotEquals(notif, notif1);
assertEquals(notif.getAction(), notif1.getAction());
assertEquals(notif.getAai().toString(), notif1.getAai().toString());
Data data = new Data(fapService);
- Configurations config = new Configurations(data);
+ Configurations config = new Configurations(data, null);
ArrayList<Configurations> al = new ArrayList<>();
al.add(config);
--- /dev/null
+{
+ "closedLoopControlName": "ControlLoop-vPCI-fb41f388-a5f2-11e8-98d0-529269fb1459",
+ "requestID": "9d2d790e-a5f0-11e8-98d0-529269fb1459",
+ "target": "SONHandler",
+ "from": "SDNR",
+ "version": "1.0.2",
+ "policyName": "PCI",
+ "policyVersion": "1.0.2",
+ "payload": " { \"Configurations\":[ { \"Status\": { \"Code\": 200, \"Value\": \"SUCCESS\" }, \"data\":{\"FAPService\":{\"alias\":\"Chn0330\",\"X0005b9Lte\":{\"phyCellIdInUse\":6,\"pnfName\":\"ncserver23\"},\"CellConfig\":{\"LTE\":{\"RAN\":{\"Common\":{\"CellIdentity\":\"Chn0330\"}}}}}} } ] }"
+}