From 80b0c61808d0958ef7d38a772a206f2c17dfd2a5 Mon Sep 17 00:00:00 2001 From: krishnaa96 Date: Fri, 5 Apr 2019 18:13:32 +0530 Subject: [PATCH] Implement Enhancements to the Microservice Change-Id: Ie3b11fe14f1794fdd6880c40bc382eccbef34aa2 Issue-ID: DCAEGEN2-1109 Signed-off-by: krishna moorthy --- dpo/blueprints/k8s-sonhms-inputs.yaml | 2 + dpo/blueprints/k8s-sonhms.yaml | 12 +- dpo/data-formats/cellListFromSdnr-dataformat.json | 30 +- dpo/data-formats/configdb-req-dataformat.json | 19 +- dpo/data-formats/dmaap_son.json | 89 +-- dpo/data-formats/nbrListFromSdnr-dataformat.json | 60 +- dpo/data-formats/oofToSonAsyncResp-dataformat.json | 178 +++--- dpo/data-formats/oofToSonSyncResp-dataformat.json | 72 +-- dpo/data-formats/pciFromSdnr-dataformat.json | 52 +- dpo/data-formats/pnfNameFromSdnr-dataformat.json | 52 +- dpo/data-formats/policyToSonReq-dataformat.json | 42 +- dpo/data-formats/policyToSonResp-dataformat.json | 122 ++-- dpo/data-formats/sonInputFromSdnr-dataformat.json | 418 ++++++------- dpo/data-formats/sonToOofReq-dataformat.json | 188 +++--- dpo/data-formats/sonToPolicyReq-dataformat.json | 42 +- dpo/spec/sonhandler-componentspec.json | 606 +++++++++---------- pom.xml | 650 ++++++++++----------- .../sonhms/AlarmAdditionalInformation.java | 47 ++ .../onap/dcaegen2/services/sonhms/Application.java | 25 +- .../sonhms/BufferNotificationComponent.java | 2 +- .../services/sonhms/CommonEventHeader.java | 182 ++++++ .../dcaegen2/services/sonhms/Configuration.java | 144 ++--- .../sonhms/DmaapNotificationsComponent.java | 31 +- .../org/onap/dcaegen2/services/sonhms/Event.java | 44 ++ .../dcaegen2/services/sonhms/EventHandler.java | 249 ++++++-- .../onap/dcaegen2/services/sonhms/FaultEvent.java | 43 ++ .../onap/dcaegen2/services/sonhms/FaultFields.java | 99 ++++ .../sonhms/FaultNotificationComponent.java | 70 +++ .../sonhms/FaultNotificationtoClusterMapping.java | 61 ++ .../services/sonhms/HoMetricsComponent.java | 63 ++ .../onap/dcaegen2/services/sonhms/MainThread.java | 123 +++- .../services/sonhms/MainThreadComponent.java | 12 +- ...NewNotification.java => NewFmNotification.java} | 19 +- .../services/sonhms/NewPmNotification.java | 55 ++ .../services/sonhms/NewSdnrNotification.java | 55 ++ .../services/sonhms/PMNotificationHandler.java | 171 ++++++ .../onap/dcaegen2/services/sonhms/PMThread.java | 85 +++ .../services/sonhms/child/ChildThread.java | 277 +++++++-- .../services/sonhms/child/ChildThreadUtils.java | 162 ++++- .../services/sonhms/child/ClusterFormation.java | 145 ----- .../dcaegen2/services/sonhms/child/Detection.java | 5 +- .../onap/dcaegen2/services/sonhms/child/Graph.java | 53 +- .../dcaegen2/services/sonhms/child/PnfUtils.java | 13 +- .../dcaegen2/services/sonhms/child/StateOof.java | 125 +--- .../sonhms/controller/ConfigFetchFromCbs.java | 150 +++-- .../sonhms/dao/HandOverMetricsRepository.java | 39 ++ .../dao/PerformanceNotificationsRepository.java | 39 ++ .../services/sonhms/dao/SonRequestsRepository.java | 6 +- .../services/sonhms/dmaap/DmaapClient.java | 167 +++--- .../sonhms/dmaap/FMNotificationCallback.java | 55 ++ .../sonhms/dmaap/NotificationCallback.java | 28 + .../sonhms/dmaap/NotificationConsumer.java | 1 - .../sonhms/dmaap/PMNotificationCallback.java | 52 ++ .../services/sonhms/dmaap/PolicyDmaapClient.java | 56 +- .../sonhms/dmaap/SdnrNotificationCallback.java | 54 ++ .../services/sonhms/entity/HandOverMetrics.java | 82 +++ .../sonhms/entity/PerformanceNotifications.java | 71 +++ .../entity/{PciRequests.java => SonRequests.java} | 11 +- .../sonhms/model/AdditionalMeasurements.java | 53 ++ .../dcaegen2/services/sonhms/model/AnrInput.java | 57 ++ .../services/sonhms/model/CellPciPair.java | 1 + .../dcaegen2/services/sonhms/model/ClusterMap.java | 61 ++ .../services/sonhms/model/Configurations.java | 6 +- .../onap/dcaegen2/services/sonhms/model/Event.java | 51 ++ .../dcaegen2/services/sonhms/model/HoDetails.java | 64 ++ .../dcaegen2/services/sonhms/model/LteCell.java | 87 +++ .../sonhms/model/LteNeighborListInUseLteCell.java | 4 - .../services/sonhms/model/Measurement.java | 54 ++ .../services/sonhms/model/NeighborListInUse.java | 8 +- .../services/sonhms/model/PMNotification.java | 44 ++ .../onap/dcaegen2/services/sonhms/model/Ran.java | 8 +- .../services/sonhms/restclient/AnrSolutions.java | 60 ++ .../sonhms/restclient/AsyncResponseBody.java | 8 +- .../services/sonhms/restclient/CellInfo.java | 21 + .../services/sonhms/restclient/OofRequestBody.java | 2 +- .../services/sonhms/restclient/OofRestClient.java | 12 +- .../{SonSolution.java => PciSolutions.java} | 10 +- .../services/sonhms/restclient/RequestInfo.java | 12 + .../services/sonhms/restclient/SdnrRestClient.java | 14 +- .../restclient/{Solution.java => Solutions.java} | 46 +- .../services/sonhms/utils/ClusterUtils.java | 210 ++++--- .../dcaegen2/services/sonhms/utils/DmaapUtils.java | 199 ++++--- .../sonhms/utils/SonHandlerRestTemplate.java | 28 +- .../services/sonhms/utils/ThreadUtils.java | 17 +- src/main/resources/logback.xml | 70 +-- src/main/resources/schema.sql | 10 +- .../sonhms/BufferNotificationComponentTest.java | 2 +- .../sonhms/ClusterDetailsComponentTest.java | 2 +- .../services/sonhms/CommonEventHeaderTest.java | 69 +++ .../services/sonhms/ConfigurationTest.java | 28 +- .../sonhms/DmaapNotificationsComponentTest.java | 32 +- .../dcaegen2/services/sonhms/EventHandlerTest.java | 2 +- .../onap/dcaegen2/services/sonhms/EventTest.java | 78 +++ .../dcaegen2/services/sonhms/FaultFieldsTest.java | 58 ++ .../sonhms/FaultNotificationComponentTest.java | 102 ++++ .../services/sonhms/HoMetricsComponentTest.java | 101 ++++ .../services/sonhms/PMNotificationHandlerTest.java | 117 ++++ .../services/sonhms/child/ChildThreadTest.java | 72 +++ .../services/sonhms/child/StateOofTest.java | 83 +++ .../sonhms/child/TestChildThreadUtils.java | 231 ++++++-- .../services/sonhms/child/TestDetection.java | 7 +- .../services/sonhms/child/TestPnfUtils.java | 7 +- .../sonhms/dmaap/NotificationProducerTest.java | 1 + .../services/sonhms/entity/PciRequestsTest.java | 10 +- .../services/sonhms/model/NotificationTest.java | 2 +- .../services/sonhms/model/PayloadTest.java | 2 +- .../sonhms/restclient/AsyncResponseBodyTest.java | 28 +- .../sonhms/restclient/OofRestClientTest.java | 8 +- .../sonhms/restclient/PciSolutionsTest.java | 2 +- .../sonhms/restclient/SdnrRestClientTest.java | 6 +- .../services/sonhms/restclient/SolutionsTest.java | 20 +- .../services/sonhms/utils/ClusterUtilsTest.java | 196 ++++--- src/test/resources/AsyncRespBody.json | 23 + src/test/resources/ClusterDetailsTest.json | 19 +- src/test/resources/clusterInfo1.json | 13 +- src/test/resources/clusterInfo2.json | 13 +- src/test/resources/clusterInfo3.json | 13 +- src/test/resources/clusterInfo4.json | 13 +- src/test/resources/clusterInfo5.json | 18 +- src/test/resources/clusterInfo6.json | 18 +- src/test/resources/clusterInfo7.json | 13 +- src/test/resources/hoDetails.json | 14 + src/test/resources/notification1.json | 86 +-- src/test/resources/notification2.json | 106 ++-- src/test/resources/notification3.json | 86 +-- src/test/resources/pmNotification.json | 56 ++ src/test/resources/pmNotification1.json | 55 ++ src/test/resources/policy_notification.json | 34 +- src/test/resources/solutions.json | 17 +- version.properties | 20 + 130 files changed, 6222 insertions(+), 2683 deletions(-) create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/AlarmAdditionalInformation.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/CommonEventHeader.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/Event.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/FaultEvent.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/FaultFields.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/FaultNotificationComponent.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/FaultNotificationtoClusterMapping.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/HoMetricsComponent.java rename src/main/java/org/onap/dcaegen2/services/sonhms/{NewNotification.java => NewFmNotification.java} (87%) create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/NewPmNotification.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/NewSdnrNotification.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/PMNotificationHandler.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/PMThread.java delete mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/child/ClusterFormation.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/dao/HandOverMetricsRepository.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/dao/PerformanceNotificationsRepository.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/FMNotificationCallback.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationCallback.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PMNotificationCallback.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/SdnrNotificationCallback.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/entity/HandOverMetrics.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/entity/PerformanceNotifications.java rename src/main/java/org/onap/dcaegen2/services/sonhms/entity/{PciRequests.java => SonRequests.java} (88%) create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/model/AdditionalMeasurements.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/model/AnrInput.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/model/ClusterMap.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/model/Event.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/model/HoDetails.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/model/LteCell.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/model/Measurement.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/model/PMNotification.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/restclient/AnrSolutions.java rename src/main/java/org/onap/dcaegen2/services/sonhms/restclient/{SonSolution.java => PciSolutions.java} (88%) rename src/main/java/org/onap/dcaegen2/services/sonhms/restclient/{Solution.java => Solutions.java} (69%) create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/CommonEventHeaderTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/EventTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/FaultFieldsTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/FaultNotificationComponentTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/HoMetricsComponentTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/PMNotificationHandlerTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/child/StateOofTest.java create mode 100644 src/test/resources/AsyncRespBody.json create mode 100644 src/test/resources/hoDetails.json create mode 100644 src/test/resources/pmNotification.json create mode 100644 src/test/resources/pmNotification1.json diff --git a/dpo/blueprints/k8s-sonhms-inputs.yaml b/dpo/blueprints/k8s-sonhms-inputs.yaml index 9caf823..42afba4 100644 --- a/dpo/blueprints/k8s-sonhms-inputs.yaml +++ b/dpo/blueprints/k8s-sonhms-inputs.yaml @@ -28,6 +28,8 @@ num_solutions: 5 min_collision: 5 min_confusion: 5 max_clusters: 5 +bad_threshold: 50 +poor_threshold: 70 dmaap: message-router buffer_time: 60 cg: sonhms-cg diff --git a/dpo/blueprints/k8s-sonhms.yaml b/dpo/blueprints/k8s-sonhms.yaml index 172048c..9e43fac 100644 --- a/dpo/blueprints/k8s-sonhms.yaml +++ b/dpo/blueprints/k8s-sonhms.yaml @@ -68,6 +68,14 @@ inputs: type: integer description: maximum clusters default: 5 + bad_threshold: + type: integer + description: threshold for bad neighbors + default: 50 + poor_threshold: + type: integer + description: threshold for poor neighbors + default: 70 dmaap: type: string description: dmaap server @@ -179,7 +187,7 @@ node_templates: client_id: { get_input: topic02_client_id } topic_url: { get_input: topic02_url } type: message-router - streams__publishes: + streams_publishes: CL_topic: aaf_username: { get_input: aaf_username } aaf_password: { get_input: aaf_password } @@ -199,6 +207,8 @@ node_templates: sonhandler.minCollision: { get_input: min_collision } sonhandler.minConfusion: { get_input: min_confusion } sonhandler.maximumClusters: { get_input: max_clusters } + sonhandler.badThreshold: { get_input: bad_threshold } + sonhandler.poorThreshold: { get_input: poor_threshold } sonhandler.sourceId: SONHMS sonhandler.dmaap.server: - { get_input: dmaap } diff --git a/dpo/data-formats/cellListFromSdnr-dataformat.json b/dpo/data-formats/cellListFromSdnr-dataformat.json index 610552e..1875be8 100644 --- a/dpo/data-formats/cellListFromSdnr-dataformat.json +++ b/dpo/data-formats/cellListFromSdnr-dataformat.json @@ -1,18 +1,18 @@ { - "dataformatversion": "1.0.0", - "jsonschema": { - "$schema": "http://json-schema.org/draft-04/schema#", - "description": "", - "items": { - "description": "", - "type": "string" - }, - "type": "array" - }, - "self": { - "description": "", - "name": "CELLLIST_FROM_SDNR", - "version": "1.0.0" - } + "dataformatversion": "1.0.0", + "jsonschema": { + "$schema": "http://json-schema.org/draft-04/schema#", + "description": "", + "items": { + "description": "", + "type": "string" + }, + "type": "array" + }, + "self": { + "description": "", + "name": "CELLLIST_FROM_SDNR", + "version": "1.0.0" + } } diff --git a/dpo/data-formats/configdb-req-dataformat.json b/dpo/data-formats/configdb-req-dataformat.json index a40a05c..9549541 100644 --- a/dpo/data-formats/configdb-req-dataformat.json +++ b/dpo/data-formats/configdb-req-dataformat.json @@ -1,12 +1,11 @@ { - "self": { - "name": "CONFIGDB-REQ", - "version": "1.0.0", - "description": "Request to config DB" - - }, - "dataformatversion": "1.0.0", - "unstructured": { - "encoding": "UTF-8" - } + "self": { + "name": "CONFIGDB-REQ", + "version": "1.0.0", + "description": "Request to config DB" + }, + "dataformatversion": "1.0.0", + "unstructured": { + "encoding": "UTF-8" + } } diff --git a/dpo/data-formats/dmaap_son.json b/dpo/data-formats/dmaap_son.json index 43f7b8e..7e4a950 100644 --- a/dpo/data-formats/dmaap_son.json +++ b/dpo/data-formats/dmaap_son.json @@ -1,45 +1,46 @@ -{"nbr_list_change_topic":{ - "type": "message_router", - "aaf_username": "", - "aaf_password": "", - "dmaap_info": { - "client_role": "son-subscriber", - "client_id": "sdnr-son-1", - "location": "onap", - "topic_url": "https://HOSTNAME:3905/events/PCI-NOTIF-TOPIC-NGHBR-LIST-CHANGE-INFO" - } -}, -"fault_management_topic":{ - "type": "message_router", - "aaf_username": "", - "aaf_password": "", - "dmaap_info": { - "client_role": "son-subscriber", - "client_id": "sdnr-son-1", - "location": "onap", - "topic_url": "https://HOSTNAME:3905/events/unauthenticated.SEC_FAULT_OUTPUT" - } -}, -"performance_management_topic":{ - "type": "message_router", - "aaf_username": "", - "aaf_password": "", - "dmaap_info": { - "client_role": "son-subscriber", - "client_id": "sdnr-son-1", - "location": "onap", - "topic_url": "https://HOSTNAME:3905/events/unauthenticated.SEC_MEASUREMENT_OUTPUT" - } -}, -"CL_topic":{ - "type": "message_router", - "aaf_username": "", - "aaf_password": "", - "dmaap_info": { - "client_role": "policy-publisher", - "client_id": "policy-son-1", - "location": "onap", - "topic_url": "https://HOSTNAME:3905/events/DCAE_CL_OUTPUT" - } -} +{ + "nbr_list_change_topic": { + "type": "message_router", + "aaf_username": "", + "aaf_password": "", + "dmaap_info": { + "client_role": "son-subscriber", + "client_id": "sdnr-son-1", + "location": "onap", + "topic_url": "https://HOSTNAME:3905/events/PCI-NOTIF-TOPIC-NGHBR-LIST-CHANGE-INFO" + } + }, + "fault_management_topic": { + "type": "message_router", + "aaf_username": "", + "aaf_password": "", + "dmaap_info": { + "client_role": "son-subscriber", + "client_id": "sdnr-son-1", + "location": "onap", + "topic_url": "https://HOSTNAME:3905/events/unauthenticated.SEC_FAULT_OUTPUT" + } + }, + "performance_management_topic": { + "type": "message_router", + "aaf_username": "", + "aaf_password": "", + "dmaap_info": { + "client_role": "son-subscriber", + "client_id": "sdnr-son-1", + "location": "onap", + "topic_url": "https://HOSTNAME:3905/events/unauthenticated.SEC_MEASUREMENT_OUTPUT" + } + }, + "CL_topic": { + "type": "message_router", + "aaf_username": "", + "aaf_password": "", + "dmaap_info": { + "client_role": "policy-publisher", + "client_id": "policy-son-1", + "location": "onap", + "topic_url": "https://HOSTNAME:3905/events/DCAE_CL_OUTPUT" + } + } } diff --git a/dpo/data-formats/nbrListFromSdnr-dataformat.json b/dpo/data-formats/nbrListFromSdnr-dataformat.json index ad50950..b32ea1f 100644 --- a/dpo/data-formats/nbrListFromSdnr-dataformat.json +++ b/dpo/data-formats/nbrListFromSdnr-dataformat.json @@ -1,33 +1,33 @@ { - "dataformatversion": "1.0.0", - "jsonschema": { - "$schema": "http://json-schema.org/draft-04/schema#", - "description": "", - "items": { - "additionalproperties": true, - "description": "", - "properties": { - "cellId": { - "description": "", - "type": "string" - }, - "pciValue": { - "description": "", - "type": "integer" - } - }, - "required": [ - "cellId", - "pciValue" - ], - "type": "object" - }, - "type": "array" - }, - "self": { - "description": "", - "name": "NBRLST_FROM_SDNR", - "version": "1.0.0" - } + "dataformatversion": "1.0.0", + "jsonschema": { + "$schema": "http://json-schema.org/draft-04/schema#", + "description": "", + "items": { + "additionalproperties": true, + "description": "", + "properties": { + "cellId": { + "description": "", + "type": "string" + }, + "pciValue": { + "description": "", + "type": "integer" + } + }, + "required": [ + "cellId", + "pciValue" + ], + "type": "object" + }, + "type": "array" + }, + "self": { + "description": "", + "name": "NBRLST_FROM_SDNR", + "version": "1.0.0" + } } diff --git a/dpo/data-formats/oofToSonAsyncResp-dataformat.json b/dpo/data-formats/oofToSonAsyncResp-dataformat.json index 2668370..bf99528 100644 --- a/dpo/data-formats/oofToSonAsyncResp-dataformat.json +++ b/dpo/data-formats/oofToSonAsyncResp-dataformat.json @@ -1,91 +1,91 @@ { - "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": { + "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" + } } diff --git a/dpo/data-formats/oofToSonSyncResp-dataformat.json b/dpo/data-formats/oofToSonSyncResp-dataformat.json index 11f8cd0..9f15a06 100644 --- a/dpo/data-formats/oofToSonSyncResp-dataformat.json +++ b/dpo/data-formats/oofToSonSyncResp-dataformat.json @@ -1,38 +1,38 @@ { - "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" - }, - "statusMessage": { - "description": "", - "type": "string" - }, - "transactionId": { - "description": "", - "type": "string" - } - }, - "required": [ - "requestId", - "requestStatus", - "statusMessage", - "transactionId" - ], - "type": "object" - }, - "self": { - "description": "", - "name": "SON_OOF_SYNC_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" + }, + "statusMessage": { + "description": "", + "type": "string" + }, + "transactionId": { + "description": "", + "type": "string" + } + }, + "required": [ + "requestId", + "requestStatus", + "statusMessage", + "transactionId" + ], + "type": "object" + }, + "self": { + "description": "", + "name": "SON_OOF_SYNC_RESP", + "version": "1.0.0" + } } diff --git a/dpo/data-formats/pciFromSdnr-dataformat.json b/dpo/data-formats/pciFromSdnr-dataformat.json index 5eb8e7c..111d55a 100644 --- a/dpo/data-formats/pciFromSdnr-dataformat.json +++ b/dpo/data-formats/pciFromSdnr-dataformat.json @@ -1,29 +1,29 @@ { - "dataformatversion": "1.0.0", - "jsonschema": { - "$schema": "http://json-schema.org/draft-04/schema#", - "additionalproperties": true, - "description": "", - "properties": { - "attribute-name": { - "description": "", - "type": "string" - }, - "value": { - "description": "", - "type": "string" - } - }, - "required": [ - "attribute-name", - "value" - ], - "type": "object" - }, - "self": { - "description": "", - "name": "PCI_FROM_SDNR", - "version": "1.0.0" - } + "dataformatversion": "1.0.0", + "jsonschema": { + "$schema": "http://json-schema.org/draft-04/schema#", + "additionalproperties": true, + "description": "", + "properties": { + "attribute-name": { + "description": "", + "type": "string" + }, + "value": { + "description": "", + "type": "string" + } + }, + "required": [ + "attribute-name", + "value" + ], + "type": "object" + }, + "self": { + "description": "", + "name": "PCI_FROM_SDNR", + "version": "1.0.0" + } } diff --git a/dpo/data-formats/pnfNameFromSdnr-dataformat.json b/dpo/data-formats/pnfNameFromSdnr-dataformat.json index 84787dc..4f9f1d6 100644 --- a/dpo/data-formats/pnfNameFromSdnr-dataformat.json +++ b/dpo/data-formats/pnfNameFromSdnr-dataformat.json @@ -1,29 +1,29 @@ { - "dataformatversion": "1.0.0", - "jsonschema": { - "$schema": "http://json-schema.org/draft-04/schema#", - "additionalproperties": true, - "description": "", - "properties": { - "attribute-name": { - "description": "", - "type": "string" - }, - "value": { - "description": "", - "type": "string" - } - }, - "required": [ - "attribute-name", - "value" - ], - "type": "object" - }, - "self": { - "description": "", - "name": "PNFNAME_FROM_SDNR", - "version": "1.0.0" - } + "dataformatversion": "1.0.0", + "jsonschema": { + "$schema": "http://json-schema.org/draft-04/schema#", + "additionalproperties": true, + "description": "", + "properties": { + "attribute-name": { + "description": "", + "type": "string" + }, + "value": { + "description": "", + "type": "string" + } + }, + "required": [ + "attribute-name", + "value" + ], + "type": "object" + }, + "self": { + "description": "", + "name": "PNFNAME_FROM_SDNR", + "version": "1.0.0" + } } diff --git a/dpo/data-formats/policyToSonReq-dataformat.json b/dpo/data-formats/policyToSonReq-dataformat.json index f787695..c677a35 100644 --- a/dpo/data-formats/policyToSonReq-dataformat.json +++ b/dpo/data-formats/policyToSonReq-dataformat.json @@ -1,23 +1,23 @@ { - "dataformatversion": "1.0.0", - "jsonschema": { - "$schema": "http://json-schema.org/draft-04/schema#", - "additionalproperties": true, - "description": "", - "properties": { - "policyName": { - "description": "", - "type": "string" - } - }, - "required": [ - "policyName" - ], - "type": "object" - }, - "self": { - "description": "", - "name": "SON_TO_POLICY_REST_REQ", - "version": "1.0.0" - } + "dataformatversion": "1.0.0", + "jsonschema": { + "$schema": "http://json-schema.org/draft-04/schema#", + "additionalproperties": true, + "description": "", + "properties": { + "policyName": { + "description": "", + "type": "string" + } + }, + "required": [ + "policyName" + ], + "type": "object" + }, + "self": { + "description": "", + "name": "SON_TO_POLICY_REST_REQ", + "version": "1.0.0" + } } diff --git a/dpo/data-formats/policyToSonResp-dataformat.json b/dpo/data-formats/policyToSonResp-dataformat.json index 526f145..d409824 100644 --- a/dpo/data-formats/policyToSonResp-dataformat.json +++ b/dpo/data-formats/policyToSonResp-dataformat.json @@ -1,64 +1,64 @@ { - "dataformatversion": "1.0.0", - "jsonschema": { - "$schema": "http://json-schema.org/draft-04/schema#", - "additionalproperties": true, - "description": "", - "properties": { - "configBody": { - "description": "", - "type": "string" - }, - "configBodyType": { - "description": "", - "type": "string" - }, - "configName": { - "description": "", - "type": "string" - }, - "onapName": { - "description": "", - "type": "string" - }, - "policyClass": { - "description": "", - "type": "string" - }, - "policyConfigType": { - "description": "", - "type": "string" - }, - "policyName": { - "description": "", - "type": "string" - }, - "policyVersion": { - "description": "", - "type": "string" - }, - "ttlDate": { - "description": "", - "type": "string" - } - }, - "required": [ - "configBody", - "configBodyType", - "configName", - "onapName", - "policyClass", - "policyConfigType", - "policyName", - "policyVersion", - "ttlDate" - ], - "type": "object" - }, - "self": { - "description": "", - "name": "POLICY_TO_SON_REST_RESP", - "version": "1.0.0" - } + "dataformatversion": "1.0.0", + "jsonschema": { + "$schema": "http://json-schema.org/draft-04/schema#", + "additionalproperties": true, + "description": "", + "properties": { + "configBody": { + "description": "", + "type": "string" + }, + "configBodyType": { + "description": "", + "type": "string" + }, + "configName": { + "description": "", + "type": "string" + }, + "onapName": { + "description": "", + "type": "string" + }, + "policyClass": { + "description": "", + "type": "string" + }, + "policyConfigType": { + "description": "", + "type": "string" + }, + "policyName": { + "description": "", + "type": "string" + }, + "policyVersion": { + "description": "", + "type": "string" + }, + "ttlDate": { + "description": "", + "type": "string" + } + }, + "required": [ + "configBody", + "configBodyType", + "configName", + "onapName", + "policyClass", + "policyConfigType", + "policyName", + "policyVersion", + "ttlDate" + ], + "type": "object" + }, + "self": { + "description": "", + "name": "POLICY_TO_SON_REST_RESP", + "version": "1.0.0" + } } diff --git a/dpo/data-formats/sonInputFromSdnr-dataformat.json b/dpo/data-formats/sonInputFromSdnr-dataformat.json index de8c017..0ff1bc7 100644 --- a/dpo/data-formats/sonInputFromSdnr-dataformat.json +++ b/dpo/data-formats/sonInputFromSdnr-dataformat.json @@ -1,212 +1,212 @@ { - "dataformatversion": "1.0.0", - "jsonschema": { - "$schema": "http://json-schema.org/draft-04/schema#", - "additionalproperties": true, - "description": "", - "properties": { - "AAI": { - "description": "", - "type": "object" - }, - "Action": { - "description": "", - "type": "string" - }, - "Payload": { - "additionalproperties": true, - "description": "", - "properties": { - "RadioAccess": { - "additionalproperties": true, - "description": "", - "properties": { - "FAPServiceList": { - "description": "", - "items": { - "additionalproperties": true, - "description": "", - "properties": { - "CellConfig": { - "additionalproperties": true, - "description": "", - "properties": { - "LTE": { - "additionalproperties": true, - "description": "", - "properties": { - "RAN": { - "additionalproperties": true, - "description": "", - "properties": { - "CellIdentity": { - "description": "", - "type": "string" - }, - "NeighborListInUse": { - "additionalproperties": true, - "description": "", - "properties": { - "LTECellNumberOfEntries": { - "description": "", - "type": "string" - }, - "LTENeighborListInUseLTECell": { - "description": "", - "items": { - "additionalproperties": true, - "description": "", - "properties": { - "alias": { - "description": "", - "type": "string" - }, - "blacklisted": { - "description": "", - "type": "string" - }, - "cid": { - "description": "", - "type": "string" - }, - "enable": { - "description": "", - "type": "string" - }, - "mustInclude": { - "description": "", - "type": "string" - }, - "phyCellId": { - "description": "", - "type": "string" - }, - "plmnid": { - "description": "", - "type": "string" - }, - "pnfName": { - "description": "", - "type": "string" - } - }, - "required": [ - "alias", - "blacklisted", - "cid", - "enable", - "mustInclude", - "phyCellId", - "plmnid", - "pnfName" - ], - "type": "object" - }, - "type": "array" - } - }, - "required": [ - "LTECellNumberOfEntries", - "LTENeighborListInUseLTECell" - ], - "type": "object" - } - }, - "required": [ - "CellIdentity", - "NeighborListInUse" - ], - "type": "object" - } - }, - "required": [ - "RAN" - ], - "type": "object" - } - }, - "required": [ - "LTE" - ], - "type": "object" - }, - "X0005b9Lte": { - "additionalproperties": true, - "description": "", - "properties": { - "phyCellIdInUse": { - "description": "", - "type": "string" - }, - "pnfName": { - "description": "", - "type": "string" - } - }, - "required": [ - "phyCellIdInUse", - "pnfName" - ], - "type": "object" - }, - "alias": { - "description": "", - "type": "string" - } - }, - "required": [ - "CellConfig", - "X0005b9Lte", - "alias" - ], - "type": "object" - }, - "type": "array" - }, - "FAPServiceNumberOfEntries": { - "description": "", - "type": "string" - } - }, - "required": [ - "FAPServiceList", - "FAPServiceNumberOfEntries" - ], - "type": "object" - } - }, - "required": [ - "RadioAccess" - ], - "type": "object" - }, - "from": { - "description": "", - "type": "string" - }, - "requestID": { - "description": "", - "type": "string" - }, - "version": { - "description": "", - "type": "string" - } - }, - "required": [ - "AAI", - "Action", - "Payload", - "from", - "requestID", - "version" - ], - "type": "object" - }, - "self": { - "description": "dmaap message from SDNR to SON handler", - "name": "SON_INPUT_FROM_SDNR", - "version": "1.0.0" - } + "dataformatversion": "1.0.0", + "jsonschema": { + "$schema": "http://json-schema.org/draft-04/schema#", + "additionalproperties": true, + "description": "", + "properties": { + "AAI": { + "description": "", + "type": "object" + }, + "Action": { + "description": "", + "type": "string" + }, + "Payload": { + "additionalproperties": true, + "description": "", + "properties": { + "RadioAccess": { + "additionalproperties": true, + "description": "", + "properties": { + "FAPServiceList": { + "description": "", + "items": { + "additionalproperties": true, + "description": "", + "properties": { + "CellConfig": { + "additionalproperties": true, + "description": "", + "properties": { + "LTE": { + "additionalproperties": true, + "description": "", + "properties": { + "RAN": { + "additionalproperties": true, + "description": "", + "properties": { + "CellIdentity": { + "description": "", + "type": "string" + }, + "NeighborListInUse": { + "additionalproperties": true, + "description": "", + "properties": { + "LTECellNumberOfEntries": { + "description": "", + "type": "string" + }, + "LTENeighborListInUseLTECell": { + "description": "", + "items": { + "additionalproperties": true, + "description": "", + "properties": { + "alias": { + "description": "", + "type": "string" + }, + "blacklisted": { + "description": "", + "type": "string" + }, + "cid": { + "description": "", + "type": "string" + }, + "enable": { + "description": "", + "type": "string" + }, + "mustInclude": { + "description": "", + "type": "string" + }, + "phyCellId": { + "description": "", + "type": "string" + }, + "plmnid": { + "description": "", + "type": "string" + }, + "pnfName": { + "description": "", + "type": "string" + } + }, + "required": [ + "alias", + "blacklisted", + "cid", + "enable", + "mustInclude", + "phyCellId", + "plmnid", + "pnfName" + ], + "type": "object" + }, + "type": "array" + } + }, + "required": [ + "LTECellNumberOfEntries", + "LTENeighborListInUseLTECell" + ], + "type": "object" + } + }, + "required": [ + "CellIdentity", + "NeighborListInUse" + ], + "type": "object" + } + }, + "required": [ + "RAN" + ], + "type": "object" + } + }, + "required": [ + "LTE" + ], + "type": "object" + }, + "X0005b9Lte": { + "additionalproperties": true, + "description": "", + "properties": { + "phyCellIdInUse": { + "description": "", + "type": "string" + }, + "pnfName": { + "description": "", + "type": "string" + } + }, + "required": [ + "phyCellIdInUse", + "pnfName" + ], + "type": "object" + }, + "alias": { + "description": "", + "type": "string" + } + }, + "required": [ + "CellConfig", + "X0005b9Lte", + "alias" + ], + "type": "object" + }, + "type": "array" + }, + "FAPServiceNumberOfEntries": { + "description": "", + "type": "string" + } + }, + "required": [ + "FAPServiceList", + "FAPServiceNumberOfEntries" + ], + "type": "object" + } + }, + "required": [ + "RadioAccess" + ], + "type": "object" + }, + "from": { + "description": "", + "type": "string" + }, + "requestID": { + "description": "", + "type": "string" + }, + "version": { + "description": "", + "type": "string" + } + }, + "required": [ + "AAI", + "Action", + "Payload", + "from", + "requestID", + "version" + ], + "type": "object" + }, + "self": { + "description": "dmaap message from SDNR to SON handler", + "name": "SON_INPUT_FROM_SDNR", + "version": "1.0.0" + } } diff --git a/dpo/data-formats/sonToOofReq-dataformat.json b/dpo/data-formats/sonToOofReq-dataformat.json index 3ca70e0..e686dd1 100644 --- a/dpo/data-formats/sonToOofReq-dataformat.json +++ b/dpo/data-formats/sonToOofReq-dataformat.json @@ -1,97 +1,97 @@ { - "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": { + "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" + } } diff --git a/dpo/data-formats/sonToPolicyReq-dataformat.json b/dpo/data-formats/sonToPolicyReq-dataformat.json index 7686242..df016aa 100644 --- a/dpo/data-formats/sonToPolicyReq-dataformat.json +++ b/dpo/data-formats/sonToPolicyReq-dataformat.json @@ -1,24 +1,24 @@ { - "dataformatversion": "1.0.0", - "jsonschema": { - "$schema": "http://json-schema.org/draft-04/schema#", - "additionalproperties": true, - "description": "", - "properties": { - "policyName": { - "description": "", - "type": "string" - } - }, - "required": [ - "policyName" - ], - "type": "object" - }, - "self": { - "description": "", - "name": "SON_TO_POLICY_REST_REQ", - "version": "1.0.0" - } + "dataformatversion": "1.0.0", + "jsonschema": { + "$schema": "http://json-schema.org/draft-04/schema#", + "additionalproperties": true, + "description": "", + "properties": { + "policyName": { + "description": "", + "type": "string" + } + }, + "required": [ + "policyName" + ], + "type": "object" + }, + "self": { + "description": "", + "name": "SON_TO_POLICY_REST_REQ", + "version": "1.0.0" + } } diff --git a/dpo/spec/sonhandler-componentspec.json b/dpo/spec/sonhandler-componentspec.json index 186fbf7..1586dcf 100644 --- a/dpo/spec/sonhandler-componentspec.json +++ b/dpo/spec/sonhandler-componentspec.json @@ -1,297 +1,313 @@ { - "self":{ - "version":"1.0.0", - "name":"docker.sonhandler.app", - "description":"Handles the PCI optimization for SON network", - "component_type":"docker" - }, - "streams":{ - "subscribes":[ - { - "format":"SON_INPUT_FROM_SDNR", - "version":"1.0.0", - "config_key":"nbr_list_change_topic", - "type":"message router" - }, - { - "format":"FM_ALARM_FROM_VES", - "version":"1.0.0", - "config_key":"fault_management_topic", - "type":"message router" - }, - { - "format":"PM_ALARM_FROM_VES", - "version":"1.0.0", - "config_key":"performance_management_topic", - "type":"message router" - }, - { - "format":"SON_OOF_ASYNC_RESP", - "version":"1.0.0", - "route":"/callbackUrl", - "type":"http" - } - ], - "publishes":[ - { - "format":"SON_TO_POLICY_DMAAP", - "version":"1.0.0", - "config_key":"CL_topic", - "type":"message router" - } - ] - }, - "services":{ - "calls":[ - { - "config_key":"oof-req", - "request":{ - "format":"SON_TO_OOF_REST_REQ", - "version":"1.0.0" - }, - "response":{ - "format":"SON_OOF_SYNC_RESP", - "version":"1.0.0" - } - }, - { - "config_key":"sdnr-getpnfname", - "request":{ - "format":"CONFIGDB-REQ", - "version":"1.0.0" - }, - "response":{ - "format":"PNFNAME_FROM_SDNR", - "version":"1.0.0" - } - }, - { - "config_key":"sdnr-getcelllist", - "request":{ - "format":"CONFIGDB-REQ", - "version":"1.0.0" - }, - "response":{ - "format":"CELLLIST_FROM_SDNR", - "version":"1.0.0" - } - }, - { - "config_key":"sdnr-getnbrlist", - "request":{ - "format":"CONFIGDB-REQ", - "version":"1.0.0" - }, - "response":{ - "format":"NBRLST_FROM_SDNR", - "version":"1.0.0" - } - }, - { - "config_key":"sdnr-getpci", - "request":{ - "format":"CONFIGDB-REQ", - "version":"1.0.0" - }, - "response":{ - "format":"PCI_FROM_SDNR", - "version":"1.0.0" - } - } - ], - "provides":[ - - ] - }, - "parameters":[ - { - "name":"postgres.username", - "value":"sonuser", - "description":"postgres config", - "sourced_at_deployment":false, - "policy_editable":false, - "designer_editable":false - }, - { - "name":"postgres.password", - "value":"sonpassword", - "description":"postgres config", - "sourced_at_deployment":false, - "policy_editable":false, - "designer_editable":false - }, - { - "name":"postgres.host", - "value":"10.165.160.148", - "description":"postgres config", - "sourced_at_deployment":false, - "policy_editable":false, - "designer_editable":false - }, - { - "name":"postgres.port", - "value":"5432", - "description":"postgres config", - "sourced_at_deployment":false, - "policy_editable":false, - "designer_editable":false - }, - { - "name":"sonhandler.optimizers", - "value":[ - "pci" - ], - "description":"son handler optimizers list", - "sourced_at_deployment":false, - "policy_editable":false, - "designer_editable":false - }, - { - "name":"sonhandler.buffertime", - "value":"60", - "description":"buffer time in seconds", - "sourced_at_deployment":false, - "policy_editable":false, - "designer_editable":false - }, - { - "name":"sonhandler.numsolutions", - "value":"10", - "description":"number of solutions", - "sourced_at_deployment":false, - "policy_editable":false, - "designer_editable":false - }, - { - "name":"sonhandler.maximumclusters", - "value":"5", - "description":"maximum number of clusters", - "sourced_at_deployment":false, - "policy_editable":false, - "designer_editable":false - }, - { - "name":"sonhandler.cg", - "value":"sonhms-cg", - "description":"son consumer group", - "sourced_at_deployment":false, - "policy_editable":false, - "designer_editable":false - }, - { - "name":"sonhandler.cid", - "value":"sonhms-cid", - "description":"son consumer Id", - "sourced_at_deployment":false, - "policy_editable":false, - "designer_editable":false - }, - { - "name":"sonhandler.dmaap.servers", - "value":["message-router:3904"], - "description":"dmaap server location", - "sourced_at_deployment":false, - "policy_editable":false, - "designer_editable":false - }, - { - "name":"sonhandler.pollingInterval", - "value":"20", - "description":"dmaap polling interval", - "sourced_at_deployment":false, - "policy_editable":false, - "designer_editable":false - }, - { - "name":"sonhandler.pollingTimeout", - "value":"60", - "description":"dmaap polling timeout", - "sourced_at_deployment":false, - "policy_editable":false, - "designer_editable":false - }, - { - "name":"sonhandler.minCollision", - "value":"5", - "description":"minimum collision count", - "sourced_at_deployment":false, - "policy_editable":false, - "designer_editable":false - }, - { - "name":"sonhandler.minConfusion", - "value":"5", - "description":"minimum confusion count", - "sourced_at_deployment":false, - "policy_editable":false, - "designer_editable":false - }, - { - "name":"sonhandler.configDb.service", - "value":"http://sdnc:8282", - "description":"configDb service url", - "sourced_at_deployment":false, - "policy_editable":false, - "designer_editable":false - }, - { - "name":"sonhandler.oof.service", - "value":"http://oof:8080", - "description":"oof service url", - "sourced_at_deployment":false, - "policy_editable":false, - "designer_editable":false - }, - { - "name":"sonhandler.sourceId", - "value":"SONHMS", - "description":"sonhms source ID", - "sourced_at_deployment":false, - "policy_editable":false, - "designer_editable":false - }, - { - "name":"sonhandler.callbackUrl", - "value":"http://sonhms.onap:8080/callbackUrl", - "description":"sonhms callback url", - "sourced_at_deployment":false, - "policy_editable":false, - "designer_editable":false - } - ], - "auxilary":{ - "healthcheck":{ - "type":"http", - "interval":"15s", - "timeout":"1s", - "endpoint":"/healthckeck" - }, - "volumes":[ - { - "container":{ - "bind":"/etc/localtime" - }, - "host":{ - "path":"/etc/localtime" - } - }, - { - "container":{ - "bind":"/var/log/onap" - }, - "host":{ - "path":"/dockerdata-nfs/pci-handler/logs" - } - } - ], - "ports":[ - "8080:8080" - ] - }, - "artifacts":[ - { - "type":"docker image", - "uri":"k8s-rancher-1:5000/son-handler:1.0.1" - } - ] + "self": { + "version": "1.0.0", + "name": "docker.sonhandler.app", + "description": "Handles the PCI optimization for SON network", + "component_type": "docker" + }, + "streams": { + "subscribes": [ + { + "format": "SON_INPUT_FROM_SDNR", + "version": "1.0.0", + "config_key": "nbr_list_change_topic", + "type": "message router" + }, + { + "format": "FM_ALARM_FROM_VES", + "version": "1.0.0", + "config_key": "fault_management_topic", + "type": "message router" + }, + { + "format": "PM_ALARM_FROM_VES", + "version": "1.0.0", + "config_key": "performance_management_topic", + "type": "message router" + }, + { + "format": "SON_OOF_ASYNC_RESP", + "version": "1.0.0", + "route": "/callbackUrl", + "type": "http" + } + ], + "publishes": [ + { + "format": "SON_TO_POLICY_DMAAP", + "version": "1.0.0", + "config_key": "CL_topic", + "type": "message router" + } + ] + }, + "services": { + "calls": [ + { + "config_key": "oof-req", + "request": { + "format": "SON_TO_OOF_REST_REQ", + "version": "1.0.0" + }, + "response": { + "format": "SON_OOF_SYNC_RESP", + "version": "1.0.0" + } + }, + { + "config_key": "sdnr-getpnfname", + "request": { + "format": "CONFIGDB-REQ", + "version": "1.0.0" + }, + "response": { + "format": "PNFNAME_FROM_SDNR", + "version": "1.0.0" + } + }, + { + "config_key": "sdnr-getcelllist", + "request": { + "format": "CONFIGDB-REQ", + "version": "1.0.0" + }, + "response": { + "format": "CELLLIST_FROM_SDNR", + "version": "1.0.0" + } + }, + { + "config_key": "sdnr-getnbrlist", + "request": { + "format": "CONFIGDB-REQ", + "version": "1.0.0" + }, + "response": { + "format": "NBRLST_FROM_SDNR", + "version": "1.0.0" + } + }, + { + "config_key": "sdnr-getpci", + "request": { + "format": "CONFIGDB-REQ", + "version": "1.0.0" + }, + "response": { + "format": "PCI_FROM_SDNR", + "version": "1.0.0" + } + } + ], + "provides": [] + }, + "parameters": [ + { + "name": "postgres.username", + "value": "sonuser", + "description": "postgres config", + "sourced_at_deployment": false, + "policy_editable": false, + "designer_editable": false + }, + { + "name": "postgres.password", + "value": "sonpassword", + "description": "postgres config", + "sourced_at_deployment": false, + "policy_editable": false, + "designer_editable": false + }, + { + "name": "postgres.host", + "value": "10.165.160.148", + "description": "postgres config", + "sourced_at_deployment": false, + "policy_editable": false, + "designer_editable": false + }, + { + "name": "postgres.port", + "value": "5432", + "description": "postgres config", + "sourced_at_deployment": false, + "policy_editable": false, + "designer_editable": false + }, + { + "name": "sonhandler.optimizers", + "value": [ + "pci" + ], + "description": "son handler optimizers list", + "sourced_at_deployment": false, + "policy_editable": false, + "designer_editable": false + }, + { + "name": "sonhandler.buffertime", + "value": "60", + "description": "buffer time in seconds", + "sourced_at_deployment": false, + "policy_editable": false, + "designer_editable": false + }, + { + "name": "sonhandler.numsolutions", + "value": "10", + "description": "number of solutions", + "sourced_at_deployment": false, + "policy_editable": false, + "designer_editable": false + }, + { + "name": "sonhandler.maximumclusters", + "value": "5", + "description": "maximum number of clusters", + "sourced_at_deployment": false, + "policy_editable": false, + "designer_editable": false + }, + { + "name": "sonhandler.cg", + "value": "sonhms-cg", + "description": "son consumer group", + "sourced_at_deployment": false, + "policy_editable": false, + "designer_editable": false + }, + { + "name": "sonhandler.cid", + "value": "sonhms-cid", + "description": "son consumer Id", + "sourced_at_deployment": false, + "policy_editable": false, + "designer_editable": false + }, + { + "name": "sonhandler.dmaap.servers", + "value": [ + "message-router:3904" + ], + "description": "dmaap server location", + "sourced_at_deployment": false, + "policy_editable": false, + "designer_editable": false + }, + { + "name": "sonhandler.pollingInterval", + "value": "20", + "description": "dmaap polling interval", + "sourced_at_deployment": false, + "policy_editable": false, + "designer_editable": false + }, + { + "name": "sonhandler.pollingTimeout", + "value": "60", + "description": "dmaap polling timeout", + "sourced_at_deployment": false, + "policy_editable": false, + "designer_editable": false + }, + { + "name": "sonhandler.minCollision", + "value": "5", + "description": "minimum collision count", + "sourced_at_deployment": false, + "policy_editable": false, + "designer_editable": false + }, + { + "name": "sonhandler.minConfusion", + "value": "5", + "description": "minimum confusion count", + "sourced_at_deployment": false, + "policy_editable": false, + "designer_editable": false + }, + { + "name": "sonhandler.configDb.service", + "value": "http://sdnc:8282", + "description": "configDb service url", + "sourced_at_deployment": false, + "policy_editable": false, + "designer_editable": false + }, + { + "name": "sonhandler.oof.service", + "value": "http://oof:8080", + "description": "oof service url", + "sourced_at_deployment": false, + "policy_editable": false, + "designer_editable": false + }, + { + "name": "sonhandler.sourceId", + "value": "SONHMS", + "description": "sonhms source ID", + "sourced_at_deployment": false, + "policy_editable": false, + "designer_editable": false + }, + { + "name": "sonhandler.badThreshold", + "value": "50", + "description": "Threshold for bad neighbors", + "sourced_at_deployment": false, + "policy_editable": false, + "designer_editable": false + }, + { + "name": "sonhandler.poorThreshold", + "value": "70", + "description": "Threshold for poor neighbors", + "sourced_at_deployment": false, + "policy_editable": false, + "designer_editable": false + }, + { + "name": "sonhandler.callbackUrl", + "value": "http://sonhms.onap:8080/callbackUrl", + "description": "sonhms callback url", + "sourced_at_deployment": false, + "policy_editable": false, + "designer_editable": false + } + ], + "auxilary": { + "healthcheck": { + "type": "http", + "interval": "15s", + "timeout": "1s", + "endpoint": "/healthckeck" + }, + "volumes": [ + { + "container": { + "bind": "/etc/localtime" + }, + "host": { + "path": "/etc/localtime" + } + }, + { + "container": { + "bind": "/var/log/onap" + }, + "host": { + "path": "/dockerdata-nfs/pci-handler/logs" + } + } + ], + "ports": [ + "8080:8080" + ] + }, + "artifacts": [ + { + "type": "docker image", + "uri": "k8s-rancher-1:5000/son-handler:1.0.1" + } + ] } diff --git a/pom.xml b/pom.xml index 05dd29b..e3a48a3 100644 --- a/pom.xml +++ b/pom.xml @@ -1,357 +1,327 @@ - + - 4.0.0 - org.onap.dcaegen2.services.son-handler - son-handler - dcaegen2-services-son-handler - 1.0.0-SNAPSHOT + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + org.onap.dcaegen2.services.son-handler + son-handler + dcaegen2-services-son-handler + 1.0.0-SNAPSHOT - - - - org.onap.oparent - oparent - 1.2.1 - - + + + org.onap.oparent + oparent + 1.2.1 + + - - 1.1.3 - UTF-8 - 1.8 - 1.8 - onap/org.onap.dcaegen2.services.son-handler - - https://nexus.onap.org - content/repositories/snapshots/ - content/repositories/releases/ - content/sites/site/org/onap/dcaegen2/services/son-handler/${project.artifactId}/${project.version} - yyyyMMdd'T'HHmmss - - - - - org.onap.dcaegen2.services.sdk.rest.services - cbs-client - ${sdk.version} - - - - org.onap.dcaegen2.services.sdk.security.crypt - crypt-password - ${sdk.version} - - - - org.springframework.boot - spring-boot-dependencies - 2.0.4.RELEASE - pom - import - - - com.att.nsa - cambriaClient - 0.0.1 - - - junit - junit - test - - - com.fasterxml.jackson.core - jackson-core - 2.9.8 - - - com.fasterxml.jackson.core - jackson-databind - 2.9.8 - - - - javax.json - javax.json-api - 1.1.2 - - - org.springframework.boot - spring-boot-starter-web - 2.0.4.RELEASE - - - org.postgresql - postgresql - 42.2.5 - - - org.springframework.boot - spring-boot-starter-data-jpa - 2.0.4.RELEASE - - - org.springframework.data - spring-data-commons-core - 1.4.0.RELEASE - + + 1.1.4-SNAPSHOT + UTF-8 + 1.8 + 1.8 + onap/org.onap.dcaegen2.services.son-handler + + https://nexus.onap.org + content/repositories/snapshots/ + content/repositories/releases/ + content/sites/site/org/onap/dcaegen2/services/son-handler/${project.artifactId}/${project.version} + yyyyMMdd'T'HHmmss + + + + + org.onap.dcaegen2.services.sdk.rest.services + cbs-client + ${sdk.version} + - - - - org.codehaus.jackson - jackson-mapper-asl - 1.9.13 - - - org.hibernate.javax.persistence - hibernate-jpa-2.0-api - 1.0.1.Final - - - - org.springframework - spring-beans - 5.0.10.RELEASE - + + org.onap.dcaegen2.services.sdk.security.crypt + crypt-password + ${sdk.version} + + + + org.springframework.boot + spring-boot-dependencies + 2.0.4.RELEASE + pom + import + + + com.att.nsa + cambriaClient + 0.0.1 + + + junit + junit + test + + + com.fasterxml.jackson.core + jackson-core + 2.9.8 + + + com.fasterxml.jackson.core + jackson-databind + 2.9.8 + + + + javax.json + javax.json-api + 1.1.2 + + + org.springframework.boot + spring-boot-starter-web + 2.0.4.RELEASE + + + org.postgresql + postgresql + 42.2.5 + + + org.springframework.boot + spring-boot-starter-data-jpa + 2.0.4.RELEASE + + + org.springframework.data + spring-data-commons-core + 1.4.0.RELEASE + - - org.springframework.boot - spring-boot-starter-test -2.0.4.RELEASE - test - - - - - - org.mockito - mockito-core - 1.10.16 - test - - - - - junit - junit - 4.12 - test - - - - - org.powermock - powermock-api-mockito - 1.6.4 - test - - - - org.powermock - powermock-module-junit4 - 1.6.4 - test - - - org.functionaljava - functionaljava - 3.0 - - - + + + org.codehaus.jackson + jackson-mapper-asl + 1.9.13 + + + org.hibernate.javax.persistence + hibernate-jpa-2.0-api + 1.0.1.Final + + + + org.springframework + spring-beans + 5.0.10.RELEASE + - - - - maven-checkstyle-plugin - - - onap-java-style - - check - - process-sources - - - onap-checkstyle/onap-java-style.xml - - - ${project.build.sourceDirectory} - - true - false - false - - - true - false - warning - - - - - - org.onap.oparent - checkstyle - 1.2.3 - compile - - - - - + org.springframework.boot - spring-boot-maven-plugin - 2.0.4.RELEASE - - - - repackage - - - - - - com.spotify - docker-maven-plugin - - ${onap.nexus.dockerregistry.daily} + spring-boot-starter-test + 2.0.4.RELEASE + test + + + + + + org.mockito + mockito-core + 1.10.16 + test + + + + + junit + junit + 4.12 + test + + + + + org.powermock + powermock-api-mockito + 1.6.4 + test + + + + org.powermock + powermock-module-junit4 + 1.6.4 + test + + + + org.functionaljava + functionaljava + 3.0 + + + + + + + + + maven-checkstyle-plugin + + + onap-java-style + + check + + process-sources + + + onap-checkstyle/onap-java-style.xml + + + ${project.build.sourceDirectory} + + true + false + false + + + true + false + warning + + + + + + org.onap.oparent + checkstyle + 1.2.3 + compile + + + + + + org.springframework.boot + spring-boot-maven-plugin + 2.0.4.RELEASE + + + + repackage + + + + + + com.spotify + docker-maven-plugin + + ${onap.nexus.dockerregistry.daily} - ${docker.image.name} - - latest - - java:openjdk-8 - - - /bin - ${project.build.directory} - ${project.artifactId}-${project.version}.jar - - - /bin - ${project.basedir} - entrypoint.sh - - - - - chmod +x /bin/entrypoint.sh - mv /bin/*.jar /bin/application.jar - - - 8080 - - /bin/entrypoint.sh - - - - build-image - package - - build - - - - tag-and-push-image-latest - deploy - - tag - - - ${docker.image.name}:latest - ${onap.nexus.dockerregistry.daily}/${docker.image.name}:latest - true - - - - tag-and-push-image-with-version - deploy - - tag - - - ${docker.image.name}:latest - ${onap.nexus.dockerregistry.daily}/${docker.image.name}:${project.version} - true - - - - tag-and-push-image-with-version-and-date - deploy - - tag - - - ${docker.image.name}:latest - ${onap.nexus.dockerregistry.daily}/${docker.image.name}:${project.version}-${maven.build.timestamp}Z - true - - - - - - + ${docker.image.name} + + latest + + java:openjdk-8 + sonhms + + + /bin + ${project.build.directory} + ${project.artifactId}-${project.version}.jar + + + /bin + ${project.basedir} + entrypoint.sh + + + + + chmod +x /bin/entrypoint.sh + mv /bin/*.jar /bin/application.jar + chmod -R 777 /bin + mkdir /var/log/onap + chmod -R 777 /var/log/onap + + + 8080 + + /bin/entrypoint.sh + + + + build-image + package + + build + + + + tag-and-push-image-latest + deploy + + tag + + + ${docker.image.name}:latest + ${onap.nexus.dockerregistry.daily}/${docker.image.name}:latest + true + + + + tag-and-push-image-with-version + deploy + + tag + + + ${docker.image.name}:latest + ${onap.nexus.dockerregistry.daily}/${docker.image.name}:${project.version} + true + + + + tag-and-push-image-with-version-and-date + deploy + + tag + + + ${docker.image.name}:latest + ${onap.nexus.dockerregistry.daily}/${docker.image.name}:${project.version}-${maven.build.timestamp}Z + true + + + + + + diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/AlarmAdditionalInformation.java b/src/main/java/org/onap/dcaegen2/services/sonhms/AlarmAdditionalInformation.java new file mode 100644 index 0000000..63cc745 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/AlarmAdditionalInformation.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * pcims + * ================================================================================ + * 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========================================================= + ******************************************************************************/ + +package org.onap.dcaegen2.services.sonhms; + +public class AlarmAdditionalInformation { + + 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; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/Application.java b/src/main/java/org/onap/dcaegen2/services/sonhms/Application.java index 22d58d9..22f458a 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/Application.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/Application.java @@ -31,24 +31,23 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.jdbc.DataSourceBuilder; import org.springframework.context.annotation.Bean; -@SpringBootApplication +@SpringBootApplication public class Application { - private static Logger log = LoggerFactory.getLogger(Application.class); /** * Main method where the pci context is initially set. */ public static void main(String[] args) { - + ConfigFetchFromCbs configFetchFromCbs = new ConfigFetchFromCbs(); configFetchFromCbs.getAppConfig(); try { - Thread.sleep(10000); - } catch (InterruptedException e) { - log.debug("InterruptedException : {}",e); - } + Thread.sleep(10000); + } catch (InterruptedException e) { + log.debug("InterruptedException : {}", e); + } log.info("after 10s sleep"); log.info("Starting spring boot application"); SpringApplication.run(Application.class); @@ -61,15 +60,11 @@ public class Application { @Bean public DataSource dataSource() { Configuration configuration = Configuration.getInstance(); - + String url = "jdbc:postgresql://" + configuration.getPgHost() + ":" + configuration.getPgPort() + "/sonhms"; - - return DataSourceBuilder - .create() - .url(url) - .username(configuration.getPgUsername()) - .password(configuration.getPgPassword()) - .build(); + + return DataSourceBuilder.create().url(url).username(configuration.getPgUsername()) + .password(configuration.getPgPassword()).build(); } } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/BufferNotificationComponent.java b/src/main/java/org/onap/dcaegen2/services/sonhms/BufferNotificationComponent.java index d1297b4..ce2b4bc 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/BufferNotificationComponent.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/BufferNotificationComponent.java @@ -40,7 +40,7 @@ public class BufferNotificationComponent { .getBean(BufferedNotificationsRepository.class); bufferedNotificationsRepository.save(bufferedNotifications); - } + } /** * Retrieves buffered notification from the database. diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/CommonEventHeader.java b/src/main/java/org/onap/dcaegen2/services/sonhms/CommonEventHeader.java new file mode 100644 index 0000000..013dc66 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/CommonEventHeader.java @@ -0,0 +1,182 @@ +/******************************************************************************* + * ============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; + +public class CommonEventHeader { + + private String version; + private String vesEventListenerVersion; + private String domain; + private String eventName; + private String eventId; + private int sequence; + private String priority; + private String reportingEntityId; + private String reportingEntityName; + private String sourceId; + private String sourceName; + private long startEpochMicrosec; + private long lastEpochMicrosec; + private String timeZoneOffset; + private String nfNamingCode; + private String nfVendorName; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getVesEventListenerVersion() { + return vesEventListenerVersion; + } + + public void setVesEventListenerVersion(String vesEventListenerVersion) { + this.vesEventListenerVersion = vesEventListenerVersion; + } + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public String getEventName() { + return eventName; + } + + public void setEventName(String eventName) { + this.eventName = eventName; + } + + public String getEventId() { + return eventId; + } + + public void setEventId(String eventId) { + this.eventId = eventId; + } + + public int getSequence() { + return sequence; + } + + public void setSequence(int sequence) { + this.sequence = sequence; + } + + public String getPriority() { + return priority; + } + + public void setPriority(String priority) { + this.priority = priority; + } + + public String getReportingEntityId() { + return reportingEntityId; + } + + public void setReportingEntityId(String reportingEntityId) { + this.reportingEntityId = reportingEntityId; + } + + public String getReportingEntityName() { + return reportingEntityName; + } + + public void setReportingEntityName(String reportingEntityName) { + this.reportingEntityName = reportingEntityName; + } + + public String getSourceId() { + return sourceId; + } + + public void setSourceId(String sourceId) { + this.sourceId = sourceId; + } + + public String getSourceName() { + return sourceName; + } + + public void setSourceName(String sourceName) { + this.sourceName = sourceName; + } + + public long getStartEpochMicrosec() { + return startEpochMicrosec; + } + + public void setStartEpochMicrosec(long startEpochMicrosec) { + this.startEpochMicrosec = startEpochMicrosec; + } + + public long getLastEpochMicrosec() { + return lastEpochMicrosec; + } + + public void setLastEpochMicrosec(long lastEpochMicrosec) { + this.lastEpochMicrosec = lastEpochMicrosec; + } + + public String getTimeZoneOffset() { + return timeZoneOffset; + } + + public void setTimeZoneOffset(String timeZoneOffset) { + this.timeZoneOffset = timeZoneOffset; + } + + public String getNfNamingCode() { + return nfNamingCode; + } + + public void setNfNamingCode(String nfNamingCode) { + this.nfNamingCode = nfNamingCode; + } + + public String getNfVendorName() { + return nfVendorName; + } + + public void setNfVendorName(String nfVendorName) { + this.nfVendorName = nfVendorName; + } + + @Override + public String toString() { + return "CommonEventHeader [version=" + version + ", vesEventListenerVersion=" + vesEventListenerVersion + + ", domain=" + domain + ", eventName=" + eventName + ", eventId=" + eventId + ", sequence=" + sequence + + ", priority=" + priority + ", reportingEntityId=" + reportingEntityId + ", reportingEntityName=" + + reportingEntityName + ", sourceId=" + sourceId + ", sourceName=" + sourceName + + ", startEpochMicrosec=" + startEpochMicrosec + ", lastEpochMicrosec=" + lastEpochMicrosec + + ", timeZoneOffset=" + timeZoneOffset + ", nfNamingCode=" + nfNamingCode + ", nfVendorName=" + + nfVendorName + "]"; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java b/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java index 1126102..a0dc6c5 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java @@ -45,63 +45,71 @@ public class Configuration { private List optimizers; private int numSolutions; private int bufferTime; - private int maximumClusters; + private int maximumClusters; private String aafUsername; private String aafPassword; - private Map streamsSubscribes; - private Map streamsPublishes; + private Map streamsSubscribes; + private Map streamsPublishes; + private int badThreshold; + private int poorThreshold; - public boolean isSecured() { - if(aafUsername.equals("")||aafUsername==null){ - return false; - } - else - return true; - } - - - - public String getAafUsername() { - return aafUsername; - } - - - - public void setAafUsername(String aafUsername) { - this.aafUsername = aafUsername; - } + public int getBadThreshold() { + return badThreshold; + } + public void setBadThreshold(int badThreshold) { + this.badThreshold = badThreshold; + } + public int getPoorThreshold() { + return poorThreshold; + } - public String getAafPassword() { - return aafPassword; - } + public void setPoorThreshold(int poorThreshold) { + this.poorThreshold = poorThreshold; + } + /** + * Check if topic is secure. + */ + public boolean isSecured() { + return (aafUsername != null); + + } + public String getAafUsername() { + return aafUsername; + } - public void setAafPassword(String aafPassword) { - this.aafPassword = aafPassword; - } + public void setAafUsername(String aafUsername) { + this.aafUsername = aafUsername; + } + public String getAafPassword() { + return aafPassword; + } + public void setAafPassword(String aafPassword) { + this.aafPassword = aafPassword; + } - public Map getStreamsSubscribes() { - return streamsSubscribes; - } + public Map getStreamsSubscribes() { + return streamsSubscribes; + } - public void setStreamsSubscribes(Map streamsSubscribes) { - this.streamsSubscribes = streamsSubscribes; - } + public void setStreamsSubscribes(Map streamsSubscribes) { + this.streamsSubscribes = streamsSubscribes; + } - public Map getStreamsPublishes() { - return streamsPublishes; - } + public Map getStreamsPublishes() { + return streamsPublishes; + } - public void setStreamsPublishes(Map streamsPublishes) { - this.streamsPublishes = streamsPublishes; - } + public void setStreamsPublishes(Map streamsPublishes) { + this.streamsPublishes = streamsPublishes; + } - public int getMaximumClusters() { + public int getMaximumClusters() { return maximumClusters; } @@ -187,7 +195,7 @@ public class Configuration { this.sourceId = sourceId; } - public String getCallbackUrl() { + public String getCallbackUrl() { return callbackUrl; } @@ -250,39 +258,33 @@ public class Configuration { public void setPgPassword(String pgPassword) { this.pgPassword = pgPassword; } - - public List getDmaapServers() { - return dmaapServers; - } - - public void setDmaapServers(List dmaapServers) { - this.dmaapServers = dmaapServers; - } - - public String getConfigDbService() { - return configDbService; - } - - public void setConfigDbService(String configDbService) { - this.configDbService = configDbService; - } + public List getDmaapServers() { + return dmaapServers; + } + public void setDmaapServers(List dmaapServers) { + this.dmaapServers = dmaapServers; + } - @Override - public String toString() { - return "Configuration [pgHost=" + pgHost + ", pgPort=" + pgPort + ", pgUsername=" + pgUsername + ", pgPassword=" - + pgPassword + ", dmaapServers=" + dmaapServers + ", configDbService=" + configDbService + ", oofService=" - + oofService + ", cg=" + cg + ", cid=" + cid + ", pollingInterval=" + pollingInterval - + ", pollingTimeout=" + pollingTimeout + ", minCollision=" + minCollision + ", minConfusion=" - + minConfusion + ", sourceId=" + sourceId + ", callbackUrl=" + callbackUrl + ", optimizers=" - + optimizers + ", numSolutions=" + numSolutions + ", bufferTime=" + bufferTime + ", maximumClusters=" - + maximumClusters + ", aafUsername=" + aafUsername + ", aafPassword=" + aafPassword - + ", streamsSubscribes=" + streamsSubscribes + ", streamsPublishes=" + streamsPublishes + "]"; - } + public String getConfigDbService() { + return configDbService; + } - + public void setConfigDbService(String configDbService) { + this.configDbService = configDbService; + } + @Override + public String toString() { + return "Configuration [pgHost=" + pgHost + ", pgPort=" + pgPort + ", pgUsername=" + pgUsername + ", pgPassword=" + + pgPassword + ", dmaapServers=" + dmaapServers + ", configDbService=" + configDbService + + ", oofService=" + oofService + ", cg=" + cg + ", cid=" + cid + ", pollingInterval=" + pollingInterval + + ", pollingTimeout=" + pollingTimeout + ", minCollision=" + minCollision + ", minConfusion=" + + minConfusion + ", sourceId=" + sourceId + ", callbackUrl=" + callbackUrl + ", optimizers=" + + optimizers + ", numSolutions=" + numSolutions + ", bufferTime=" + bufferTime + ", maximumClusters=" + + maximumClusters + ", aafUsername=" + aafUsername + ", aafPassword=" + aafPassword + + ", streamsSubscribes=" + streamsSubscribes + ", streamsPublishes=" + streamsPublishes + "]"; + } - } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/DmaapNotificationsComponent.java b/src/main/java/org/onap/dcaegen2/services/sonhms/DmaapNotificationsComponent.java index f2c444c..39cfbd1 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/DmaapNotificationsComponent.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/DmaapNotificationsComponent.java @@ -26,9 +26,10 @@ import com.fasterxml.jackson.databind.ObjectMapper; import fj.data.Either; import java.io.IOException; - 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.utils.BeanUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -38,12 +39,15 @@ public class DmaapNotificationsComponent { private static Logger log = LoggerFactory.getLogger(DmaapNotificationsComponent.class); /** - * Get dmaap notifications. + * Get sdnr notifications */ - public Either getDmaapNotifications() { + public Either getSdnrNotifications() { DmaapNotificationsRepository dmaapNotificationsRepository = BeanUtil .getBean(DmaapNotificationsRepository.class); String notificationString = dmaapNotificationsRepository.getNotificationFromQueue(); + if (notificationString == null) { + return Either.right(404); + } ObjectMapper mapper = new ObjectMapper(); Notification notification = new Notification(); @@ -55,5 +59,26 @@ public class DmaapNotificationsComponent { return Either.right(400); } } + + /** + * Get pm notifications + */ + public Either 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(); + + try { + pmNotification = mapper.readValue(pmNotificationString, PMNotification.class); + return Either.left(pmNotification); + } catch(IOException e) { + log.error("Exception in parsing pm notification ",pmNotificationString,e); + return Either.right(400); + } + } } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/Event.java b/src/main/java/org/onap/dcaegen2/services/sonhms/Event.java new file mode 100644 index 0000000..84b8eee --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/Event.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * ============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; + +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; + } + @Override + public String toString() { + return "Event [commonEventHeader=" + commonEventHeader + ", faultFields=" + faultFields + "]"; + } + + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/EventHandler.java b/src/main/java/org/onap/dcaegen2/services/sonhms/EventHandler.java index df24aa8..a25fe0e 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/EventHandler.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/EventHandler.java @@ -25,9 +25,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import fj.data.Either; -import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -39,7 +39,10 @@ import org.onap.dcaegen2.services.sonhms.child.ChildThread; import org.onap.dcaegen2.services.sonhms.child.Graph; import org.onap.dcaegen2.services.sonhms.entity.ClusterDetails; import org.onap.dcaegen2.services.sonhms.exceptions.ConfigDbNotFoundException; +import org.onap.dcaegen2.services.sonhms.model.CellPciPair; +import org.onap.dcaegen2.services.sonhms.model.ClusterMap; import org.onap.dcaegen2.services.sonhms.model.FapServiceList; +import org.onap.dcaegen2.services.sonhms.model.LteNeighborListInUseLteCell; import org.onap.dcaegen2.services.sonhms.model.Notification; import org.onap.dcaegen2.services.sonhms.utils.ClusterUtils; import org.onap.dcaegen2.services.sonhms.utils.ThreadUtils; @@ -59,7 +62,7 @@ public class EventHandler { private ExecutorService pool; private ClusterUtils clusterUtils; - + private ThreadUtils threadUtils; /** @@ -75,16 +78,153 @@ public class EventHandler { this.threadUtils = threadUtils; } + /** + * Handles fault notifications. + */ + public Boolean handleFaultNotification(List fmNotification) { + + log.info("Handling Fault notification"); + log.info("fm notification {}", fmNotification); + + Set cellIds = new HashSet<>(); + List clusterDetails = clusterUtils.getAllClusters(); + String networkId = ""; + Map> collisionConfusionMap = new HashMap<>(); + + for (FaultEvent faultEvent : fmNotification) { + String cellId = faultEvent.getEvent().getCommonEventHeader().getSourceName(); + cellIds.add(cellId); + networkId = faultEvent.getEvent().getFaultFields().getAlarmAdditionalInformation().getNetworkId(); + ArrayList counts = new ArrayList<>(); + counts.add(faultEvent.getEvent().getFaultFields().getAlarmAdditionalInformation().getCollisions()); + counts.add(faultEvent.getEvent().getFaultFields().getAlarmAdditionalInformation().getConfusions()); + collisionConfusionMap.put(cellId, counts); + } + FaultNotificationtoClusterMapping faultNotificationtoClusterMapping = clusterUtils + .getClustersForFmNotification(cellIds, clusterDetails); + + faultNotificationtoClusterMapping.setCollisionConfusionMap(collisionConfusionMap); + // matching cells + if (faultNotificationtoClusterMapping.getCellsinCluster() != null && !faultNotificationtoClusterMapping.getCellsinCluster().isEmpty()) { + try { + handleMatchedFmCells(faultNotificationtoClusterMapping, clusterDetails); + } catch (ConfigDbNotFoundException e) { + log.error("Config DB Exception {}", e); + } + + } + // unmatched new cells + if (faultNotificationtoClusterMapping.getNewCells() != null && !faultNotificationtoClusterMapping.getNewCells().isEmpty()) { + handleUnmatchedFmCells(faultNotificationtoClusterMapping, networkId); + + } + + return true; + } + + /** + * handle matched fm cells. + * + */ + private void handleMatchedFmCells(FaultNotificationtoClusterMapping faultNotificationtoClusterMapping, + List clusterDetails) throws ConfigDbNotFoundException { + Map cellsinCluster = faultNotificationtoClusterMapping.getCellsinCluster(); + log.info("Handling Matching cells for FM notification"); + + for (Entry entry : cellsinCluster.entrySet()) { + + String cellId = entry.getKey(); + String clusterId = entry.getValue(); + Map> clusterMap = clusterUtils.findClusterMap(cellId); + + Either clusterDetail = clusterUtils.getClusterDetailsFromClusterId(clusterId, + clusterDetails); + + if (clusterDetail.isRight()) { + log.error("Cannot find the cluster for Cluster ID"); + return; + } else { + long threadId = clusterDetail.left().value().getChildThreadId(); + + if (childStatus.get(threadId).equals("triggeredOof")) { + log.info("OOF triggered for the cluster, buffering notification"); + bufferNotification(clusterMap, clusterId); + } else { + childThreadMap.get(threadId).putInQueue(clusterMap); + } + } + } + + } + + /** + * handle unmatched fm cells. + * + * @param networkId2 + * @param faultNotificationtoClusterMapping + */ + private void handleUnmatchedFmCells(FaultNotificationtoClusterMapping faultNotificationtoClusterMapping, + String networkId) { + List newCells = faultNotificationtoClusterMapping.getNewCells(); + log.info("Handle Unmatching cells for FM notificatins newCells{}", newCells); + List newClusters = new ArrayList<>(); + + for (String cellId : newCells) { + ArrayList collisionConfusionCount = faultNotificationtoClusterMapping.getCollisionConfusionMap() + .get(cellId); + log.info("Handle Unmatching cells for FM notificatins,collisionConfusionCount{}", collisionConfusionCount); + + Either existingCluster = clusterUtils.getClusterForFMCell(cellId, newClusters); + if (existingCluster.isRight()) { + try { + Map> clusterMap = clusterUtils.findClusterMap(cellId); + Graph cluster = clusterUtils.createCluster(clusterMap); + cluster.setNetworkId(networkId); + Map> collisionConfusionMap = new HashMap<>(); + collisionConfusionMap.put(cellId, collisionConfusionCount); + cluster.setCollisionConfusionMap(collisionConfusionMap); + + newClusters.add(cluster); + } catch (ConfigDbNotFoundException e) { + log.error("Error connecting with configDB {}", e); + } + } + + else { + Graph cluster = existingCluster.left().value(); + + Graph modifiedCluster = null; + try { + modifiedCluster = clusterUtils.modifyCluster(cluster, clusterUtils.findClusterMap(cellId)); + Map> collisionConfusionMap = cluster.getCollisionConfusionMap(); + collisionConfusionMap.put(cellId, collisionConfusionCount); + cluster.setCollisionConfusionMap(collisionConfusionMap); + } catch (ConfigDbNotFoundException e) { + log.error("Config DB not found {}", e); + } + newClusters.remove(cluster); + newClusters.add(modifiedCluster); + } + + } + + // create new child thread + log.info("New clusters {}", newClusters); + + threadUtils.createNewThread(newClusters, childStatusQueue, pool, this, null); + + } + /** * handle sdnr notification. */ public Boolean handleSdnrNotification(Notification notification) { // Check if notification matches with a cluster - + log.info("Handling SDNR notification"); try { List clusterDetails = clusterUtils.getAllClusters(); - NotificationToClusterMapping mapping = clusterUtils.getClustersForNotification(notification, + NotificationToClusterMapping mapping = clusterUtils.getClustersForNotification(notification, clusterDetails); // Matching cells @@ -105,15 +245,22 @@ public class EventHandler { } - private void handleUnMatchingCells(List newCells) { + private void handleUnMatchingCells(List newCells) throws ConfigDbNotFoundException { + + log.info("handling unmatched cells"); + List newClusters = new ArrayList<>(); for (FapServiceList fapService : newCells) { + Map> clusterMap = clusterUtils.findClusterMap(fapService.getAlias()); Either existingCluster = clusterUtils.getClusterForCell(fapService, newClusters); if (existingCluster.isRight()) { try { - Graph cluster = clusterUtils.createCluster(fapService); + Graph cluster = clusterUtils.createCluster(clusterMap); + cluster.setNetworkId(fapService.getCellConfig().getLte().getRan().getNeighborListInUse() + .getLteNeighborListInUseLteCell().get(0).getPlmnid()); + cluster.setCollisionConfusionMap(new HashMap<>()); newClusters.add(cluster); } catch (ConfigDbNotFoundException e) { log.error("Error connecting with configDB {}", e); @@ -122,8 +269,8 @@ public class EventHandler { else { Graph cluster = existingCluster.left().value(); - - Graph modifiedCluster = clusterUtils.modifyCluster(cluster, fapService); + Graph modifiedCluster = clusterUtils.modifyCluster(cluster, + clusterUtils.findClusterMap(fapService.getAlias())); newClusters.remove(cluster); newClusters.add(modifiedCluster); } @@ -131,16 +278,33 @@ public class EventHandler { } // create new child thread - - threadUtils.createNewThread(newClusters, childStatusQueue, pool, this); + + threadUtils.createNewThread(newClusters, childStatusQueue, pool, this, null); } - private void handleMatchingCells(Map cellsInCluster, List clusterDetails) { + private void handleMatchingCells(Map cellsInCluster, List clusterDetails) + throws ConfigDbNotFoundException { + + log.info("handling matching cells"); + for (Entry entry : cellsInCluster.entrySet()) { FapServiceList fapService = entry.getKey(); String clusterId = entry.getValue(); + String cellId = fapService.getAlias(); + int pci = fapService.getX0005b9Lte().getPhyCellIdInUse(); + ArrayList neighbours = new ArrayList<>(); + for (LteNeighborListInUseLteCell neighbour : fapService.getCellConfig().getLte().getRan() + .getNeighborListInUse().getLteNeighborListInUseLteCell()) { + String neighbourCellId = neighbour.getAlias(); + int neighbourPci = neighbour.getPhyCellId(); + neighbours.add(new CellPciPair(neighbourCellId, neighbourPci)); + + } + Map> clusterMap = new HashMap<>(); + clusterMap.put(new CellPciPair(cellId, pci), neighbours); + Either clusterDetail = clusterUtils.getClusterDetailsFromClusterId(clusterId, clusterDetails); @@ -152,23 +316,33 @@ public class EventHandler { if (childStatus.get(threadId).equals("triggeredOof")) { log.info("OOF triggered for the cluster, buffering notification"); - bufferNotification(fapService, clusterId); + + bufferNotification(clusterMap, clusterId); } else { - childThreadMap.get(threadId).putInQueue(fapService); + log.info("Forwarding notification to child thread {}", threadId); + childThreadMap.get(threadId).putInQueue(clusterMap); } } } } - private void bufferNotification(FapServiceList fapService, String clusterId) { + private void bufferNotification(Map> clusterMap, String clusterId) { + + log.info("Buffering notifications ..."); ObjectMapper mapper = new ObjectMapper(); - BufferNotificationComponent bufferNotifComponent = new BufferNotificationComponent(); String serviceListString = ""; + + ClusterMap clusterMapJson = new ClusterMap(); + + clusterMapJson.setCell(clusterMap.keySet().iterator().next()); + clusterMapJson.setNeighbourList(clusterMap.get(clusterMap.keySet().iterator().next())); + try { - serviceListString = mapper.writeValueAsString(fapService); + serviceListString = mapper.writeValueAsString(clusterMapJson); } catch (JsonProcessingException e) { - log.debug("JSON processing exception: {}", e); + log.error("JSON processing exception: {}", e); } + BufferNotificationComponent bufferNotifComponent = new BufferNotificationComponent(); bufferNotifComponent.bufferNotification(serviceListString, clusterId); } @@ -178,52 +352,19 @@ public class EventHandler { */ public void handleChildStatusUpdate(List childStatus) { - // update Child status in data structure + log.info("Handling child status update"); + Long childThreadId = Long.parseLong(childStatus.get(0)); addChildStatus(childThreadId, childStatus.get(1)); // if child status is OOF result success, handle buffered notifications - if (childStatus.get(1).equals("success")) { - BufferNotificationComponent bufferNotificationComponent = new BufferNotificationComponent(); - ClusterDetailsComponent clusterDetailsComponent = new ClusterDetailsComponent(); - String clusterId = clusterDetailsComponent.getClusterId(childThreadId); - List bufferedNotifications = bufferNotificationComponent.getBufferedNotification(clusterId); - - if (bufferedNotifications == null || bufferedNotifications.isEmpty()) { - log.info("No buffered notification for this thread"); - - Set setOfThread = Thread.getAllStackTraces().keySet(); - for (Thread thread : setOfThread) { - if (thread.getId() == childThreadId) { - deleteChildStatus(childThreadId); - thread.interrupt(); - } - } - } else { - handleBufferedNotifications(childThreadId, bufferedNotifications); - } + if (childStatus.get(1).equals("done")) { + deleteChildStatus(childThreadId); } // else kill the child thread } - private void handleBufferedNotifications(Long childThreadId, List bufferedNotifications) { - - ObjectMapper mapper = new ObjectMapper(); - for (String notification : bufferedNotifications) { - FapServiceList fapServiceList; - try { - fapServiceList = mapper.readValue(notification, FapServiceList.class); - log.debug("fapServiceList{}", fapServiceList); - - childThreadMap.get(childThreadId).putInQueueWithNotify(fapServiceList); - - } catch (IOException e) { - log.error("Error parsing the buffered notification, skipping {}", e); - } - } - } - public static void addChildThreadMap(Long childThreadId, ChildThread child) { childThreadMap.put(childThreadId, child); } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/FaultEvent.java b/src/main/java/org/onap/dcaegen2/services/sonhms/FaultEvent.java new file mode 100644 index 0000000..57f7d43 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/FaultEvent.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * ============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; + +public class FaultEvent { + + private Event event; + + public Event getEvent() { + return event; + } + + public void setEvent(Event event) { + this.event = event; + } + + @Override + public String toString() { + return "FaultEvent [event=" + event + "]"; + } + + + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/FaultFields.java b/src/main/java/org/onap/dcaegen2/services/sonhms/FaultFields.java new file mode 100644 index 0000000..462f550 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/FaultFields.java @@ -0,0 +1,99 @@ +/******************************************************************************* + * ============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; + +public class FaultFields { + + @Override + public String toString() { + return "FaultFields [faultFieldsVersion=" + faultFieldsVersion + ", alarmCondition=" + alarmCondition + + ", eventSourceType=" + eventSourceType + ", specificProblem=" + specificProblem + ", eventSeverity=" + + eventSeverity + ", vfStatus=" + vfStatus + ", alarmAdditionalInformation=" + + alarmAdditionalInformation + "]"; + } + + private int faultFieldsVersion; + private String alarmCondition; + private String eventSourceType; + private String specificProblem; + private String eventSeverity; + private String vfStatus; + private AlarmAdditionalInformation alarmAdditionalInformation; + + + public AlarmAdditionalInformation getAlarmAdditionalInformation() { + return alarmAdditionalInformation; + } + + public void setAlarmAdditionalInformation(AlarmAdditionalInformation alarmAdditionalInformation) { + this.alarmAdditionalInformation = alarmAdditionalInformation; + } + + public int getFaultFieldsVersion() { + return faultFieldsVersion; + } + + public void setFaultFieldsVersion(int faultFieldsVersion) { + this.faultFieldsVersion = faultFieldsVersion; + } + + public String getAlarmCondition() { + return alarmCondition; + } + + public void setAlarmCondition(String alarmCondition) { + this.alarmCondition = alarmCondition; + } + + public String getEventSourceType() { + return eventSourceType; + } + + public void setEventSourceType(String eventSourceType) { + this.eventSourceType = eventSourceType; + } + + public String getSpecificProblem() { + return specificProblem; + } + + public void setSpecificProblem(String specificProblem) { + this.specificProblem = specificProblem; + } + + public String getEventSeverity() { + return eventSeverity; + } + + public void setEventSeverity(String eventSeverity) { + this.eventSeverity = eventSeverity; + } + + public String getVfStatus() { + return vfStatus; + } + + public void setVfStatus(String vfStatus) { + this.vfStatus = vfStatus; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/FaultNotificationComponent.java b/src/main/java/org/onap/dcaegen2/services/sonhms/FaultNotificationComponent.java new file mode 100644 index 0000000..99695ab --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/FaultNotificationComponent.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * son-handler + * ================================================================================ + * Copyright (C) 2019 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.dcaegen2.services.sonhms; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import fj.data.Either; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import org.onap.dcaegen2.services.sonhms.dao.FaultNotificationsRepository; +import org.onap.dcaegen2.services.sonhms.utils.BeanUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class FaultNotificationComponent { + + private static Logger log = LoggerFactory.getLogger(FaultNotificationComponent.class); + + /** + * Get fault notifications. + */ + public Either,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 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); + + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/FaultNotificationtoClusterMapping.java b/src/main/java/org/onap/dcaegen2/services/sonhms/FaultNotificationtoClusterMapping.java new file mode 100644 index 0000000..5e59467 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/FaultNotificationtoClusterMapping.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * son-handler + * ================================================================================ + * Copyright (C) 2019 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.dcaegen2.services.sonhms; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class FaultNotificationtoClusterMapping { + public Map getCellsinCluster() { + return cellsinCluster; + } + + public void setCellsinCluster(Map cellsinCluster) { + this.cellsinCluster = cellsinCluster; + } + + public List getNewCells() { + return newCells; + } + + public void setNewCells(List newCells) { + this.newCells = newCells; + } + + private Map> collisionConfusionMap; + + //map that returns cellid and its matching cluster id + + public Map> getCollisionConfusionMap() { + return collisionConfusionMap; + } + + public void setCollisionConfusionMap(Map> collisionConfusionMap) { + this.collisionConfusionMap = collisionConfusionMap; + } + + private Map cellsinCluster; + + //cells that dont match + private List newCells; +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/HoMetricsComponent.java b/src/main/java/org/onap/dcaegen2/services/sonhms/HoMetricsComponent.java new file mode 100644 index 0000000..d27227f --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/HoMetricsComponent.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * son-handler + * ================================================================================ + * Copyright (C) 2019 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.dcaegen2.services.sonhms; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; + +import fj.data.Either; + +import java.util.ArrayList; +import java.util.List; + +import org.onap.dcaegen2.services.sonhms.dao.HandOverMetricsRepository; +import org.onap.dcaegen2.services.sonhms.model.HoDetails; +import org.onap.dcaegen2.services.sonhms.utils.BeanUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class HoMetricsComponent { + + private static Logger log = LoggerFactory.getLogger(HoMetricsComponent.class); + + /** + * Get HO metrics. + */ + + public Either, Integer> getHoMetrics(String srcCellId) { + HandOverMetricsRepository handOverMetricsRepository = BeanUtil.getBean(HandOverMetricsRepository.class); + String hoDetailsString = handOverMetricsRepository.getHandOverMetrics(srcCellId); + if (hoDetailsString != null) { + ObjectMapper mapper = new ObjectMapper(); + List hoDetails = new ArrayList<>(); + try { + hoDetails = mapper.readValue(hoDetailsString, new TypeReference>() { + }); + return Either.left(hoDetails); + } catch (Exception e) { + log.error("Exception in parsing HO metrics", hoDetailsString, e); + return Either.right(400); + } + } else + return Either.right(404); + } +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/MainThread.java b/src/main/java/org/onap/dcaegen2/services/sonhms/MainThread.java index 84775ad..6cbb711 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/MainThread.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/MainThread.java @@ -23,12 +23,16 @@ package org.onap.dcaegen2.services.sonhms; import fj.data.Either; +import java.sql.Timestamp; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.concurrent.BlockingQueue; import java.util.concurrent.Executors; import java.util.concurrent.LinkedBlockingQueue; +import org.onap.dcaegen2.services.sonhms.model.FapServiceList; import org.onap.dcaegen2.services.sonhms.model.Notification; import org.onap.dcaegen2.services.sonhms.utils.ClusterUtils; import org.onap.dcaegen2.services.sonhms.utils.ThreadUtils; @@ -36,37 +40,81 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class MainThread implements Runnable { + private static Logger log = LoggerFactory.getLogger(MainThread.class); - private NewNotification newNotification; + private NewSdnrNotification newNotification; + + private NewFmNotification newFmNotification; private BlockingQueue> childStatusQueue; - + private DmaapNotificationsComponent dmaapNotificationsComponent; - + + private FaultNotificationComponent faultNotificationComponent; + private EventHandler eventHandler; - + + private Map bufferedFMNotificationCells; + + private List sdnrNotificationCells; + + private Boolean isTimer; + + private Timestamp startTimer; + + List fmNotificationToBuffer; + /** * parameterized constructor. */ - public MainThread(NewNotification newNotification) { - super(); + public MainThread(NewSdnrNotification newNotification, NewFmNotification newFmNotification) { + super(); + this.newFmNotification = newFmNotification; this.newNotification = newNotification; childStatusQueue = new LinkedBlockingQueue<>(); dmaapNotificationsComponent = new DmaapNotificationsComponent(); - eventHandler = new EventHandler(childStatusQueue, - Executors.newFixedThreadPool(Configuration.getInstance().getMaximumClusters()), - new HashMap<>(), new ClusterUtils(), new ThreadUtils()); - } - + faultNotificationComponent = new FaultNotificationComponent(); + sdnrNotificationCells = new ArrayList<>(); + fmNotificationToBuffer = new ArrayList<>(); + bufferedFMNotificationCells = new HashMap<>(); + eventHandler = new EventHandler(childStatusQueue, + Executors.newFixedThreadPool(Configuration.getInstance().getMaximumClusters()), new HashMap<>(), + new ClusterUtils(), new ThreadUtils()); + isTimer = false; + startTimer = new Timestamp(System.currentTimeMillis()); + + } + @Override public void run() { log.info("Starting Main Thread"); // Check for Notifications from Dmaap and Child thread - Boolean done = false; - + Boolean done = false; + while (!done) { + + Timestamp currentTime = new Timestamp(System.currentTimeMillis()); + if (isTimer) { + Long difference = currentTime.getTime() - startTimer.getTime(); + if (difference > 5000) { + log.info("FM handling difference > 5000"); + + for (String sdnrCell: sdnrNotificationCells) { + bufferedFMNotificationCells.remove(sdnrCell); + } + + log.info("FM bufferedFMNotificationCells {}", bufferedFMNotificationCells.values()); + List fmNotificationsToHandle = new ArrayList<>( + bufferedFMNotificationCells.values()); + Boolean result = eventHandler.handleFaultNotification(fmNotificationsToHandle); + bufferedFMNotificationCells = new HashMap<>(); + isTimer = false; + log.info("FM notification handling {}", result); + } + } + try { if (!childStatusQueue.isEmpty()) { List childState = childStatusQueue.poll(); @@ -76,12 +124,57 @@ public class MainThread implements Runnable { } if (newNotification.getNewNotif()) { - Either notification = dmaapNotificationsComponent.getDmaapNotifications(); + Either notification = dmaapNotificationsComponent.getSdnrNotifications(); if (notification.isRight()) { - log.error("Error parsing the notification from SDNR"); + if (notification.right().value() == 400) { + log.error("Error parsing the notification from SDNR"); + } else if (notification.right().value() == 404) { + newNotification.setNewNotif(false); + } } else if (notification.isLeft()) { + List fapServiceLists = (notification.left().value()).getPayload() + .getRadioAccess().getFapServiceList(); + for (FapServiceList fapServiceList : fapServiceLists) { + sdnrNotificationCells.add(fapServiceList.getAlias()); + + } + Boolean result = eventHandler.handleSdnrNotification(notification.left().value()); log.debug("SDNR notification handling {}", result); + + } + + } + if (newFmNotification.getNewNotif()) { + log.info("newFmNotification has come"); + + String faultCellId = ""; + Either, Integer> fmNotifications = faultNotificationComponent + .getFaultNotifications(); + if (fmNotifications.isRight()) { + if (fmNotifications.right().value() == 400) { + log.info("Error parsing notifications"); + } else if (fmNotifications.right().value() == 404) { + newFmNotification.setNewNotif(false); + } + } else { + for (FaultEvent fmNotification : fmNotifications.left().value()) { + faultCellId = fmNotification.getEvent().getCommonEventHeader().getSourceName(); + bufferedFMNotificationCells.put(faultCellId, fmNotification); + log.info("Buffered FM cell {}", faultCellId); + log.info("fmNotification{}", fmNotification); + + } + log.info("bufferedFMNotificationCells before staring timer {}", + bufferedFMNotificationCells.keySet()); + + for (String sdnrCell: sdnrNotificationCells) { + bufferedFMNotificationCells.remove(sdnrCell); + } + + startTimer = new Timestamp(System.currentTimeMillis()); + isTimer = true; + log.info("Buffered FM cell {}", bufferedFMNotificationCells.keySet()); } } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/MainThreadComponent.java b/src/main/java/org/onap/dcaegen2/services/sonhms/MainThreadComponent.java index 1b4ff26..606f420 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/MainThreadComponent.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/MainThreadComponent.java @@ -34,7 +34,13 @@ public class MainThreadComponent { private static Logger log = LoggerFactory.getLogger(MainThreadComponent.class); @Autowired - private NewNotification newNotification; + private NewSdnrNotification newNotification; + + @Autowired + private NewPmNotification newPmNotification; + + @Autowired + private NewFmNotification newFmNotification; /** * main thread initialization. @@ -42,7 +48,9 @@ public class MainThreadComponent { @PostConstruct public void init() { log.debug("initializing main thread"); - Thread thread = new Thread(new MainThread(newNotification)); + Thread thread = new Thread(new MainThread(newNotification, newFmNotification)); thread.start(); + Thread pmThread = new Thread(new PMThread(newPmNotification)); + pmThread.start(); } } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/NewNotification.java b/src/main/java/org/onap/dcaegen2/services/sonhms/NewFmNotification.java similarity index 87% rename from src/main/java/org/onap/dcaegen2/services/sonhms/NewNotification.java rename to src/main/java/org/onap/dcaegen2/services/sonhms/NewFmNotification.java index 703204b..fa71c4f 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/NewNotification.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/NewFmNotification.java @@ -21,13 +21,19 @@ package org.onap.dcaegen2.services.sonhms; +import javax.annotation.PostConstruct; + import org.springframework.stereotype.Component; @Component -public class NewNotification { - +public class NewFmNotification { private Boolean newNotif; + @PostConstruct + void init() { + newNotif = false; + } + public Boolean getNewNotif() { return newNotif; } @@ -36,13 +42,12 @@ public class NewNotification { this.newNotif = newNotif; } - public NewNotification(Boolean newNotif) { + public NewFmNotification(Boolean newNotif) { super(); this.newNotif = newNotif; } - - public NewNotification() { - - } + public NewFmNotification() { + + } } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/NewPmNotification.java b/src/main/java/org/onap/dcaegen2/services/sonhms/NewPmNotification.java new file mode 100644 index 0000000..ce583dd --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/NewPmNotification.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * son-handler + * ================================================================================ + * Copyright (C) 2019 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.dcaegen2.services.sonhms; + +import javax.annotation.PostConstruct; + +import org.springframework.stereotype.Component; + +@Component +public class NewPmNotification { + + private Boolean newNotif; + + @PostConstruct + public void init() { + newNotif=false; + } + + public Boolean getNewNotif() { + return newNotif; + } + + public void setNewNotif(Boolean newNotif) { + this.newNotif = newNotif; + } + + public NewPmNotification(Boolean newNotif) { + super(); + this.newNotif = newNotif; + } + + public NewPmNotification() { + + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/NewSdnrNotification.java b/src/main/java/org/onap/dcaegen2/services/sonhms/NewSdnrNotification.java new file mode 100644 index 0000000..127b559 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/NewSdnrNotification.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * son-handler + * ================================================================================ + * Copyright (C) 2019 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.dcaegen2.services.sonhms; + +import javax.annotation.PostConstruct; + +import org.springframework.stereotype.Component; + +@Component +public class NewSdnrNotification { + + private Boolean newNotif; + + @PostConstruct + void init() { + newNotif = false; + } + + public Boolean getNewNotif() { + return newNotif; + } + + public void setNewNotif(Boolean newNotif) { + this.newNotif = newNotif; + } + + public NewSdnrNotification(Boolean newNotif) { + super(); + this.newNotif = newNotif; + } + + public NewSdnrNotification() { + + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/PMNotificationHandler.java b/src/main/java/org/onap/dcaegen2/services/sonhms/PMNotificationHandler.java new file mode 100644 index 0000000..0482b83 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/PMNotificationHandler.java @@ -0,0 +1,171 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * pcims + * ================================================================================ + * 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========================================================= + ******************************************************************************/ + +package org.onap.dcaegen2.services.sonhms; + +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.util.ArrayList; +import java.util.List; +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.AdditionalMeasurements; +import org.onap.dcaegen2.services.sonhms.model.CellConfig; +import org.onap.dcaegen2.services.sonhms.model.Common; +import org.onap.dcaegen2.services.sonhms.model.Configurations; +import org.onap.dcaegen2.services.sonhms.model.Data; +import org.onap.dcaegen2.services.sonhms.model.FapService; +import org.onap.dcaegen2.services.sonhms.model.HoDetails; +import org.onap.dcaegen2.services.sonhms.model.Lte; +import org.onap.dcaegen2.services.sonhms.model.LteCell; +import org.onap.dcaegen2.services.sonhms.model.NeighborListInUse; +import org.onap.dcaegen2.services.sonhms.model.PMNotification; +import org.onap.dcaegen2.services.sonhms.model.Payload; +import org.onap.dcaegen2.services.sonhms.model.Ran; +import org.onap.dcaegen2.services.sonhms.utils.BeanUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class PMNotificationHandler { + + private static Logger log = LoggerFactory.getLogger(DmaapNotificationsComponent.class); + PolicyDmaapClient policyDmaapClient; + + public PMNotificationHandler() { + + } + + public PMNotificationHandler(PolicyDmaapClient policyDmaapClient) { + this.policyDmaapClient = policyDmaapClient; + } + + /** + * handle pm notifications. + */ + public Boolean handlePmNotifications(PMNotification pmNotification, int badThreshold) { + HandOverMetricsRepository handOverMetricsRepository = BeanUtil.getBean(HandOverMetricsRepository.class); + Boolean result; + try { + List hoDetailsList = new ArrayList<>(); + List lteCellList = new ArrayList<>(); + String srcCellId = pmNotification.getEvent().getCommonEventHeader().getSourceName(); + for (AdditionalMeasurements additionalMeasurements : pmNotification.getEvent().getMeasurement() + .getAdditionalMeasurements()) { + int attemptsCount = Integer + .parseInt(additionalMeasurements.getArrayOfNamedHashMap().get(1).get("InterEnbOutAtt_X2HO")); + int successCount = Integer + .parseInt(additionalMeasurements.getArrayOfNamedHashMap().get(2).get("InterEnbOutSucc_X2HO")); + float successRate = ((float) successCount / attemptsCount) * 100; + if (successRate >= badThreshold) { + HoDetails hoDetails = new HoDetails(); + hoDetails.setDstCellId(additionalMeasurements.getName()); + hoDetails.setAttemptsCount(attemptsCount); + hoDetails.setSuccessCount(successCount); + hoDetails.setSuccessRate(successRate); + hoDetailsList.add(hoDetails); + log.info("not bad neighbor {}",additionalMeasurements.getName()); + } else { + 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.setPnfName(pmNotification.getEvent().getCommonEventHeader().getReportingEntityName()); + lteCellList.add(lteCell); + } + } + if (!lteCellList.isEmpty()) { + log.info("triggering policy to remove bad neighbors"); + result = sendAnrUpdateToPolicy(pmNotification, lteCellList); + log.info("Sent ANR update to policy {}", result); + String hoDetailsString = handOverMetricsRepository.getHandOverMetrics(srcCellId); + if (hoDetailsString != null) { + ObjectMapper mapper = new ObjectMapper(); + String newHoDetailsString = null; + try { + newHoDetailsString = mapper.writeValueAsString(hoDetailsList); + } catch (Exception e) { + log.error("Error in writing handover metrics json ", e); + return false; + } + handOverMetricsRepository.updateHoMetrics(newHoDetailsString, srcCellId); + } + } + if (!hoDetailsList.isEmpty()) { + result = saveToHandOverMetrics(hoDetailsList, srcCellId); + log.debug("save HO metrics result {} ", result); + + } + + } catch (Exception e) { + log.error("Error in handlePmNotifications ", e); + return false; + } + return true; + + } + + private Boolean sendAnrUpdateToPolicy(PMNotification pmNotification, List lteCellList) { + ObjectMapper mapper = new ObjectMapper(); + try { + mapper.setSerializationInclusion(Include.NON_NULL); + ArrayList 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())))))))); + configurations.add(configuration); + Payload payload = new Payload(configurations); + log.info("payload : {}", payload); + String anrUpdateString = mapper.writeValueAsString(payload); + + 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; + } + return true; + } + + private Boolean saveToHandOverMetrics(List hoDetailsList, String srcCellId) { + HandOverMetricsRepository handOverMetricsRepository = BeanUtil.getBean(HandOverMetricsRepository.class); + ObjectMapper mapper = new ObjectMapper(); + String hoDetailsString = null; + try { + hoDetailsString = mapper.writeValueAsString(hoDetailsList); + } catch (Exception e) { + log.error("Error in writing handover metrics json ", e); + return false; + } + + if (handOverMetricsRepository.getHandOverMetrics(srcCellId) == null) { + HandOverMetrics handOverMetrics = new HandOverMetrics(); + handOverMetrics.setHoDetails(hoDetailsString); + handOverMetrics.setSrcCellId(srcCellId); + handOverMetricsRepository.save(handOverMetrics); + } + else { + handOverMetricsRepository.updateHoMetrics(hoDetailsString, srcCellId); + } + return true; + } +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/PMThread.java b/src/main/java/org/onap/dcaegen2/services/sonhms/PMThread.java new file mode 100644 index 0000000..608e61f --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/PMThread.java @@ -0,0 +1,85 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * son-handler + * ================================================================================ + * Copyright (C) 2019 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.dcaegen2.services.sonhms; + +import fj.data.Either; + +import org.onap.dcaegen2.services.sonhms.dmaap.PolicyDmaapClient; +import org.onap.dcaegen2.services.sonhms.model.PMNotification; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class PMThread implements Runnable { + + private static Logger log = LoggerFactory.getLogger(PMThread.class); + + private NewPmNotification newPmNotification; + + private DmaapNotificationsComponent dmaapNotificationsComponent; + + private PMNotificationHandler pmNotificationHandler; + + /** + * parameterized constructor. + */ + public PMThread(NewPmNotification newPmNotification) { + super(); + this.newPmNotification = newPmNotification; + dmaapNotificationsComponent = new DmaapNotificationsComponent(); + pmNotificationHandler = new PMNotificationHandler(new PolicyDmaapClient()); + } + + @Override + public void run() { + log.info("PM thread starting ..."); + // check for PM notifications + Boolean done = false; + while (!done) { + try { + Thread.sleep(1000); + if (newPmNotification.getNewNotif()) { + log.info("New PM notification from Dmaap"); + Either pmNotification = dmaapNotificationsComponent.getPmNotifications(); + if (pmNotification.isRight()) { + if (pmNotification.right().value() == 400) { + log.error("error parsing pm notifications"); + } else if (pmNotification.right().value() == 404) { + log.info("Queue is empty"); + newPmNotification.setNewNotif(false); + } + } else if (pmNotification.isLeft()) { + Configuration configuration = Configuration.getInstance(); + Boolean result = pmNotificationHandler.handlePmNotifications(pmNotification.left().value(), + configuration.getBadThreshold()); + log.info("pm notification handler result {}", result); + } + + } + } catch (Exception e) { + log.error("Exception in PM Thread ", e); + done = true; + } + } + + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThread.java b/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThread.java index d12092b..5348e7d 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThread.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThread.java @@ -21,18 +21,35 @@ package org.onap.dcaegen2.services.sonhms.child; +import com.fasterxml.jackson.databind.ObjectMapper; + +import fj.data.Either; + +import java.io.IOException; import java.sql.Timestamp; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.UUID; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; +import org.onap.dcaegen2.services.sonhms.BufferNotificationComponent; +import org.onap.dcaegen2.services.sonhms.ClusterDetailsComponent; +import org.onap.dcaegen2.services.sonhms.ConfigPolicy; import org.onap.dcaegen2.services.sonhms.Configuration; +import org.onap.dcaegen2.services.sonhms.HoMetricsComponent; import org.onap.dcaegen2.services.sonhms.dao.ClusterDetailsRepository; -import org.onap.dcaegen2.services.sonhms.model.FapServiceList; +import org.onap.dcaegen2.services.sonhms.dao.SonRequestsRepository; +import org.onap.dcaegen2.services.sonhms.dmaap.PolicyDmaapClient; +import org.onap.dcaegen2.services.sonhms.exceptions.ConfigDbNotFoundException; +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.HoDetails; import org.onap.dcaegen2.services.sonhms.model.ThreadId; import org.onap.dcaegen2.services.sonhms.restclient.AsyncResponseBody; import org.onap.dcaegen2.services.sonhms.utils.BeanUtil; @@ -40,36 +57,45 @@ import org.onap.dcaegen2.services.sonhms.utils.ClusterUtils; import org.slf4j.Logger; import org.slf4j.MDC; - public class ChildThread implements Runnable { private BlockingQueue> childStatusUpdate; - private BlockingQueue queue = new LinkedBlockingQueue<>(); + private BlockingQueue>> queue = new LinkedBlockingQueue<>(); private static Map responseMap = new HashMap<>(); private Graph cluster; private ThreadId threadId; - FapServiceList fapServiceList = new FapServiceList(); + Map> clusterMap; + HoMetricsComponent hoMetricsComponent; private static final Logger log = org.slf4j.LoggerFactory.getLogger(ChildThread.class); /** * Constructor with parameters. */ public ChildThread(BlockingQueue> childStatusUpdate, Graph cluster, - BlockingQueue queue, ThreadId threadId) { + BlockingQueue>> queue, ThreadId threadId, + HoMetricsComponent hoMetricsComponent) { super(); this.childStatusUpdate = childStatusUpdate; this.queue = queue; this.threadId = threadId; this.cluster = cluster; + this.hoMetricsComponent = hoMetricsComponent; + } + + public ChildThread() { + } /** * Puts notification in queue. */ - public void putInQueue(FapServiceList fapserviceList) { + // change this interface to send cell and neighbours to keep it generic for sdnr + // and fm + + public void putInQueue(Map> clusterMap) { try { - queue.put(fapserviceList); + queue.put(clusterMap); } catch (InterruptedException e) { log.error(" The Thread is Interrupted", e); Thread.currentThread().interrupt(); @@ -79,10 +105,10 @@ public class ChildThread implements Runnable { /** * Puts notification in queue with notify. */ - public void putInQueueWithNotify(FapServiceList fapserviceList) { + public void putInQueueWithNotify(Map> clusterMap) { synchronized (queue) { try { - queue.put(fapserviceList); + queue.put(clusterMap); queue.notifyAll(); } catch (InterruptedException e) { log.error(" The Thread is Interrupted", e); @@ -98,7 +124,7 @@ public class ChildThread implements Runnable { */ public static void putResponse(Long threadId, AsyncResponseBody obj) { synchronized (responseMap) { - responseMap.put(threadId, obj); + responseMap.put(threadId, obj); } } @@ -118,50 +144,132 @@ public class ChildThread implements Runnable { MDC.put("logFileName", Thread.currentThread().getName()); log.debug("Starting child thread"); - try { - fapServiceList = queue.take(); - if (log.isDebugEnabled()) { - log.debug("fapServicelist: {}", fapServiceList); - } - } catch (InterruptedException e1) { - log.error("InterruptedException is {}", e1); - Thread.currentThread().interrupt(); - } - - ClusterFormation clusterFormation = new ClusterFormation(queue); StateOof oof = new StateOof(childStatusUpdate); ClusterUtils clusterUtils = new ClusterUtils(); Detection detect = new Detection(); + ChildThreadUtils childUtils = new ChildThreadUtils(ConfigPolicy.getInstance(), new PnfUtils(), + new PolicyDmaapClient()); try { - String networkId = fapServiceList.getCellConfig().getLte().getRan().getNeighborListInUse() - .getLteNeighborListInUseLteCell().get(0).getPlmnid(); + String networkId = cluster.getNetworkId(); Boolean done = false; + Map> collisionConfusionResult; while (!done) { + if (cluster.getCollisionConfusionMap().isEmpty()) { - Map> collisionConfusionResult = detect.detectCollisionConfusion(cluster); - Boolean trigger = clusterFormation.triggerOrWait(collisionConfusionResult); + collisionConfusionResult = detect.detectCollisionConfusion(cluster); + } else { + collisionConfusionResult = cluster.getCollisionConfusionMap(); + } + Boolean trigger = childUtils.triggerOrWait(collisionConfusionResult); + ConfigPolicy configPolicy = ConfigPolicy.getInstance(); + int timer = 60; + try { + timer = (int) configPolicy.getConfig().get("PCI_NEIGHBOR_CHANGE_CLUSTER_TIMEOUT_IN_SECS"); + } catch (NullPointerException e) { + log.info("Policy config not available. Using default timeout - 60 seconds"); + } if (!trigger) { - collisionConfusionResult = clusterFormation.waitForNotification(collisionConfusionResult, cluster); + try { + Thread.sleep((long) timer * 1000); + } catch (InterruptedException e) { + log.error("Interrupted Exception while waiting for more notifications {}", e); + Thread.currentThread().interrupt(); + } + + while (!queue.isEmpty()) { + Map> newNotification; + newNotification = queue.poll(); + log.info("New notification from SDNR {}", newNotification); + cluster = clusterUtils.modifyCluster(cluster, newNotification); + + // update cluster in DB + clusterUtils.updateCluster(cluster); + + } + collisionConfusionResult = detect.detectCollisionConfusion(cluster); + + } + ArrayList cellidList = new ArrayList<>(); + ArrayList cellIds = new ArrayList<>(); + + for (Map.Entry> entry : collisionConfusionResult.entrySet()) { + String key = entry.getKey(); + ArrayList arr; + arr = entry.getValue(); + if (!arr.isEmpty()) { + Set set = new HashSet<>(arr); + if (((set.size() == 1) && !set.contains(0)) || (set.size() != 1)) { + cellIds.add(key); + + } + } + + } + + for (String cell : cellIds) { + log.debug("cellidList entries: {}", cell); + cellidList.add(cell); + } + UUID transactionId; + Either, Integer> anrTriggerResponse = checkAnrTrigger(cellidList); + if (anrTriggerResponse.isRight()) { + if (anrTriggerResponse.right().value() == 404) + log.debug("No poor neighbors found"); + else if (anrTriggerResponse.right().value() == 500) + log.debug("Failed to fetch HO details from DB "); + transactionId = oof.triggerOof(cellidList, networkId, new ArrayList<>()); + } else { + List anrInputList = anrTriggerResponse.left().value(); + transactionId = oof.triggerOof(cellidList, networkId, anrInputList); + } + long childThreadId = Thread.currentThread().getId(); + childUtils.saveRequest(transactionId.toString(), childThreadId); + while (!ChildThread.getResponseMap().containsKey(childThreadId)) { + Thread.sleep(100); + } + + AsyncResponseBody asynResponseBody = ChildThread.getResponseMap().get(childThreadId); + + try { + childUtils.sendToPolicy(asynResponseBody); + } catch (ConfigDbNotFoundException e1) { + log.debug("Config DB is unreachable: {}", e1); + } + + SonRequestsRepository sonRequestsRepository = BeanUtil.getBean(SonRequestsRepository.class); + sonRequestsRepository.deleteByChildThreadId(childThreadId); + + List childStatus = new ArrayList<>(); + childStatus.add(Long.toString(Thread.currentThread().getId())); + childStatus.add("success"); + try { + childStatusUpdate.put(childStatus); + } catch (InterruptedException e) { + log.debug("InterruptedException during childStatus update {}", e); + Thread.currentThread().interrupt(); + } - oof.triggerOof(collisionConfusionResult, networkId); - if (isNotificationsBuffered()) { - List fapServiceLists = bufferNotification(); - for (FapServiceList fapService : fapServiceLists) { - cluster = clusterUtils.modifyCluster(cluster, fapService); + Either, Integer> bufferedNotifications = getBufferedNotifications(); + + if (bufferedNotifications.isRight()) { + log.info("No buffered notifications"); + done = true; + } else { + List>> clusterMaps = getClusterMapsFromNotifications( + bufferedNotifications.left().value()); + for (Map> bufferedClusterMap : clusterMaps) { + cluster = clusterUtils.modifyCluster(cluster, bufferedClusterMap); } String cellPciNeighbourString = cluster.getPciNeighbourJson(); UUID clusterId = cluster.getGraphId(); ClusterDetailsRepository clusterDetailsRepository = BeanUtil .getBean(ClusterDetailsRepository.class); clusterDetailsRepository.updateCluster(cellPciNeighbourString, clusterId.toString()); - - } else { - done = true; } } @@ -173,29 +281,57 @@ public class ChildThread implements Runnable { cleanup(); } - private boolean isNotificationsBuffered() { - synchronized (queue) { - + private List>> getClusterMapsFromNotifications(List notifications) { + ObjectMapper mapper = new ObjectMapper(); + List>> clusterMaps = new ArrayList<>(); + for (String notification : notifications) { + Map> clusterMap = new HashMap<>(); + ClusterMap clusterMapJson = new ClusterMap(); try { - while (queue.isEmpty()) { - queue.wait(); - } - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - return false; + clusterMapJson = mapper.readValue(notification, ClusterMap.class); + clusterMap.put(clusterMapJson.getCell(), clusterMapJson.getNeighbourList()); + + log.debug("clusterMap{}", clusterMap); + clusterMaps.add(clusterMap); + } catch (IOException e) { + log.error("Error parsing the buffered notification, skipping {}", e); } } - return true; + return clusterMaps; + } + + private Either, Integer> getBufferedNotifications() { + log.info("Check if notifications are buffered"); + BufferNotificationComponent bufferNotificationComponent = new BufferNotificationComponent(); + ClusterDetailsComponent clusterDetailsComponent = new ClusterDetailsComponent(); + String clusterId = clusterDetailsComponent.getClusterId(Thread.currentThread().getId()); + List bufferedNotifications = bufferNotificationComponent.getBufferedNotification(clusterId); + if (bufferedNotifications == null || bufferedNotifications.isEmpty()) { + return Either.right(404); + } else { + return Either.left(bufferedNotifications); + } + } /** * cleanup resources. */ private void cleanup() { - log.debug("cleaning up database and killing child thread"); + log.info("cleaning up database and killing child thread"); + List childStatus = new ArrayList<>(); + childStatus.add(Long.toString(Thread.currentThread().getId())); + childStatus.add("done"); + try { + childStatusUpdate.put(childStatus); + } catch (InterruptedException e) { + log.debug("InterruptedException during cleanup{}", e); + Thread.currentThread().interrupt(); + + } ClusterDetailsRepository clusterDetailsRepository = BeanUtil.getBean(ClusterDetailsRepository.class); clusterDetailsRepository.deleteByChildThreadId(threadId.getChildThreadId()); - log.debug("Child thread :{} {}", Thread.currentThread().getId(), "completed"); + log.info("Child thread :{} {}", Thread.currentThread().getId(), "completed"); MDC.remove("logFileName"); } @@ -203,11 +339,11 @@ public class ChildThread implements Runnable { /** * Buffer Notification. */ - public List bufferNotification() { + public List>> bufferNotification() { // Processing Buffered notifications - List fapServiceLists = new ArrayList<>(); + List>> clusterMapList = new ArrayList<>(); Configuration config = Configuration.getInstance(); @@ -234,12 +370,49 @@ public class ChildThread implements Runnable { log.debug("Timer has run for seconds {}", difference); if (!queue.isEmpty()) { - FapServiceList fapService; - fapService = queue.poll(); - fapServiceLists.add(fapService); + Map> clusterMap; + clusterMap = queue.poll(); + clusterMapList.add(clusterMap); } + } - return fapServiceLists; + return clusterMapList; } + public Either, Integer> checkAnrTrigger(List cellidList) { + + List anrInputList = new ArrayList<>(); + Configuration configuration = Configuration.getInstance(); + int poorThreshold = configuration.getPoorThreshold(); + List hoDetailsList; + Either, Integer> response; + for (String cellId : cellidList) { + response = hoMetricsComponent.getHoMetrics(cellId); + List removeableNeighbors = new ArrayList<>(); + if (response.isLeft()) { + hoDetailsList = response.left().value(); + for (HoDetails hoDetail : hoDetailsList) { + if (hoDetail.getSuccessRate() < poorThreshold) { + removeableNeighbors.add(hoDetail.getDstCellId()); + } + } + } else { + if (response.right().value() == 400) { + log.error("Error in getting HO details from db"); + return Either.right(500); + } else { + log.info("no HO metrics found"); + } + } + + if (!removeableNeighbors.isEmpty()) { + AnrInput anrInput = new AnrInput(cellId, removeableNeighbors); + anrInputList.add(anrInput); + } + } + if (!anrInputList.isEmpty()) { + return Either.left(anrInputList); + } + return Either.right(404); + } } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.java b/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.java index 89cafd6..178d728 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.java @@ -27,8 +27,15 @@ import com.fasterxml.jackson.databind.ObjectMapper; import java.util.ArrayList; import java.util.List; +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.dao.SonRequestsRepository; +import org.onap.dcaegen2.services.sonhms.dmaap.PolicyDmaapClient; +import org.onap.dcaegen2.services.sonhms.entity.SonRequests; +import org.onap.dcaegen2.services.sonhms.exceptions.ConfigDbNotFoundException; import org.onap.dcaegen2.services.sonhms.model.CellConfig; import org.onap.dcaegen2.services.sonhms.model.CellPciPair; import org.onap.dcaegen2.services.sonhms.model.Common; @@ -36,22 +43,71 @@ 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.Lte; +import org.onap.dcaegen2.services.sonhms.model.LteCell; +import org.onap.dcaegen2.services.sonhms.model.NeighborListInUse; import org.onap.dcaegen2.services.sonhms.model.Payload; 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; +import org.onap.dcaegen2.services.sonhms.utils.BeanUtil; import org.slf4j.Logger; public class ChildThreadUtils { - + private static final Logger log = org.slf4j.LoggerFactory.getLogger(ChildThreadUtils.class); - ConfigPolicy configPolicy; - - public ChildThreadUtils(ConfigPolicy configPolicy) { + private ConfigPolicy configPolicy; + private PnfUtils pnfUtils; + private PolicyDmaapClient policyDmaapClient; + + /** + * Parameterized constructor. + */ + public ChildThreadUtils(ConfigPolicy configPolicy, PnfUtils pnfUtils, PolicyDmaapClient policyDmaapClient) { this.configPolicy = configPolicy; + this.pnfUtils = pnfUtils; + this.policyDmaapClient = policyDmaapClient; } - - + + /** + * Save request. + */ + public void saveRequest(String transactionId, long childThreadId) { + SonRequestsRepository sonRequestsRepository = BeanUtil.getBean(SonRequestsRepository.class); + + SonRequests sonRequest = new SonRequests(); + sonRequest.setTransactionId(transactionId); + sonRequest.setChildThreadId(childThreadId); + sonRequestsRepository.save(sonRequest); + } + + /** + * Determines whether to trigger Oof or wait for notifications. + */ + public Boolean triggerOrWait(Map> collisionConfusionResult) { + // determine collision or confusion + + Configuration configuration = Configuration.getInstance(); + int collisionSum = 0; + int confusionSum = 0; + + for (Map.Entry> entry : collisionConfusionResult.entrySet()) { + + ArrayList arr; + arr = entry.getValue(); + // check for 0 collision and confusion + if (!arr.isEmpty()) { + collisionSum = collisionSum + arr.get(0); + confusionSum = confusionSum + arr.get(1); + } + } + return ((collisionSum >= configuration.getMinCollision()) && (confusionSum >= configuration.getMinConfusion())); + + } + /** * get policy notification string from oof result. * @@ -63,27 +119,33 @@ public class ChildThreadUtils { 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))))))); + 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 closedLoopControlName = (String) configPolicy.getConfig().get("PCI_MODCONFIG_POLICY_NAME"); - PolicyNotification policyNotification = new PolicyNotification(closedLoopControlName, - requestId, alarmStartTime, pnfName); - + + String closedLoopControlName = "ControlLoop-vPCI-fb41f388-a5f2-11e8-98d0-529269fb1459"; + try { + closedLoopControlName = (String) configPolicy.getConfig().get("PCI_MODCONFIG_POLICY_NAME"); + } catch (NullPointerException e) { + log.error("Config policy not found, Using default"); + } + + PolicyNotification policyNotification = new PolicyNotification(closedLoopControlName, requestId, alarmStartTime, + pnfName); + policyNotification.setClosedLoopControlName(closedLoopControlName); policyNotification.setPayload(payloadString); - mapper.setSerializationInclusion(Include.NON_NULL); String notification = ""; try { notification = mapper.writeValueAsString(policyNotification); @@ -92,5 +154,77 @@ public class ChildThreadUtils { } return notification; } - + + /** + * Sends Dmaap notification to Policy. + * + * @throws ConfigDbNotFoundException + * when config db is unreachable + */ + public void sendToPolicy(AsyncResponseBody async) throws ConfigDbNotFoundException { + + if (log.isDebugEnabled()) { + log.debug(async.toString()); + } + + Solutions solutions; + solutions = async.getSolutions(); + + if (!solutions.getPciSolutions().isEmpty()) { + Map> pnfs = pnfUtils.getPnfs(solutions); + + for (Map.Entry> entry : pnfs.entrySet()) { + String pnfName = entry.getKey(); + List cellPciPairs = entry.getValue(); + + String notification = getNotificationString(pnfName, cellPciPairs, UUID.randomUUID().toString(), + System.currentTimeMillis()); + log.debug("Policy Notification: {}", notification); + PolicyDmaapClient policy = new PolicyDmaapClient(); + boolean status = policy.sendNotificationToPolicy(notification); + log.debug("sent Message: {}", status); + if (status) { + log.debug("Message sent to policy"); + } else { + log.debug("Sending notification to policy failed"); + } + + } + } + if (!solutions.getAnrSolutions().isEmpty()) { + + List configurations = new ArrayList<>(); + for (AnrSolutions anrSolution : solutions.getAnrSolutions()) { + String cellId = anrSolution.getCellId(); + List 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); + } + 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); + } + Boolean result = policyDmaapClient.sendNotificationToPolicy(anrUpdateString); + log.debug("send notification to policy result {} ", result); + } + } + } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/child/ClusterFormation.java b/src/main/java/org/onap/dcaegen2/services/sonhms/child/ClusterFormation.java deleted file mode 100644 index e248a59..0000000 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/child/ClusterFormation.java +++ /dev/null @@ -1,145 +0,0 @@ -/******************************************************************************* - * ============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.child; - -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.Map; -import java.util.Properties; -import java.util.UUID; -import java.util.concurrent.BlockingQueue; - -import org.onap.dcaegen2.services.sonhms.ConfigPolicy; -import org.onap.dcaegen2.services.sonhms.Configuration; -import org.onap.dcaegen2.services.sonhms.dao.ClusterDetailsRepository; -import org.onap.dcaegen2.services.sonhms.entity.ClusterDetails; -import org.onap.dcaegen2.services.sonhms.model.FapServiceList; -import org.onap.dcaegen2.services.sonhms.utils.BeanUtil; -import org.onap.dcaegen2.services.sonhms.utils.ClusterUtils; -import org.slf4j.Logger; - - -public class ClusterFormation { - - private static final Logger log = org.slf4j.LoggerFactory.getLogger(ClusterFormation.class); - private BlockingQueue queue; - private ClusterUtils clusterUtils; - private Detection detect; - Properties confProp; - ClusterDetails details = new ClusterDetails(); - - public ClusterFormation() { - this.detect = new Detection(); - } - - /** - * parameterized constructor. - * - */ - public ClusterFormation(BlockingQueue queue) { - super(); - this.queue = queue; - this.detect = new Detection(); - this.clusterUtils = new ClusterUtils(); - } - - /** - * Determines whether to trigger Oof or wait for notifications. - */ - public Boolean triggerOrWait(Map> collisionConfusionResult) { - // determine collision or confusion - - Configuration configuration = Configuration.getInstance(); - int collisionSum = 0; - int confusionSum = 0; - - for (Map.Entry> entry : collisionConfusionResult.entrySet()) { - - ArrayList arr; - arr = entry.getValue(); - // check for 0 collision and confusion - if (!arr.isEmpty()) { - collisionSum = collisionSum + arr.get(0); - confusionSum = confusionSum + arr.get(1); - } - } - return ((collisionSum >= configuration.getMinCollision()) && (confusionSum >= configuration.getMinConfusion())); - - } - - /** - * Waits for notifications. - */ - public Map> waitForNotification(Map> collisionConfusionResult, - Graph cluster) { - - FapServiceList newNotification; - ConfigPolicy config = ConfigPolicy.getInstance(); - int timer = 60; - try { - timer = (int) config.getConfig().get("PCI_NEIGHBOR_CHANGE_CLUSTER_TIMEOUT_IN_SECS"); - } catch (NullPointerException e) { - log.debug("Policy config not available. Using default timeout - 60 seconds"); - } - - Timestamp currentTime = new Timestamp(System.currentTimeMillis()); - log.debug("Current Time {}", currentTime); - - Timestamp laterTime = new Timestamp(System.currentTimeMillis()); - log.debug("LaterTime {}", laterTime); - - long difference = laterTime.getTime() - currentTime.getTime(); - - int flag = 0; - - while (difference < (timer * 1000)) { - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - log.error("Interrupted Exception is {}", e); - Thread.currentThread().interrupt(); - } - - laterTime = new Timestamp(System.currentTimeMillis()); - difference = laterTime.getTime() - currentTime.getTime(); - - if ((difference < (timer * 1000)) && (!queue.isEmpty())) { - newNotification = queue.poll(); - cluster = clusterUtils.modifyCluster(cluster, newNotification); - - // update cluster in DB - String cellPciNeighbourString = cluster.getPciNeighbourJson(); - UUID clusterId = cluster.getGraphId(); - ClusterDetailsRepository clusterDetailsRepository = BeanUtil.getBean(ClusterDetailsRepository.class); - clusterDetailsRepository.updateCluster(cellPciNeighbourString, clusterId.toString()); - flag++; - - } - } - if (flag != 0) { - return detect.detectCollisionConfusion(cluster); - - } - return collisionConfusionResult; - } - -} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/child/Detection.java b/src/main/java/org/onap/dcaegen2/services/sonhms/child/Detection.java index 2634d9a..bdfa8f6 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/child/Detection.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/child/Detection.java @@ -28,7 +28,6 @@ import java.util.Map; import org.onap.dcaegen2.services.sonhms.model.CellPciPair; import org.slf4j.Logger; - public class Detection { private static final Logger log = org.slf4j.LoggerFactory.getLogger(Detection.class); @@ -37,9 +36,9 @@ public class Detection { * Returns a map with key as cellid and its value is a list of its collision and * confusion. */ - public Map> detectCollisionConfusion(Graph cluster) { + log.info("Finding collision and confusion count"); Map> clusterMap = cluster.getCellPciNeighbourMap(); HashMap> hash = new HashMap<>(); @@ -79,7 +78,7 @@ public class Detection { hash.put(cellId, counts); } - log.debug("collison and confusion map {}", hash); + log.info("collison and confusion map {}", hash); return hash; } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/child/Graph.java b/src/main/java/org/onap/dcaegen2/services/sonhms/child/Graph.java index a76d0dd..7d1e898 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/child/Graph.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/child/Graph.java @@ -47,11 +47,32 @@ public class Graph { // symbol table: key = string vertex, value = set of neighboring vertices private Map> cellPciNeighbourMap; private UUID graphId; + + private String networkId; + + public String getNetworkId() { + return networkId; + } + + public void setNetworkId(String networkId) { + this.networkId = networkId; + } + + + private Map> collisionConfusionMap; + + public Map> getCollisionConfusionMap() { + return collisionConfusionMap; + } + + public void setCollisionConfusionMap(Map> collisionConfusionMap) { + this.collisionConfusionMap = collisionConfusionMap; + } /** * Parameterized constructor. */ - public Graph(String clusterInfo) { + public Graph(String clusterInfo) { JSONArray cells = new JSONArray(clusterInfo); Map> cellMap = new HashMap<>(); @@ -62,9 +83,10 @@ public class Graph { ArrayList neighbours = new ArrayList<>(); try { neighbours = mapper.readValue(cell.getString("neighbours"), - new TypeReference>() { }); + new TypeReference>() { + }); } catch (JSONException | IOException e) { - log.debug("Error parsing json: {}", e); + log.error("Error parsing json: {}", e); } cellMap.put(cellPciPair, neighbours); @@ -195,7 +217,7 @@ public class Graph { try { pciNeighbourJson = mapper.writeValueAsString(cells); } catch (JsonProcessingException e) { - log.debug("Error while processing json: {}", e); + log.error("Error while processing json: {}", e); } return pciNeighbourJson; } @@ -211,31 +233,10 @@ public class Graph { @Override public boolean equals(Object obj) { - if (this == obj) { - return true; - } if (obj == null) { return false; } - if (getClass() != obj.getClass()) { - return false; - } - Graph other = (Graph) obj; - if (cellPciNeighbourMap == null) { - if (other.cellPciNeighbourMap != null) { - return false; - } - } else if (!cellPciNeighbourMap.equals(other.cellPciNeighbourMap)) { - return false; - } - if (graphId == null) { - if (other.graphId != null) { - return false; - } - } else if (!graphId.equals(other.graphId)) { - return false; - } - return true; + return (this.hashCode() == obj.hashCode()); } } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/child/PnfUtils.java b/src/main/java/org/onap/dcaegen2/services/sonhms/child/PnfUtils.java index 30fd0b9..590a938 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/child/PnfUtils.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/child/PnfUtils.java @@ -31,9 +31,9 @@ import org.onap.dcaegen2.services.sonhms.dao.CellInfoRepository; 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.PciSolutions; import org.onap.dcaegen2.services.sonhms.restclient.SdnrRestClient; -import org.onap.dcaegen2.services.sonhms.restclient.Solution; -import org.onap.dcaegen2.services.sonhms.restclient.SonSolution; +import org.onap.dcaegen2.services.sonhms.restclient.Solutions; import org.onap.dcaegen2.services.sonhms.utils.BeanUtil; @@ -44,13 +44,11 @@ public class PnfUtils { * get pnfs. * */ - public Map> getPnfs(List solutions) throws ConfigDbNotFoundException { + public Map> getPnfs(Solutions solutions) throws ConfigDbNotFoundException { Map> pnfs = new HashMap<>(); - - for (Solution solution : solutions) { - List pciSolutions = solution.getPciSolutions(); - for (SonSolution pciSolution : pciSolutions) { + List pciSolutions = solutions.getPciSolutions(); + for (PciSolutions pciSolution : pciSolutions) { String cellId = pciSolution.getCellId(); int pci = pciSolution.getPci(); @@ -70,7 +68,6 @@ public class PnfUtils { cellPciPairs.add(new CellPciPair(cellId, pci)); pnfs.put(pnfName, cellPciPairs); } - } } return pnfs; diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/child/StateOof.java b/src/main/java/org/onap/dcaegen2/services/sonhms/child/StateOof.java index ae40dbf..a92617c 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/child/StateOof.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/child/StateOof.java @@ -22,31 +22,19 @@ package org.onap.dcaegen2.services.sonhms.child; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; -import java.util.Map; -import java.util.Set; import java.util.UUID; import java.util.concurrent.BlockingQueue; -import org.onap.dcaegen2.services.sonhms.ConfigPolicy; import org.onap.dcaegen2.services.sonhms.Configuration; -import org.onap.dcaegen2.services.sonhms.dao.SonRequestsRepository; -import org.onap.dcaegen2.services.sonhms.dmaap.PolicyDmaapClient; -import org.onap.dcaegen2.services.sonhms.entity.PciRequests; -import org.onap.dcaegen2.services.sonhms.exceptions.ConfigDbNotFoundException; import org.onap.dcaegen2.services.sonhms.exceptions.OofNotFoundException; -import org.onap.dcaegen2.services.sonhms.model.CellPciPair; -import org.onap.dcaegen2.services.sonhms.restclient.AsyncResponseBody; +import org.onap.dcaegen2.services.sonhms.model.AnrInput; import org.onap.dcaegen2.services.sonhms.restclient.OofRestClient; -import org.onap.dcaegen2.services.sonhms.restclient.Solution; -import org.onap.dcaegen2.services.sonhms.utils.BeanUtil; import org.slf4j.Logger; public class StateOof { private static final Logger log = org.slf4j.LoggerFactory.getLogger(StateOof.class); private BlockingQueue> childStatusUpdate; - public StateOof() { } @@ -61,33 +49,14 @@ public class StateOof { } /** - * Triggers OOF. + * Triggers OOF for pci. * @throws OofNotFoundException when trigger oof fails */ - public void triggerOof(Map> result, - String networkId) throws OofNotFoundException, InterruptedException { - // check for 0 collision and 0 confusion - ArrayList cellidList = new ArrayList<>(); - ArrayList cellIds = new ArrayList<>(); - - for (Map.Entry> entry : result.entrySet()) { - String key = entry.getKey(); - ArrayList arr; - arr = entry.getValue(); - if (!arr.isEmpty()) { - Set set = new HashSet<>(arr); - if (((set.size() == 1) && !set.contains(0)) || (set.size() != 1)) { - cellIds.add(key); - - } - } - - } - - for (String cell : cellIds) { - log.debug("cellidList entries: {}", cell); - cellidList.add(cell); - } + public UUID triggerOof(List cellidList, + String networkId, List anrInputList) throws OofNotFoundException, InterruptedException { + + log.info("Triggering oof"); + log.debug("the cells triggering the oof are {}", cellidList); UUID transactionId = UUID.randomUUID(); @@ -97,8 +66,8 @@ public class StateOof { List optimizers = config.getOptimizers(); String oofResponse = OofRestClient.queryOof(numSolutions, transactionId.toString(), "create", cellidList, - networkId, optimizers); - log.debug("Synchronous Response {}", oofResponse); + networkId, optimizers, anrInputList); + log.info("Synchronous Response {}", oofResponse); List childStatus = new ArrayList<>(); childStatus.add(Long.toString(Thread.currentThread().getId())); @@ -110,83 +79,9 @@ public class StateOof { Thread.currentThread().interrupt(); } - - // Store Request details in Database - - PciRequests pciRequest = new PciRequests(); - - long childThreadId = Thread.currentThread().getId(); - pciRequest.setTransactionId(transactionId.toString()); - pciRequest.setChildThreadId(childThreadId); - SonRequestsRepository pciRequestsRepository = BeanUtil.getBean(SonRequestsRepository.class); - pciRequestsRepository.save(pciRequest); - - while (!ChildThread.getResponseMap().containsKey(childThreadId)) { - Thread.sleep(100); - } - - AsyncResponseBody asynResponseBody = ChildThread.getResponseMap().get(childThreadId); - - try { - sendToPolicy(asynResponseBody); - } catch (ConfigDbNotFoundException e1) { - log.debug("Config DB is unreachable: {}", e1); - } - - pciRequestsRepository = BeanUtil.getBean(SonRequestsRepository.class); - pciRequestsRepository.deleteByChildThreadId(childThreadId); - - childStatus = new ArrayList<>(); - childStatus.add(Long.toString(Thread.currentThread().getId())); - childStatus.add("success"); - try { - childStatusUpdate.put(childStatus); - } catch (InterruptedException e) { - log.debug("InterruptedException {}", e); - Thread.currentThread().interrupt(); - - } - - } - - /** - * Sends Dmaap notification to Policy. - * - * @throws ConfigDbNotFoundException - * when config db is unreachable - */ - private void sendToPolicy(AsyncResponseBody async) throws ConfigDbNotFoundException { - - if (log.isDebugEnabled()) { - log.debug(async.toString()); - } - - List solutions; - solutions = async.getSolutions(); - PnfUtils pnfUtils = new PnfUtils(); - Map> pnfs = pnfUtils.getPnfs(solutions); - - for (Map.Entry> entry : pnfs.entrySet()) { - String pnfName = entry.getKey(); - List cellPciPairs = entry.getValue(); - - ChildThreadUtils childThreadUtils = new ChildThreadUtils(ConfigPolicy.getInstance()); - String notification = childThreadUtils.getNotificationString(pnfName, cellPciPairs, - UUID.randomUUID().toString(), System.currentTimeMillis()); - log.debug("Policy Notification: {}", notification); - PolicyDmaapClient policy = new PolicyDmaapClient(); - boolean status = policy.sendNotificationToPolicy(notification); - log.debug("sent Message: {}", status); - if (status) { - log.debug("Message sent to policy"); - } else { - log.debug("Sending notification to policy failed"); - } - - } + return transactionId; } - } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/controller/ConfigFetchFromCbs.java b/src/main/java/org/onap/dcaegen2/services/sonhms/controller/ConfigFetchFromCbs.java index ab6d40d..76e7929 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/controller/ConfigFetchFromCbs.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/controller/ConfigFetchFromCbs.java @@ -21,16 +21,26 @@ package org.onap.dcaegen2.services.sonhms.controller; +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; import java.util.List; import java.util.Map; import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api.CbsClientFactory; +import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api.CbsRequests; +import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.CbsRequest; import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.EnvProperties; import org.onap.dcaegen2.services.sdk.rest.services.model.logging.RequestDiagnosticContext; +import org.onap.dcaegen2.services.sonhms.ConfigPolicy; import org.onap.dcaegen2.services.sonhms.Configuration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; + public class ConfigFetchFromCbs { private static Logger log = LoggerFactory.getLogger(ConfigFetchFromCbs.class); @@ -38,72 +48,102 @@ public class ConfigFetchFromCbs { /** * Gets app config from CBS. */ - @SuppressWarnings("unchecked") - public void getAppConfig() { + public void getAppConfig() { // Generate RequestID and InvocationID which will be used when logging and in // HTTP requests - log.debug("getAppconfig start .."); + log.info("getAppconfig start .."); RequestDiagnosticContext diagnosticContext = RequestDiagnosticContext.create(); - log.debug("fiagnostic context : {}",diagnosticContext.toString()); // Read necessary properties from the environment final EnvProperties env = EnvProperties.fromEnvironment(); - log.debug("environments {}",env.toString()); - Configuration configuration = Configuration.getInstance(); + log.debug("environments {}",env); + ConfigPolicy configPolicy = ConfigPolicy.getInstance(); // Create the client and use it to get the configuration - CbsClientFactory.createCbsClient(env).flatMap(cbsClient -> cbsClient.get(diagnosticContext)) + final CbsRequest request = CbsRequests.getAll(diagnosticContext); + CbsClientFactory.createCbsClient(env).flatMap(cbsClient -> cbsClient.get(request)) .subscribe(jsonObject -> { - log.debug("configuration from CBS {}", jsonObject.toString()); - final Map streamsSubscribes=(Map) jsonObject.get("streams_subscribes"); - final Map streamsPublishes=(Map) jsonObject.get("streams_publishes"); - final int pgPort = jsonObject.get("postgres.port").getAsInt(); - final int pollingInterval=jsonObject.get("sonhandler.pollingInterval").getAsInt(); - final String pgPassword = jsonObject.get("postgres.password").getAsString(); - final int numSolutions=jsonObject.get("sonhandler.numSolutions").getAsInt(); - final int minConfusion = jsonObject.get("sonhandler.minConfusion").getAsInt(); - final int maximumClusters =jsonObject.get("sonhandler.maximumClusters").getAsInt(); - final int minCollision = jsonObject.get("sonhandler.minCollision").getAsInt(); - final String sourceId = jsonObject.get("sonhandler.sourceId").getAsString(); - final String pgUsername = jsonObject.get("postgres.username").getAsString(); - final String pgHost = jsonObject.get("postgres.host").getAsString(); - final List dmaapServers = (List) jsonObject.get("sonhandler.dmaap.server"); - final String cg=jsonObject.get("sonhandler.cg").getAsString(); - final int bufferTime=jsonObject.get("sonhandler.bufferTime").getAsInt(); - final String cid =jsonObject.get("sonhandler.cid").getAsString(); - final String configDbService=jsonObject.get("sonhandler.configDb.service").getAsString(); - final String callbackUrl=jsonObject.get("sonhandler.callbackUrl").getAsString(); - final List optimizers = (List) jsonObject.get("sonhandler.optimizers"); - final String oofService=jsonObject.get("sonhandler.oof.service").getAsString(); - final int pollingTimeout=jsonObject.get("sonhandler.pollingTimeout").getAsInt(); - - configuration.setStreamsSubscribes(streamsSubscribes); - configuration.setStreamsPublishes(streamsPublishes); - configuration.setPgPassword(pgPassword); - configuration.setPgPort(pgPort); - configuration.setPollingInterval(pollingInterval); - configuration.setNumSolutions(numSolutions); - configuration.setMinCollision(minCollision); - configuration.setMinConfusion(minConfusion); - configuration.setMaximumClusters(maximumClusters); - configuration.setPgHost(pgHost); - configuration.setPgUsername(pgUsername); - configuration.setSourceId(sourceId); - configuration.setDmaapServers(dmaapServers); - configuration.setCg(cg); - configuration.setCid(cid); - configuration.setBufferTime(bufferTime); - configuration.setConfigDbService(configDbService); - configuration.setCallbackUrl(callbackUrl); - configuration.setOptimizers(optimizers); - configuration.setOofService(oofService); - configuration.setPollingTimeout(pollingTimeout); + log.debug("configuration from CBS {}", jsonObject); + JsonObject config = jsonObject.getAsJsonObject("config"); + + updateConfigurationFromJsonObject(config); - log.debug("configuration {}", configuration); - }, throwable -> { - log.warn("Ooops", throwable); - }); + Type mapType = new TypeToken>() {}.getType(); + JsonObject policyJson = jsonObject.getAsJsonObject("policy"); + Map policy = new Gson().fromJson(policyJson, mapType); + configPolicy.setConfig(policy); + }, throwable -> log.warn("Ooops", throwable)) ; + + } + + private void updateConfigurationFromJsonObject(JsonObject jsonObject) { + + log.info("Updating configuration from CBS"); + Configuration configuration = Configuration.getInstance(); + log.debug("configuration from CBS {}", jsonObject); + Type mapType = new TypeToken>() {}.getType(); + + JsonObject subscribes = jsonObject.getAsJsonObject("streams_subscribes"); + Map streamsSubscribes = new Gson().fromJson(subscribes, mapType); + + JsonObject publishes = jsonObject.getAsJsonObject("streams_publishes"); + Map 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(); + int numSolutions = jsonObject.get("sonhandler.numSolutions").getAsInt(); + int minConfusion = jsonObject.get("sonhandler.minConfusion").getAsInt(); + int maximumClusters = jsonObject.get("sonhandler.maximumClusters").getAsInt(); + int minCollision = jsonObject.get("sonhandler.minCollision").getAsInt(); + String sourceId = jsonObject.get("sonhandler.sourceId").getAsString(); + String pgUsername = jsonObject.get("postgres.username").getAsString(); + String pgHost = jsonObject.get("postgres.host").getAsString(); + + JsonArray servers = jsonObject.getAsJsonArray("sonhandler.dmaap.server"); + Type listType = new TypeToken>() {}.getType(); + List 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 callbackUrl = "http://" + System.getenv("HOSTNAME") + ":8080/callbackUrl"; + + JsonArray optimizersJson = jsonObject.getAsJsonArray("sonhandler.optimizers"); + List optimizers = new Gson().fromJson(optimizersJson, listType); + + String oofService = jsonObject.get("sonhandler.oof.service").getAsString(); + int pollingTimeout = jsonObject.get("sonhandler.pollingTimeout").getAsInt(); + + int badThreshold = jsonObject.get("sonhandler.badThreshold").getAsInt(); + int poorThreshold = jsonObject.get("sonhandler.poorThreshold").getAsInt(); + + configuration.setStreamsSubscribes(streamsSubscribes); + configuration.setStreamsPublishes(streamsPublishes); + configuration.setPgPassword(pgPassword); + configuration.setPgPort(pgPort); + configuration.setPollingInterval(pollingInterval); + configuration.setNumSolutions(numSolutions); + configuration.setMinCollision(minCollision); + configuration.setMinConfusion(minConfusion); + configuration.setMaximumClusters(maximumClusters); + configuration.setPgHost(pgHost); + configuration.setPgUsername(pgUsername); + configuration.setSourceId(sourceId); + configuration.setDmaapServers(dmaapServers); + configuration.setCg(cg); + configuration.setCid(cid); + configuration.setBufferTime(bufferTime); + configuration.setConfigDbService(configDbService); + configuration.setCallbackUrl(callbackUrl); + configuration.setOptimizers(optimizers); + configuration.setOofService(oofService); + configuration.setPollingTimeout(pollingTimeout); + configuration.setBadThreshold(badThreshold); + configuration.setPoorThreshold(poorThreshold); } } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dao/HandOverMetricsRepository.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dao/HandOverMetricsRepository.java new file mode 100644 index 0000000..efc1e19 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dao/HandOverMetricsRepository.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * ============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.dao; + +import org.onap.dcaegen2.services.sonhms.entity.HandOverMetrics; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface HandOverMetricsRepository extends CrudRepository { + + @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") + public void updateHoMetrics(String hoDetails, String srcCellId); +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dao/PerformanceNotificationsRepository.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dao/PerformanceNotificationsRepository.java new file mode 100644 index 0000000..c83956f --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dao/PerformanceNotificationsRepository.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * ============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.dao; + +import org.onap.dcaegen2.services.sonhms.entity.PerformanceNotifications; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface PerformanceNotificationsRepository extends CrudRepository { + + @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(); + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dao/SonRequestsRepository.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dao/SonRequestsRepository.java index 4bf9dd6..63f7c45 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/dao/SonRequestsRepository.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dao/SonRequestsRepository.java @@ -21,7 +21,7 @@ package org.onap.dcaegen2.services.sonhms.dao; -import org.onap.dcaegen2.services.sonhms.entity.PciRequests; +import org.onap.dcaegen2.services.sonhms.entity.SonRequests; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.CrudRepository; @@ -31,10 +31,10 @@ import org.springframework.transaction.annotation.Transactional; @Repository @Transactional -public interface SonRequestsRepository extends CrudRepository { +public interface SonRequestsRepository extends CrudRepository { @Query(nativeQuery = true, value = "SELECT child_thread_id FROM pci_requests WHERE transaction_id = ?1") - public long getChildThreadMapping(String transactionId); + public Long getChildThreadMapping(String transactionId); @Modifying @Query(nativeQuery = true, value = "DELETE FROM pci_requests WHERE child_thread_id = ?1") diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/DmaapClient.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/DmaapClient.java index 91e7117..d3ca349 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/DmaapClient.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/DmaapClient.java @@ -23,102 +23,97 @@ package org.onap.dcaegen2.services.sonhms.dmaap; import com.att.nsa.cambria.client.CambriaConsumer; -import org.onap.dcaegen2.services.sonhms.Configuration; -import org.onap.dcaegen2.services.sonhms.NewNotification; -import org.onap.dcaegen2.services.sonhms.dao.DmaapNotificationsRepository; -import org.onap.dcaegen2.services.sonhms.entity.DmaapNotifications; -import org.onap.dcaegen2.services.sonhms.utils.DmaapUtils; - - import java.util.Map; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; +import javax.annotation.PostConstruct; + +import org.onap.dcaegen2.services.sonhms.Configuration; +import org.onap.dcaegen2.services.sonhms.utils.DmaapUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component public class DmaapClient { - @Autowired - private DmaapNotificationsRepository dmaapNotificationsRepository; - private Configuration configuration; - private static Logger log = LoggerFactory.getLogger(DmaapClient.class); - - @Autowired - private NewNotification newNotification; - private DmaapUtils dmaapUtils; - - public class NotificationCallback { - DmaapClient dmaapClient; - - public NotificationCallback(DmaapClient dmaapClient) { - this.dmaapClient = dmaapClient; - } - - public void activateCallBack(String msg) { - handleNotification(msg); - } - - private void handleNotification(String msg) { - DmaapNotifications dmaapNotification = new DmaapNotifications(); - dmaapNotification.setNotification(msg); - if (log.isDebugEnabled()) { - log.debug(dmaapNotification.toString()); - } - dmaapNotificationsRepository.save(dmaapNotification); - newNotification.setNewNotif(true); - } - } - - /** - * init dmaap client. - */ - public void initClient() { - log.debug("initializing client"); - configuration = Configuration.getInstance(); - if (log.isDebugEnabled()) { - log.debug(configuration.toString()); - } - - startClient(); - } - - - /** - * start dmaap client. - */ - @SuppressWarnings("unchecked") - private synchronized void startClient() { - - Map streamSubscribes= Configuration.getInstance().getStreamsSubscribes(); - String sdnrTopicUrl =((Map)((Map)streamSubscribes.get("nbr_list_change_topic")).get("dmaap_info")).get("topic_url"); - String[] sdnrTopicSplit=sdnrTopicUrl.split("\\/"); - String sdnrTopic=sdnrTopicSplit[sdnrTopicSplit.length-1]; - ScheduledExecutorService executorPool; - CambriaConsumer cambriaConsumer = null; - - cambriaConsumer = dmaapUtils.buildConsumer(configuration, sdnrTopic ); - /* - * cambriaConsumer = new ConsumerBuilder() - * .authenticatedBy(configuration.getPcimsApiKey(), - * configuration.getPcimsSecretKey()) .knownAs(configuration.getCg(), - * configuration.getCid()).onTopic(configuration.getSdnrTopic()) - * .usingHosts(configuration.getServers()).withSocketTimeout(configuration. - * getPollingTimeout() * 1000) .build(); - */ - - // create notification consumers for SNDR and policy - NotificationConsumer notificationConsumer = new NotificationConsumer(cambriaConsumer, - new NotificationCallback(this)); - - // start notification consumer threads - executorPool = Executors.newScheduledThreadPool(10); - executorPool.scheduleAtFixedRate(notificationConsumer, 0, configuration.getPollingInterval(), TimeUnit.SECONDS); - - } - + private Configuration configuration; + private static Logger log = LoggerFactory.getLogger(DmaapClient.class); + + private DmaapUtils dmaapUtils; + + /** + * init dmaap client. + */ + @PostConstruct + public void initClient() { + log.debug("initializing client"); + dmaapUtils = new DmaapUtils(); + configuration = Configuration.getInstance(); + if (log.isDebugEnabled()) { + log.debug(configuration.toString()); + } + + startClient(); + } + + /** + * start dmaap client. + */ + @SuppressWarnings("unchecked") + private synchronized void startClient() { + + Map streamSubscribes = Configuration.getInstance().getStreamsSubscribes(); + String sdnrTopicUrl = ((Map) ((Map) streamSubscribes + .get("nbr_list_change_topic")).get("dmaap_info")).get("topic_url"); + String[] sdnrTopicSplit = sdnrTopicUrl.split("\\/"); + String sdnrTopic = sdnrTopicSplit[sdnrTopicSplit.length - 1]; + log.debug("sdnr topic : {}", sdnrTopic); + String fmTopicUrl = ((Map) ((Map) streamSubscribes + .get("fault_management_topic")).get("dmaap_info")).get("topic_url"); + String[] fmTopicSplit = fmTopicUrl.split("\\/"); + String fmTopic = fmTopicSplit[sdnrTopicSplit.length - 1]; + log.debug("fm topic : {}", fmTopic); + String pmTopicUrl = ((Map) ((Map) streamSubscribes + .get("performance_management_topic")).get("dmaap_info")).get("topic_url"); + String[] pmTopicSplit = pmTopicUrl.split("\\/"); + String pmTopic = pmTopicSplit[sdnrTopicSplit.length - 1]; + log.debug("pm topic : {}", pmTopic); + CambriaConsumer sdnrNotifCambriaConsumer = null; + CambriaConsumer fmNotifCambriaConsumer = null; + CambriaConsumer pmNotifCambriaConsumer = null; + + sdnrNotifCambriaConsumer = dmaapUtils.buildConsumer(configuration, sdnrTopic); + fmNotifCambriaConsumer = dmaapUtils.buildConsumer(configuration, fmTopic); + pmNotifCambriaConsumer = dmaapUtils.buildConsumer(configuration, pmTopic); + + // create notification consumers for SNDR and policy + NotificationConsumer sdnrNotificationConsumer = new NotificationConsumer(sdnrNotifCambriaConsumer, + new SdnrNotificationCallback()); + // start sdnr notification consumer threads + ScheduledExecutorService executorPool; + executorPool = Executors.newScheduledThreadPool(10); + executorPool.scheduleAtFixedRate(sdnrNotificationConsumer, 0, configuration.getPollingInterval(), + TimeUnit.SECONDS); + + // create notification consumers for FM + NotificationConsumer fmNotificationConsumer = new NotificationConsumer(fmNotifCambriaConsumer, + new FMNotificationCallback()); + // start fm notification consumer threads + executorPool = Executors.newScheduledThreadPool(10); + executorPool.scheduleAtFixedRate(fmNotificationConsumer, 0, configuration.getPollingInterval(), + TimeUnit.SECONDS); + + // create notification consumers for PM + NotificationConsumer pmNotificationConsumer = new NotificationConsumer(pmNotifCambriaConsumer, + new PMNotificationCallback()); + // start pm notification consumer threads + executorPool = Executors.newScheduledThreadPool(10); + executorPool.scheduleAtFixedRate(pmNotificationConsumer, 0, configuration.getPollingInterval(), + TimeUnit.SECONDS); + + } + } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/FMNotificationCallback.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/FMNotificationCallback.java new file mode 100644 index 0000000..aede74b --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/FMNotificationCallback.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * ============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 org.onap.dcaegen2.services.sonhms.NewFmNotification; +import org.onap.dcaegen2.services.sonhms.dao.FaultNotificationsRepository; +import org.onap.dcaegen2.services.sonhms.entity.FaultNotifications; +import org.onap.dcaegen2.services.sonhms.utils.BeanUtil; +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); + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationCallback.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationCallback.java new file mode 100644 index 0000000..f488f03 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationCallback.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * ============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; + +public abstract class NotificationCallback { + + public abstract void activateCallBack(String msg); + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationConsumer.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationConsumer.java index 78294a3..3860311 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationConsumer.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationConsumer.java @@ -25,7 +25,6 @@ import com.att.nsa.cambria.client.CambriaConsumer; import java.io.IOException; -import org.onap.dcaegen2.services.sonhms.dmaap.DmaapClient.NotificationCallback; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PMNotificationCallback.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PMNotificationCallback.java new file mode 100644 index 0000000..47e285a --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PMNotificationCallback.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * ============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 org.onap.dcaegen2.services.sonhms.NewPmNotification; +import org.onap.dcaegen2.services.sonhms.dao.PerformanceNotificationsRepository; +import org.onap.dcaegen2.services.sonhms.entity.PerformanceNotifications; +import org.onap.dcaegen2.services.sonhms.utils.BeanUtil; +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); + } + + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyDmaapClient.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyDmaapClient.java index 68cb788..dbd9b58 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyDmaapClient.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyDmaapClient.java @@ -22,37 +22,39 @@ package org.onap.dcaegen2.services.sonhms.dmaap; import com.att.nsa.cambria.client.CambriaBatchingPublisher; -import org.onap.dcaegen2.services.sonhms.Configuration; -import org.onap.dcaegen2.services.sonhms.utils.DmaapUtils; import java.io.IOException; import java.util.Map; +import org.onap.dcaegen2.services.sonhms.Configuration; +import org.onap.dcaegen2.services.sonhms.utils.DmaapUtils; + public class PolicyDmaapClient { - DmaapUtils dmaapUtils = new DmaapUtils(); - - /** - * Method stub for sending notification to policy. - */ - @SuppressWarnings("unchecked") - public boolean sendNotificationToPolicy(String msg) { - - Map streamSubscribes= Configuration.getInstance().getStreamsPublishes(); - String policyTopicUrl =((Map)((Map)streamSubscribes.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 { - - cambriaBatchingPublisher = dmaapUtils.buildPublisher(configuration, policyTopic); - - NotificationProducer notificationProducer = new NotificationProducer(cambriaBatchingPublisher); - notificationProducer.sendNotification(msg); - } catch (IOException e) { - return false; - } - return true; - } + private DmaapUtils dmaapUtils; + + /** + * Method stub for sending notification to policy. + */ + @SuppressWarnings("unchecked") + public boolean sendNotificationToPolicy(String msg) { + dmaapUtils = new DmaapUtils(); + Map streamsPublishes = Configuration.getInstance().getStreamsPublishes(); + String policyTopicUrl = ((Map) ((Map) 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 { + + cambriaBatchingPublisher = dmaapUtils.buildPublisher(configuration, policyTopic); + + NotificationProducer notificationProducer = new NotificationProducer(cambriaBatchingPublisher); + notificationProducer.sendNotification(msg); + } catch (IOException e) { + return false; + } + return true; + } } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/SdnrNotificationCallback.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/SdnrNotificationCallback.java new file mode 100644 index 0000000..d4430ea --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/SdnrNotificationCallback.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * ============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 org.onap.dcaegen2.services.sonhms.NewSdnrNotification; +import org.onap.dcaegen2.services.sonhms.dao.DmaapNotificationsRepository; +import org.onap.dcaegen2.services.sonhms.entity.DmaapNotifications; +import org.onap.dcaegen2.services.sonhms.utils.BeanUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SdnrNotificationCallback extends NotificationCallback { + + private static Logger log = LoggerFactory.getLogger(SdnrNotificationCallback.class); + + @Override + public void activateCallBack(String msg) { + handleNotification(msg); + } + + private void handleNotification(String msg) { + + DmaapNotificationsRepository dmaapNotificationsRepository = BeanUtil + .getBean(DmaapNotificationsRepository.class); + DmaapNotifications dmaapNotification = new DmaapNotifications(); + dmaapNotification.setNotification(msg); + if (log.isDebugEnabled()) { + log.debug(dmaapNotification.toString()); + } + dmaapNotificationsRepository.save(dmaapNotification); + NewSdnrNotification newNotification = BeanUtil.getBean(NewSdnrNotification.class); + newNotification.setNewNotif(true); + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/entity/HandOverMetrics.java b/src/main/java/org/onap/dcaegen2/services/sonhms/entity/HandOverMetrics.java new file mode 100644 index 0000000..be5aad7 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/entity/HandOverMetrics.java @@ -0,0 +1,82 @@ +/******************************************************************************* + * ============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.entity; + +import java.sql.Timestamp; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +import org.hibernate.annotations.CreationTimestamp; + +@Entity +@Table(name = "HANDOVER_METRICS") +public class HandOverMetrics { + + @Id + @Column(name = "src_cell_id", columnDefinition = "srcCellId") + private String srcCellId; + + @Column(name = "ho_details", columnDefinition = "text") + private String hoDetails; + + @CreationTimestamp + @Column(name = "created_at", columnDefinition = "timestamp") + private Timestamp createdAt; + + public HandOverMetrics() { + super(); + } + + public String getSrcCellId() { + return srcCellId; + } + + public void setSrcCellId(String srcCellId) { + this.srcCellId = srcCellId; + } + + public String getHoDetails() { + return hoDetails; + } + + public void setHoDetails(String hoDetails) { + this.hoDetails = hoDetails; + } + + public Timestamp getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Timestamp createdAt) { + this.createdAt = createdAt; + } + + @Override + public String toString() { + return "HandOverMetrics [srcCellId=" + srcCellId + ", hoDetails=" + hoDetails + ", createdAt=" + createdAt + + "]"; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/entity/PerformanceNotifications.java b/src/main/java/org/onap/dcaegen2/services/sonhms/entity/PerformanceNotifications.java new file mode 100644 index 0000000..30a6c0e --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/entity/PerformanceNotifications.java @@ -0,0 +1,71 @@ +/******************************************************************************* + * ============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.entity; + +import java.sql.Timestamp; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +import org.hibernate.annotations.CreationTimestamp; + +@Entity +@Table(name = "PERFORMANCE_NOTIFICATIONS") +public class PerformanceNotifications { + + @Id + @Column(name = "notification", columnDefinition = "text") + private String notification; + + @CreationTimestamp + @Column(name = "created_at", columnDefinition = "timestamp") + private Timestamp createdAt; + + public PerformanceNotifications() { + + } + + public PerformanceNotifications(String notification, Timestamp createdAt) { + this.notification = notification; + this.createdAt = createdAt; + } + + public String getNotification() { + return notification; + } + + public void setNotification(String notification) { + this.notification = notification; + } + + public Timestamp getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Timestamp createdAt) { + this.createdAt = createdAt; + } + + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/entity/PciRequests.java b/src/main/java/org/onap/dcaegen2/services/sonhms/entity/SonRequests.java similarity index 88% rename from src/main/java/org/onap/dcaegen2/services/sonhms/entity/PciRequests.java rename to src/main/java/org/onap/dcaegen2/services/sonhms/entity/SonRequests.java index 79120ee..e9c454e 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/entity/PciRequests.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/entity/SonRequests.java @@ -28,7 +28,7 @@ import javax.persistence.Table; @Entity @Table(name = "PCI_REQUESTS") -public class PciRequests { +public class SonRequests { @Id @Column(name = "TRANSACTION_ID") @@ -37,14 +37,14 @@ public class PciRequests { @Column(name = "CHILD_THREAD_ID") private long childThreadId; - public PciRequests() { + public SonRequests() { } /** * Parameterised constructor. */ - public PciRequests(String transactionId, long childThreadId) { + public SonRequests(String transactionId, long childThreadId) { super(); this.transactionId = transactionId; this.childThreadId = childThreadId; @@ -66,4 +66,9 @@ public class PciRequests { this.childThreadId = childThreadId; } + @Override + public String toString() { + return "PciRequests [transactionId=" + transactionId + ", childThreadId=" + childThreadId + "]"; + } + } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/AdditionalMeasurements.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/AdditionalMeasurements.java new file mode 100644 index 0000000..10329ba --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/AdditionalMeasurements.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * ============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 java.util.List; +import java.util.Map; + +public class AdditionalMeasurements { + + String name; + List> arrayOfNamedHashMap; + + public AdditionalMeasurements() { + + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public List> getArrayOfNamedHashMap() { + return arrayOfNamedHashMap; + } + public void setArrayOfNamedHashMap(List> arrayOfNamedHashMap) { + this.arrayOfNamedHashMap = arrayOfNamedHashMap; + } + @Override + public String toString() { + return "AdditionalMeasurements [name=" + name + ", arrayOfNamedHashMap=" + arrayOfNamedHashMap + "]"; + } + + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/AnrInput.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/AnrInput.java new file mode 100644 index 0000000..faff91e --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/AnrInput.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * ============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 java.util.List; + +public class AnrInput { + + String cellId; + List removeableNeighbors; + + public AnrInput() { + + } + /** + * Parameterized Constructor. + */ + + public AnrInput(String cellId, List removeableNeighbors) { + super(); + this.cellId = cellId; + this.removeableNeighbors = removeableNeighbors; + } + public String getCellId() { + return cellId; + } + public void setCellId(String cellId) { + this.cellId = cellId; + } + public List getRemoveableNeighbors() { + return removeableNeighbors; + } + public void setRemoveableNeighbors(List removeableNeighbors) { + this.removeableNeighbors = removeableNeighbors; + } + + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/CellPciPair.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/CellPciPair.java index 866c51e..b5b9398 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/model/CellPciPair.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/CellPciPair.java @@ -30,6 +30,7 @@ public class CellPciPair { @JsonProperty("physicalCellId") private int physicalCellId; + @Override public String toString() { return "CellPciPair [cellId=" + cellId + ", physicalCellId=" + physicalCellId + "]"; diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/ClusterMap.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/ClusterMap.java new file mode 100644 index 0000000..c01b3c8 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/ClusterMap.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * ============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 java.util.ArrayList; + +public class ClusterMap { + + CellPciPair cell; + ArrayList neighbourList; + + public ClusterMap() { + + } + + /** + * Constructor. + */ + public ClusterMap(CellPciPair cell, ArrayList neighbourList) { + super(); + this.cell = cell; + this.neighbourList = neighbourList; + } + + public CellPciPair getCell() { + return cell; + } + + public void setCell(CellPciPair cell) { + this.cell = cell; + } + + public ArrayList getNeighbourList() { + return neighbourList; + } + + public void setNeighbourList(ArrayList neighbourList) { + this.neighbourList = neighbourList; + } + + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/Configurations.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Configurations.java index e043aaf..415b7d9 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/model/Configurations.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Configurations.java @@ -34,7 +34,6 @@ public class Configurations { public Configurations() { } - /** * Parameterized constructor. * @@ -43,13 +42,14 @@ public class Configurations { super(); this.data = data; } - public Data getData() { return data; } - public void setData(Data data) { this.data = data; } + + + } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/Event.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Event.java new file mode 100644 index 0000000..b958318 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Event.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * ============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 org.onap.dcaegen2.services.sonhms.CommonEventHeader; + +public class Event { + CommonEventHeader commonEventHeader; + Measurement measurement; + + public Event() { + + } + + public CommonEventHeader getCommonEventHeader() { + return commonEventHeader; + } + + public void setCommonEventHeader(CommonEventHeader commonEventHeader) { + this.commonEventHeader = commonEventHeader; + } + + public Measurement getMeasurement() { + return measurement; + } + + public void setMeasurement(Measurement measurement) { + this.measurement = measurement; + } + + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/HoDetails.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/HoDetails.java new file mode 100644 index 0000000..ecc2048 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/HoDetails.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * ============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; + +public class HoDetails { + + private String dstCellId; + private int attemptsCount; + private int successCount; + private float successRate; + + /** + * 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; + } + + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/LteCell.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/LteCell.java new file mode 100644 index 0000000..a23bc6a --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/LteCell.java @@ -0,0 +1,87 @@ +/******************************************************************************* + * ============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 LteCell { + + @JsonProperty("PNFName") + private String pnfName; + + @JsonProperty("PLMNID") + private String plmnId; + + @JsonProperty("CID") + private String cid; + + @JsonProperty("PhyCellID") + private int phyCellId; + + @JsonProperty("Blacklisted") + private String blacklisted; + + public LteCell() { + + } + + public String getPnfName() { + return pnfName; + } + + public void setPnfName(String pnfName) { + this.pnfName = pnfName; + } + + public String getPlmnId() { + return plmnId; + } + + public void setPlmnId(String plmnId) { + this.plmnId = plmnId; + } + + public String getCid() { + return cid; + } + + public void setCid(String cid) { + this.cid = cid; + } + + public int getPhyCellId() { + return phyCellId; + } + + public void setPhyCellId(int phyCellId) { + this.phyCellId = phyCellId; + } + + public String getBlacklisted() { + return blacklisted; + } + + public void setBlacklisted(String blacklisted) { + this.blacklisted = blacklisted; + } + +} \ No newline at end of file diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/LteNeighborListInUseLteCell.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/LteNeighborListInUseLteCell.java index 961e5f0..f1cae93 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/model/LteNeighborListInUseLteCell.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/LteNeighborListInUseLteCell.java @@ -52,10 +52,6 @@ public class LteNeighborListInUseLteCell { } - /** - * Parameterized Constructor. - */ - public LteNeighborListInUseLteCell(String pnfName, String enable, String alias, String mustInclude, String plmnId, String cid, int phyCellId, String blacklisted) { super(); diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/Measurement.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Measurement.java new file mode 100644 index 0000000..c3863b0 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Measurement.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * ============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 java.util.List; + +public class Measurement { + + String measurementInterval; + List additionalMeasurements; + + /** + * default constructor + */ + public Measurement() { + + } + public String getMeasurementInterval() { + return measurementInterval; + } + + public void setMeasurementInterval(String measurementInterval) { + this.measurementInterval = measurementInterval; + } + + public List getAdditionalMeasurements() { + return additionalMeasurements; + } + + public void setAdditionalMeasurements(List additionalMeasurements) { + this.additionalMeasurements = additionalMeasurements; + } + + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/NeighborListInUse.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/NeighborListInUse.java index b88cb5a..c7baa25 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/model/NeighborListInUse.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/NeighborListInUse.java @@ -29,6 +29,9 @@ public class NeighborListInUse { @JsonProperty("LTENeighborListInUseLTECell") private List lteNeighborListInUseLteCell; + @JsonProperty("LTECell") + private List lteCell; + @JsonProperty("LTECellNumberOfEntries") private String lteCellNumberOfEntries; @@ -39,13 +42,14 @@ public class NeighborListInUse { /** * Parameterized Constructor. */ - - public NeighborListInUse(List lteNeighborListInUseLteCell, + public NeighborListInUse(List lteNeighborListInUseLteCell, List lteCell, String lteCellNumberOfEntries) { super(); this.lteNeighborListInUseLteCell = lteNeighborListInUseLteCell; + this.lteCell = lteCell; this.lteCellNumberOfEntries = lteCellNumberOfEntries; } + public List getLteNeighborListInUseLteCell() { return lteNeighborListInUseLteCell; diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/PMNotification.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/PMNotification.java new file mode 100644 index 0000000..076be31 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/PMNotification.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * ============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; + +public class PMNotification { + + Event event; + + /** + * default constructor + */ + public PMNotification() { + + } + + public Event getEvent() { + return event; + } + public void setEvent(Event event) { + this.event = event; + } + + + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/Ran.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Ran.java index f2be944..8f016dc 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/model/Ran.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Ran.java @@ -27,6 +27,9 @@ public class Ran { @JsonProperty(value = "Common") private Common common; + + @JsonProperty("NeighborListInUse") + private NeighborListInUse neighborListInUse; public Ran() { @@ -35,15 +38,18 @@ public class Ran { /** * Parameterized constructor. */ - public Ran(Common common) { + public Ran(Common common, NeighborListInUse neighborListInUse) { super(); this.common = common; + this.neighborListInUse = neighborListInUse; } + public Common getCommon() { return common; } + public void setCommon(Common common) { this.common = common; } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/AnrSolutions.java b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/AnrSolutions.java new file mode 100644 index 0000000..117f202 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/AnrSolutions.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * ============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.restclient; + +import java.util.ArrayList; +import java.util.List; + +public class AnrSolutions { + + String cellId; + List removeableNeighbors = new ArrayList<>(); + + public AnrSolutions() { + + } + + public AnrSolutions(String cellId, List removeableNeighbors) { + super(); + this.cellId = cellId; + this.removeableNeighbors = removeableNeighbors; + } + + public String getCellId() { + return cellId; + } + public void setCellId(String cellId) { + this.cellId = cellId; + } + public List getRemoveableNeighbors() { + return removeableNeighbors; + } + public void setRemoveableNeighbors(List removeableNeighbors) { + this.removeableNeighbors = removeableNeighbors; + } + @Override + public String toString() { + return "AnrSolutions [cellId=" + cellId + ", removeableNeighbors=" + removeableNeighbors + "]"; + } + + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/AsyncResponseBody.java b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/AsyncResponseBody.java index 61e0421..1102f76 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/AsyncResponseBody.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/AsyncResponseBody.java @@ -21,15 +21,13 @@ package org.onap.dcaegen2.services.sonhms.restclient; -import java.util.List; - public class AsyncResponseBody { String transactionId = null; String requestId = null; String requestStatus = null; String statusMessage = null; - List solutions; + Solutions solutions; public String getTransactionId() { return transactionId; @@ -69,11 +67,11 @@ public class AsyncResponseBody { this.statusMessage = statusMessage; } - public List getSolutions() { + public Solutions getSolutions() { return solutions; } - public void setSolutions(List solutions) { + public void setSolutions(Solutions solutions) { this.solutions = solutions; } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/CellInfo.java b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/CellInfo.java index edac16f..2501e53 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/CellInfo.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/CellInfo.java @@ -24,9 +24,30 @@ package org.onap.dcaegen2.services.sonhms.restclient; import java.util.ArrayList; import java.util.List; +import org.onap.dcaegen2.services.sonhms.model.AnrInput; + public class CellInfo { String networkId = null; List cellIdList = new ArrayList<>(); + protected List anrInputList = new ArrayList<>(); + String trigger; + + + public List getAnrInputList() { + return anrInputList; + } + + public void setAnrInputList(List anrInputList) { + this.anrInputList = anrInputList; + } + + public String getTrigger() { + return trigger; + } + + public void setTrigger(String trigger) { + this.trigger = trigger; + } public String getNetworkId() { return networkId; diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/OofRequestBody.java b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/OofRequestBody.java index 2e5eeaa..974c483 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/OofRequestBody.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/OofRequestBody.java @@ -25,7 +25,7 @@ public class OofRequestBody { protected RequestInfo requestInfo = new RequestInfo(); protected CellInfo cellInfo = new CellInfo(); - + public RequestInfo getRequestInfo() { return requestInfo; } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/OofRestClient.java b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/OofRestClient.java index 083341b..9cb1d18 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/OofRestClient.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/OofRestClient.java @@ -24,12 +24,15 @@ package org.onap.dcaegen2.services.sonhms.restclient; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import java.util.HashMap; import java.util.List; +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; import org.onap.dcaegen2.services.sonhms.utils.SonHandlerRestTemplate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -51,7 +54,7 @@ public class OofRestClient { */ public static String queryOof(int numSolutions, String transactionId, String requestType, List cellIdList, - String networkId, List optimizers) throws OofNotFoundException { + String networkId, List optimizers, List anrInputList) throws OofNotFoundException { log.debug("inside queryoof"); Configuration configuration = Configuration.getInstance(); @@ -67,6 +70,9 @@ public class OofRestClient { requestInfo.setRequestType(requestType); requestInfo.setNumSolutions(numSolutions); requestInfo.setOptimizers(optimizers); + Map callbackHeader = new HashMap<>(); + callbackHeader.put("Content-Type", "application/json"); + requestInfo.setCallbackHeader(callbackHeader); ConfigPolicy config = ConfigPolicy.getInstance(); int timeout = 60; try { @@ -75,9 +81,13 @@ public class OofRestClient { 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()) + cellInfo.setAnrInputList(anrInputList); OofRequestBody oofRequestBody = new OofRequestBody(); oofRequestBody.setRequestInfo(requestInfo); oofRequestBody.setCellInfo(cellInfo); diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/SonSolution.java b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/PciSolutions.java similarity index 88% rename from src/main/java/org/onap/dcaegen2/services/sonhms/restclient/SonSolution.java rename to src/main/java/org/onap/dcaegen2/services/sonhms/restclient/PciSolutions.java index 25f474a..eec3fd8 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/SonSolution.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/PciSolutions.java @@ -21,11 +21,14 @@ package org.onap.dcaegen2.services.sonhms.restclient; -public class SonSolution { +public class PciSolutions { String cellId = null; int pci; + public PciSolutions() { + + } public String getCellId() { return cellId; } @@ -42,4 +45,9 @@ public class SonSolution { this.pci = pci; } + @Override + public String toString() { + return "PciSolutions [cellId=" + cellId + ", pci=" + pci + "]"; + } + } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/RequestInfo.java b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/RequestInfo.java index ff53b33..3504e5d 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/RequestInfo.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/RequestInfo.java @@ -21,7 +21,9 @@ package org.onap.dcaegen2.services.sonhms.restclient; +import java.util.HashMap; import java.util.List; +import java.util.Map; public class RequestInfo { String transactionId = null; @@ -31,6 +33,16 @@ public class RequestInfo { String requestType = null; int numSolutions; List optimizers = null; + protected Map callbackHeader = new HashMap<>(); + + + public Map getCallbackHeader() { + return callbackHeader; + } + + public void setCallbackHeader(Map callbackHeader) { + this.callbackHeader = callbackHeader; + } public void setOptimizers(List optimizers) { this.optimizers = optimizers; diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/SdnrRestClient.java b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/SdnrRestClient.java index 996e553..65bd756 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/SdnrRestClient.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/SdnrRestClient.java @@ -58,7 +58,7 @@ public class SdnrRestClient { Configuration configuration = Configuration.getInstance(); String ts = new SimpleDateFormat(DATETIMEFORMAT).format(new Time(System.currentTimeMillis())); String requestUrl = configuration.getConfigDbService() + "/SDNCConfigDBAPI/getCellList" + "/" + networkId + "/" - + encode(ts); + + ts; return sendRequest(requestUrl); } @@ -72,7 +72,7 @@ public class SdnrRestClient { Configuration configuration = Configuration.getInstance(); String ts = new SimpleDateFormat(DATETIMEFORMAT).format(new Time(System.currentTimeMillis())); String requestUrl = configuration.getConfigDbService() + "/SDNCConfigDBAPI/getNbrList" + "/" + cellId + "/" - + encode(ts); + + ts; log.debug("request url: {}", requestUrl); String response = sendRequest(requestUrl); List nbrList = new ArrayList<>(); @@ -96,7 +96,7 @@ public class SdnrRestClient { Configuration configuration = Configuration.getInstance(); String ts = new SimpleDateFormat(DATETIMEFORMAT).format(new Time(System.currentTimeMillis())); String requestUrl = configuration.getConfigDbService() + "/SDNCConfigDBAPI/getPCI" + "/" + cellId + "/" - + encode(ts); + + ts; String response = sendRequest(requestUrl); JSONObject respObj = new JSONObject(response); return respObj.getInt("value"); @@ -112,18 +112,12 @@ public class SdnrRestClient { Configuration configuration = Configuration.getInstance(); String ts = new SimpleDateFormat(DATETIMEFORMAT).format(new Time(System.currentTimeMillis())); String requestUrl = configuration.getConfigDbService() + "/SDNCConfigDBAPI/getPnfName" + "/" + cellId + "/" - + encode(ts); + + ts; String response = sendRequest(requestUrl); JSONObject responseObject = new JSONObject(response); return responseObject.getString("value"); } - /** - * Method to encode url. - */ - private static String encode(String url) { - return url.replace(" ", "%20"); - } /** * Method to send request. diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/Solution.java b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/Solutions.java similarity index 69% rename from src/main/java/org/onap/dcaegen2/services/sonhms/restclient/Solution.java rename to src/main/java/org/onap/dcaegen2/services/sonhms/restclient/Solutions.java index 66af930..8e694a3 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/Solution.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/Solutions.java @@ -24,28 +24,15 @@ package org.onap.dcaegen2.services.sonhms.restclient; import java.util.ArrayList; import java.util.List; -public class Solution { - String startTime = null; - String finishTime = null; +public class Solutions { + String networkId = null; - List pciSolutions = new ArrayList<>(); - - public String getStartTime() { - return startTime; - } - - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public String getFinishTime() { - return finishTime; - } - - public void setFinishTime(String finishTime) { - this.finishTime = finishTime; + List pciSolutions = new ArrayList<>(); + List anrSolutions = new ArrayList<>(); + + public Solutions() { + } - public String getNetworkId() { return networkId; } @@ -54,22 +41,33 @@ public class Solution { this.networkId = networkId; } - public List getPciSolutions() { + public List getPciSolutions() { return pciSolutions; } /** * Sets PciSolutions. */ - public void setPciSolutions(List pciSolutions) { + public void setPciSolutions(List pciSolutions) { this.pciSolutions = pciSolutions; } + public List getAnrSolutions() { + return anrSolutions; + } + + public void setAnrSolutions(List anrSolutions) { + this.anrSolutions = anrSolutions; + } @Override public String toString() { - return "Solutions [startTime=" + startTime + ", finishTime=" + finishTime + ", networkId=" + networkId - + ", pciSolutions=" + pciSolutions + "]"; + return "Solutions [networkId=" + networkId + ", pciSolutions=" + pciSolutions + ", anrSolutions=" + anrSolutions + + "]"; } + + + + } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtils.java b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtils.java index 5b4ca55..a25fd54 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtils.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtils.java @@ -26,12 +26,14 @@ import fj.data.Either; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import java.util.UUID; import org.onap.dcaegen2.services.sonhms.ClusterDetailsComponent; +import org.onap.dcaegen2.services.sonhms.FaultNotificationtoClusterMapping; import org.onap.dcaegen2.services.sonhms.NotificationToClusterMapping; import org.onap.dcaegen2.services.sonhms.child.Graph; import org.onap.dcaegen2.services.sonhms.dao.ClusterDetailsRepository; @@ -45,17 +47,50 @@ import org.onap.dcaegen2.services.sonhms.restclient.SdnrRestClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +public class ClusterUtils { - -public class ClusterUtils { - private static Logger log = LoggerFactory.getLogger(ClusterUtils.class); - + public List getAllClusters() { ClusterDetailsComponent clusterDetailsComponent = new ClusterDetailsComponent(); - return clusterDetailsComponent.getClusterDetails(); + return clusterDetailsComponent.getClusterDetails(); + } + + /** + * Get cluster for FM notifications. + */ + public FaultNotificationtoClusterMapping getClustersForFmNotification(Set cellIds, + List clusterDetails) { + List newCells = new ArrayList<>(); + Map cellsInCluster = new HashMap(); + FaultNotificationtoClusterMapping faultNotificationtoClusterMapping = new FaultNotificationtoClusterMapping(); + for (String cellId : cellIds) { + for (ClusterDetails clusterDetail : clusterDetails) { + Graph cluster = new Graph(clusterDetail.getClusterInfo()); + + Set clusterCells = getCellsInCluster(cluster); + for (String clusterCell : clusterCells) { + if (cellId.equals(clusterCell)) { + cellsInCluster.put(cellId, clusterDetail.getClusterId()); + break; + + } + + } + + } + if (!cellsInCluster.containsKey(cellId)) { + newCells.add(cellId); + } + + } + + faultNotificationtoClusterMapping.setCellsinCluster(cellsInCluster); + faultNotificationtoClusterMapping.setNewCells(newCells); + return faultNotificationtoClusterMapping; + } - + /** * Get clusters for notifications. */ @@ -66,23 +101,23 @@ public class ClusterUtils { Map cellsInCluster = new HashMap<>(); List newCells = new ArrayList<>(); - + List fapServiceList = notification.getPayload().getRadioAccess().getFapServiceList(); - + for (FapServiceList fapService : fapServiceList) { for (ClusterDetails clusterDetail : clusterDetails) { Set cellsInNotification = getCellsInNotification(fapService); - + Graph cluster = new Graph(clusterDetail.getClusterInfo()); Set clusterCells = getCellsInCluster(cluster); log.debug("cells in cluster {}", clusterCells); - + cellsInNotification.retainAll(clusterCells); - + if (!cellsInNotification.isEmpty()) { log.debug("cell or it's neighbour in the cluster"); cellsInCluster.put(fapService, clusterDetail.getClusterId()); @@ -99,7 +134,7 @@ public class ClusterUtils { mapping.setNewCells(newCells); return mapping; } - + /** * Get cluster details from cluster ID. */ @@ -113,19 +148,18 @@ public class ClusterUtils { } return Either.right(404); } - + /** * Get clusters for Cell. */ public Either getClusterForCell(FapServiceList fapService, List newClusters) { - + if (newClusters.isEmpty()) { return Either.right(404); } - - + for (Graph cluster : newClusters) { - + Set cellsInNotification = getCellsInNotification(fapService); Set clusterCells = getCellsInCluster(cluster); @@ -139,7 +173,31 @@ public class ClusterUtils { return Either.right(404); } - + + /** + * Get clusters for FM Cell. + */ + public Either getClusterForFMCell(String cellId, List newClusters) { + if (newClusters.isEmpty()) { + log.info("getClusterForFMCell 404"); + return Either.right(404); + } + for (Graph cluster : newClusters) { + + Set clusterCells = getCellsInCluster(cluster); + for (String clusterCell : clusterCells) { + if (cellId.equals(clusterCell)) { + return Either.left(cluster); + + } + + } + + } + return Either.right(404); + + } + private Set getCellsInNotification(FapServiceList fapService) { Set cellsInNotification = new HashSet<>(); cellsInNotification.add(fapService.getAlias()); @@ -164,38 +222,29 @@ public class ClusterUtils { return clusterCells; } - - /** - * Create cluster from notification. - */ - public Graph createCluster(FapServiceList fapService) throws ConfigDbNotFoundException { + // generic create cluster for both fm and sdnr + + public Graph createCluster(Map> clusterMap) throws ConfigDbNotFoundException { Graph cluster = new Graph(); log.debug("cluster formation started"); - int phycellId = fapService.getX0005b9Lte().getPhyCellIdInUse(); - String cellId = fapService.getCellConfig().getLte().getRan().getCellIdentity(); - - CellPciPair val = new CellPciPair(); - val.setCellId(cellId); - val.setPhysicalCellId(phycellId); - List neighbourlist; - neighbourlist = fapService.getCellConfig().getLte().getRan().getNeighborListInUse() - .getLteNeighborListInUseLteCell(); - log.debug("Neighbor list size: {}", neighbourlist.size()); - for (int i = 0; i < neighbourlist.size(); i++) { - String cell = neighbourlist.get(i).getAlias(); - int phy = neighbourlist.get(i).getPhyCellId(); + Set keySet = clusterMap.keySet(); + Iterator iterate = keySet.iterator(); + CellPciPair val = (CellPciPair) iterate.next(); + + List firstNeighbourlist = clusterMap.get(val); + + for (int i = 0; i < firstNeighbourlist.size(); i++) { + String cell = firstNeighbourlist.get(i).getCellId(); + int phy = firstNeighbourlist.get(i).getPhysicalCellId(); - log.debug("cellID: {}", cell); - log.debug("PCI: {}", phy); CellPciPair val1 = new CellPciPair(); val1.setCellId(cell); val1.setPhysicalCellId(phy); cluster.addEdge(val, val1); - log.debug("cluster: {}", cluster); - List nbrList = SdnrRestClient.getNbrList(neighbourlist.get(i).getAlias()); + List nbrList = SdnrRestClient.getNbrList(cell); for (CellPciPair nbr : nbrList) { String cid = nbr.getCellId(); @@ -211,7 +260,7 @@ public class ClusterUtils { log.debug("final cluster: {}", cluster); return cluster; } - + /** * Save cluster. */ @@ -232,28 +281,52 @@ public class ClusterUtils { return clusterId.toString(); } - + /** - * update cluster. + * Update cluster. */ - public Graph modifyCluster(Graph cluster, FapServiceList fapser) { - - int phycellId = fapser.getX0005b9Lte().getPhyCellIdInUse(); - String cellId = fapser.getCellConfig().getLte().getRan().getCellIdentity(); - CellPciPair mainCellPciPair = new CellPciPair(); - mainCellPciPair.setCellId(cellId); - mainCellPciPair.setPhysicalCellId(phycellId); - List newNeighbourList; - newNeighbourList = fapser.getCellConfig().getLte().getRan().getNeighborListInUse() - .getLteNeighborListInUseLteCell(); + public void updateCluster(Graph cluster) { + String cellPciNeighbourString = cluster.getPciNeighbourJson(); + UUID clusterId = cluster.getGraphId(); + ClusterDetailsRepository clusterDetailsRepository = BeanUtil.getBean(ClusterDetailsRepository.class); + clusterDetailsRepository.updateCluster(cellPciNeighbourString, clusterId.toString()); + } - Map> clusterMap; - clusterMap = cluster.getCellPciNeighbourMap(); + /** + * Find cluster Map. + */ + public Map> findClusterMap(String cellId) throws ConfigDbNotFoundException { + log.info("indide clusterMap"); + int phyCellId = SdnrRestClient.getPci(cellId); + CellPciPair main = new CellPciPair(); + main.setCellId(cellId); + main.setPhysicalCellId(phyCellId); + ArrayList cellPciPairs; + cellPciPairs = (ArrayList) SdnrRestClient.getNbrList(cellId); + Map> clusterMap = new HashMap<>(); + clusterMap.put(main, cellPciPairs); + log.info("clusterMap{}", clusterMap); + + return clusterMap; + } + + /** + * Modify cluster. + */ + public Graph modifyCluster(Graph cluster, Map> clusterMap) { + Set keySet = clusterMap.keySet(); + Iterator iterate = keySet.iterator(); + CellPciPair mainCellPciPair = (CellPciPair) iterate.next(); + String cellId = mainCellPciPair.getCellId(); + List newNeighbourList = clusterMap.get(mainCellPciPair); + + Map> existingClusterMap; + existingClusterMap = cluster.getCellPciNeighbourMap(); // coe List tempCellPair = new ArrayList<>(); - for (Map.Entry> entry : clusterMap.entrySet()) { + for (Map.Entry> entry : existingClusterMap.entrySet()) { CellPciPair oldClusterKeys = entry.getKey(); tempCellPair.add(oldClusterKeys); } @@ -276,14 +349,14 @@ public class ClusterUtils { /////// update cluster with new pci values for the same cell - if (clusterMap.containsKey(mainCellPciPair)) { + if (existingClusterMap.containsKey(mainCellPciPair)) { ArrayList oldClusterArray; - oldClusterArray = clusterMap.get(mainCellPciPair); + oldClusterArray = existingClusterMap.get(mainCellPciPair); oldClusterArray.clear(); for (int i = 0; i < newNeighbourList.size(); i++) { - String cid = newNeighbourList.get(i).getAlias(); - int phy = newNeighbourList.get(i).getPhyCellId(); + String cid = newNeighbourList.get(i).getCellId(); + int phy = newNeighbourList.get(i).getPhysicalCellId(); CellPciPair val2 = new CellPciPair(); val2.setCellId(cid); val2.setPhysicalCellId(phy); @@ -299,8 +372,8 @@ public class ClusterUtils { mapVal.setCellId(cell); mapVal.setPhysicalCellId(physicalCell); for (int j = 0; j < newNeighbourList.size(); j++) { - String cid1 = newNeighbourList.get(j).getAlias(); - int phy1 = newNeighbourList.get(j).getPhyCellId(); + String cid1 = newNeighbourList.get(j).getCellId(); + int phy1 = newNeighbourList.get(j).getPhysicalCellId(); CellPciPair val3 = new CellPciPair(); val3.setCellId(cid1); val3.setPhysicalCellId(phy1); @@ -316,28 +389,29 @@ public class ClusterUtils { } for (int j = 0; j < newNeighbourList.size(); j++) { - String cid1 = newNeighbourList.get(j).getAlias(); - int phy1 = newNeighbourList.get(j).getPhyCellId(); + String cid1 = newNeighbourList.get(j).getCellId(); + int phy1 = newNeighbourList.get(j).getPhysicalCellId(); CellPciPair val3 = new CellPciPair(); val3.setCellId(cid1); val3.setPhysicalCellId(phy1); - if (clusterMap.containsKey(val3)) { + if (existingClusterMap.containsKey(val3)) { cluster.addEdge(mainCellPciPair, val3); } } for (int k = 0; k < newNeighbourList.size(); k++) { - String cid2 = newNeighbourList.get(k).getAlias(); - int phy2 = newNeighbourList.get(k).getPhyCellId(); + String cid2 = newNeighbourList.get(k).getCellId(); + int phy2 = newNeighbourList.get(k).getPhysicalCellId(); CellPciPair val5 = new CellPciPair(); val5.setCellId(cid2); val5.setPhysicalCellId(phy2); cluster.addEdge(mainCellPciPair, val5); } - log.debug("Modified Cluster {}", cluster); + log.info("Modified Cluster {}", cluster); return cluster; } + } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/utils/DmaapUtils.java b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/DmaapUtils.java index ad6c385..f5efd3b 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/utils/DmaapUtils.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/DmaapUtils.java @@ -21,11 +21,6 @@ package org.onap.dcaegen2.services.sonhms.utils; -import java.net.MalformedURLException; -import java.security.GeneralSecurityException; - -import org.onap.dcaegen2.services.sonhms.Configuration; - import com.att.nsa.cambria.client.CambriaBatchingPublisher; import com.att.nsa.cambria.client.CambriaClient; import com.att.nsa.cambria.client.CambriaClientBuilders; @@ -35,99 +30,109 @@ import com.att.nsa.cambria.client.CambriaClientBuilders.TopicManagerBuilder; import com.att.nsa.cambria.client.CambriaConsumer; import com.att.nsa.cambria.client.CambriaTopicManager; +import java.net.MalformedURLException; +import java.security.GeneralSecurityException; + +import org.onap.dcaegen2.services.sonhms.Configuration; + public class DmaapUtils { - public CambriaBatchingPublisher buildPublisher(Configuration config, String topic) { - try { - return builder(config, topic).build(); - } catch (MalformedURLException | GeneralSecurityException e) { - // TODO Auto-generated catch block - return null; - - } - } - - public CambriaConsumer buildConsumer(Configuration config, String topic) { - - try { - return builderConsumer(config, topic).build(); - } catch (MalformedURLException | GeneralSecurityException e) { - // TODO Auto-generated catch block - return null; - } - - } - - private static PublisherBuilder builder(Configuration config, String topic) { - if (config.isSecured()) { - return authenticatedBuilder(config, topic); - } else { - return unAuthenticatedBuilder(config, topic); - } - } - - private static PublisherBuilder authenticatedBuilder(Configuration config, String topic) { - return unAuthenticatedBuilder(config, topic).usingHttps().authenticatedByHttp(config.getAafUsername(), - config.getAafPassword()); - } - - private static PublisherBuilder unAuthenticatedBuilder(Configuration config, String topic) { - return new CambriaClientBuilders.PublisherBuilder().usingHosts(config.getDmaapServers()).onTopic(topic) - .logSendFailuresAfter(5); - } - - private static ConsumerBuilder builderConsumer(Configuration config, String topic) { - if (config.isSecured()) { - return authenticatedConsumerBuilder(config, topic); - } else { - return unAuthenticatedConsumerBuilder(config, topic); - } - } - - private static ConsumerBuilder unAuthenticatedConsumerBuilder(Configuration config, String topic) { - // TODO Auto-generated method stub - return new CambriaClientBuilders.ConsumerBuilder().usingHosts(config.getDmaapServers()).onTopic(topic) - .knownAs(config.getCg(), config.getCid()).withSocketTimeout(config.getPollingTimeout() * 1000); - } - - private static ConsumerBuilder authenticatedConsumerBuilder(Configuration config, String topic) { - return unAuthenticatedConsumerBuilder(config, topic).usingHttps().authenticatedByHttp(config.getAafUsername(), - config.getAafPassword()); - } - - public CambriaTopicManager cambriaCLientBuilder(Configuration configuration) { - if(configuration.isSecured()) { - return authenticatedCambriaCLientBuilder(configuration); - } - else - { - return unAuthenticatedCambriaCLientBuilder(configuration); - - } - } - - private static CambriaTopicManager authenticatedCambriaCLientBuilder(Configuration config) { - try { - return buildCambriaClient(new TopicManagerBuilder().usingHosts(config.getDmaapServers()) - .authenticatedByHttp(config.getAafUsername(), config.getAafPassword())); - } catch (MalformedURLException | GeneralSecurityException e) { - return null; - } - } - - private static CambriaTopicManager unAuthenticatedCambriaCLientBuilder(Configuration config) { - try { - return buildCambriaClient(new TopicManagerBuilder().usingHosts(config.getDmaapServers())); - } catch (MalformedURLException | GeneralSecurityException e) { - return null; - - } - } - @SuppressWarnings("unchecked") - private static T buildCambriaClient( - CambriaClientBuilders.AbstractAuthenticatedManagerBuilder client) - throws MalformedURLException, GeneralSecurityException { - return (T) client.build(); - } + /** + * Build publisher. + */ + public CambriaBatchingPublisher buildPublisher(Configuration config, String topic) { + try { + return builder(config, topic).build(); + } catch (MalformedURLException | GeneralSecurityException e) { + return null; + + } + } + + /** + * Build consumer. + */ + public CambriaConsumer buildConsumer(Configuration config, String topic) { + + try { + return builderConsumer(config, topic).build(); + } catch (MalformedURLException | GeneralSecurityException e) { + return null; + } + + } + + private static PublisherBuilder builder(Configuration config, String topic) { + if (config.isSecured()) { + return authenticatedBuilder(config, topic); + } else { + return unAuthenticatedBuilder(config, topic); + } + } + + private static PublisherBuilder authenticatedBuilder(Configuration config, String topic) { + return unAuthenticatedBuilder(config, topic).usingHttps().authenticatedByHttp(config.getAafUsername(), + config.getAafPassword()); + } + + private static PublisherBuilder unAuthenticatedBuilder(Configuration config, String topic) { + return new CambriaClientBuilders.PublisherBuilder().usingHosts(config.getDmaapServers()).onTopic(topic) + .logSendFailuresAfter(5); + } + + private static ConsumerBuilder builderConsumer(Configuration config, String topic) { + if (config.isSecured()) { + return authenticatedConsumerBuilder(config, topic); + } else { + return unAuthenticatedConsumerBuilder(config, topic); + } + } + + private static ConsumerBuilder unAuthenticatedConsumerBuilder(Configuration config, String topic) { + return new CambriaClientBuilders.ConsumerBuilder().usingHosts(config.getDmaapServers()).onTopic(topic) + .knownAs(config.getCg(), config.getCid()).withSocketTimeout(config.getPollingTimeout() * 1000); + } + + private static ConsumerBuilder authenticatedConsumerBuilder(Configuration config, String topic) { + return unAuthenticatedConsumerBuilder(config, topic).usingHttps().authenticatedByHttp(config.getAafUsername(), + config.getAafPassword()); + } + + /** + * Build cambriaClient. + */ + public CambriaTopicManager cambriaCLientBuilder(Configuration configuration) { + if (configuration.isSecured()) { + return authenticatedCambriaCLientBuilder(configuration); + } else { + return unAuthenticatedCambriaCLientBuilder(configuration); + + } + } + + private static CambriaTopicManager authenticatedCambriaCLientBuilder(Configuration config) { + try { + return buildCambriaClient(new TopicManagerBuilder().usingHosts(config.getDmaapServers()) + .authenticatedByHttp(config.getAafUsername(), config.getAafPassword())); + } catch (MalformedURLException | GeneralSecurityException e) { + return null; + } + } + + private static CambriaTopicManager unAuthenticatedCambriaCLientBuilder(Configuration config) { + try { + return buildCambriaClient(new TopicManagerBuilder().usingHosts(config.getDmaapServers())); + } catch (MalformedURLException | GeneralSecurityException e) { + return null; + + } + } + + @SuppressWarnings("unchecked") + private static T buildCambriaClient( + CambriaClientBuilders.AbstractAuthenticatedManagerBuilder client) + throws MalformedURLException, GeneralSecurityException { + return (T) client.build(); + } } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/utils/SonHandlerRestTemplate.java b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/SonHandlerRestTemplate.java index 2fe478e..c46d912 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/utils/SonHandlerRestTemplate.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/SonHandlerRestTemplate.java @@ -24,7 +24,6 @@ package org.onap.dcaegen2.services.sonhms.utils; import java.util.Collections; import org.slf4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; @@ -37,8 +36,6 @@ import org.springframework.web.client.RestTemplate; @Component public class SonHandlerRestTemplate { - @Autowired - static RestTemplate restTemplate; private static final String AUTH = "Authorization"; private static final String EXCEPTION_MSG = "Exception caught during request {}"; @@ -59,6 +56,7 @@ public class SonHandlerRestTemplate { headers.setContentType(MediaType.APPLICATION_JSON); HttpEntity requestEntity = new HttpEntity<>(requestBody, headers); try { + RestTemplate restTemplate = BeanUtil.getBean(RestTemplate.class); return restTemplate.exchange(requestUrl, HttpMethod.POST, requestEntity, responseType); } catch (Exception e) { log.debug(EXCEPTION_MSG, e.getMessage()); @@ -66,25 +64,6 @@ public class SonHandlerRestTemplate { } } - /** - * Send Post Request to policy. - */ - public static ResponseEntity sendPostToPolicy(String requestUrl, String requestBody, - ParameterizedTypeReference responseType) { - HttpHeaders headers = new HttpHeaders(); - headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); - headers.setContentType(MediaType.APPLICATION_JSON); - headers.add("ClientAuth", "cHl0aG9uOnRlc3Q="); - headers.add(AUTH, "Basic dGVzdHBkcDphbHBoYTEyMw== "); - headers.add("Environment", "TEST"); - HttpEntity requestEntity = new HttpEntity<>(requestBody, headers); - try { - return restTemplate.exchange(requestUrl, HttpMethod.POST, requestEntity, responseType); - } catch (Exception e) { - log.debug(EXCEPTION_MSG, e.getMessage()); - return new ResponseEntity<>(HttpStatus.NOT_FOUND); - } - } /** * Send Get Request. @@ -95,6 +74,7 @@ public class SonHandlerRestTemplate { headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); HttpEntity requestEntity = new HttpEntity<>(headers); try { + RestTemplate restTemplate = BeanUtil.getBean(RestTemplate.class); return restTemplate.exchange(requestUrl, HttpMethod.GET, requestEntity, responseType); } catch (Exception e) { log.debug(EXCEPTION_MSG, e.getMessage()); @@ -114,6 +94,7 @@ public class SonHandlerRestTemplate { headers.add(AUTH, "Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA=="); HttpEntity requestEntity = new HttpEntity<>(requestBody, headers); try { + RestTemplate restTemplate = BeanUtil.getBean(RestTemplate.class); return restTemplate.exchange(requestUrl, HttpMethod.POST, requestEntity, responseType); } catch (Exception e) { log.debug(EXCEPTION_MSG, e.getMessage()); @@ -133,9 +114,10 @@ public class SonHandlerRestTemplate { headers.add(AUTH, "Basic cGNpX3Rlc3Q6cGNpX3Rlc3Rwd2Q="); HttpEntity requestEntity = new HttpEntity<>(requestBody, headers); try { + RestTemplate restTemplate = BeanUtil.getBean(RestTemplate.class); return restTemplate.exchange(requestUrl, HttpMethod.POST, requestEntity, responseType); } catch (Exception e) { - log.debug(EXCEPTION_MSG, e.getMessage()); + log.debug(EXCEPTION_MSG, e); return new ResponseEntity<>(HttpStatus.NOT_FOUND); } } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/utils/ThreadUtils.java b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/ThreadUtils.java index 78722ba..96b1a24 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/utils/ThreadUtils.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/ThreadUtils.java @@ -20,16 +20,19 @@ package org.onap.dcaegen2.services.sonhms.utils; +import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.UUID; import java.util.concurrent.BlockingQueue; import java.util.concurrent.ExecutorService; import java.util.concurrent.LinkedBlockingQueue; import org.onap.dcaegen2.services.sonhms.EventHandler; +import org.onap.dcaegen2.services.sonhms.HoMetricsComponent; import org.onap.dcaegen2.services.sonhms.child.ChildThread; import org.onap.dcaegen2.services.sonhms.child.Graph; -import org.onap.dcaegen2.services.sonhms.model.FapServiceList; +import org.onap.dcaegen2.services.sonhms.model.CellPciPair; import org.onap.dcaegen2.services.sonhms.model.ThreadId; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -44,13 +47,17 @@ public class ThreadUtils { * Create thread. */ public Boolean createNewThread(List newClusters, BlockingQueue> childStatusQueue, - ExecutorService pool, EventHandler eventHandler) { + ExecutorService pool, EventHandler eventHandler,String cellId) { + + for (Graph cluster : newClusters) { - BlockingQueue queue = new LinkedBlockingQueue<>(); + BlockingQueue>> queue = new LinkedBlockingQueue<>(); ThreadId threadId = new ThreadId(); threadId.setChildThreadId(0); - ChildThread child = new ChildThread(childStatusQueue, cluster, queue, threadId); + ChildThread child = new ChildThread(childStatusQueue, cluster, queue, threadId, new HoMetricsComponent()); + + log.info("Creating new child thread"); pool.execute(child); waitForThreadId(threadId); UUID clusterId = UUID.randomUUID(); @@ -75,7 +82,7 @@ public class ThreadUtils { } } catch (InterruptedException e) { - log.error("ChildThread queue error {}", e); + log.error("ChildThread queue error {}", e); Thread.currentThread().interrupt(); } } diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index b7baa6f..28586fd 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -1,24 +1,14 @@ - + @@ -27,23 +17,27 @@ - - /var/log/onap/son-handler/${logFileName}.log - - ${logFileName}.%i.log.zip - 1 - 5 - - - 5MB - - - %d{dd-MM-yyyy HH:mm:ss.SSS} %magenta([%thread]) %highlight(%-5level) %logger{36}.%M - %msg%n - - - + + /var/log/onap/son-handler/${logFileName}.log + + ${logFileName}.%i.log.zip + 1 + 5 + + + 5MB + + + %d{dd-MM-yyyy HH:mm:ss.SSS} %magenta([%thread]) + %highlight(%-5level) %logger{36}.%M - %msg%n + + + - - - + + + diff --git a/src/main/resources/schema.sql b/src/main/resources/schema.sql index 88b64d5..72cdbcf 100644 --- a/src/main/resources/schema.sql +++ b/src/main/resources/schema.sql @@ -24,4 +24,12 @@ CREATE TABLE FAULT_NOTIFICATIONS( notification TEXT PRIMARY KEY NOT NULL, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); - +CREATE TABLE PERFORMANCE_NOTIFICATIONS( + notification TEXT PRIMARY KEY NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); +CREATE TABLE HANDOVER_METRICS( + src_cell_id TEXT PRIMARY KEY NOT NULL, + ho_details TEXT NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/BufferNotificationComponentTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/BufferNotificationComponentTest.java index d2480d2..28ff185 100644 --- a/src/test/java/org/onap/dcaegen2/services/sonhms/BufferNotificationComponentTest.java +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/BufferNotificationComponentTest.java @@ -70,7 +70,7 @@ public class BufferNotificationComponentTest { .thenReturn(bufferedNotificationsRepositoryMock); when(bufferedNotificationsRepositoryMock.save(bufferedNotifications)).thenReturn(bufferedNotifications); bufferNotificationComponent.bufferNotification("notification", "clusterId"); - assertEquals(bufferedNotifications, bufferedNotificationsRepositoryMock.save(bufferedNotifications)); + assertEquals(bufferedNotifications, bufferedNotificationsRepositoryMock.save(bufferedNotifications)); } diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/ClusterDetailsComponentTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/ClusterDetailsComponentTest.java index 18bde74..e8b44bf 100644 --- a/src/test/java/org/onap/dcaegen2/services/sonhms/ClusterDetailsComponentTest.java +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/ClusterDetailsComponentTest.java @@ -76,7 +76,7 @@ public class ClusterDetailsComponentTest { resultList = clusterDetailsComponent.getClusterDetails(); for (ClusterDetails each : resultList) { assertEquals("clusterId", each.getClusterId()); - assertEquals("clusterInfo", each.getClusterInfo()); + assertEquals("clusterInfo", each.getClusterInfo()); assertEquals(1, each.getChildThreadId()); } diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/CommonEventHeaderTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/CommonEventHeaderTest.java new file mode 100644 index 0000000..c9fc849 --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/CommonEventHeaderTest.java @@ -0,0 +1,69 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * son-handler + * ================================================================================ + * Copyright (C) 2019 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.dcaegen2.services.sonhms; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class CommonEventHeaderTest { + + CommonEventHeader common = new CommonEventHeader(); + + @Test + public void commonEventHeaderTest() { + common.setDomain("domain"); + common.setEventId("eventId"); + common.setEventName("eventName"); + common.setLastEpochMicrosec(2L); + common.setNfNamingCode("nfNamingCode"); + common.setNfVendorName("nfVendorName"); + common.setPriority("priority"); + common.setReportingEntityId("reportingEntityId"); + common.setReportingEntityName("reportingEntityName"); + common.setSequence(1); + common.setSourceId("sourceId"); + common.setSourceName("sourceName"); + common.setStartEpochMicrosec(1L); + common.setTimeZoneOffset("timeZoneOffset"); + common.setVersion("version"); + common.setVesEventListenerVersion("vesEventListenerVersion"); + assertEquals("domain", common.getDomain()); + assertEquals("eventId", common.getEventId()); + assertEquals("eventName", common.getEventName()); + assertEquals(2L, common.getLastEpochMicrosec()); + assertEquals("nfNamingCode", common.getNfNamingCode()); + assertEquals("nfVendorName", common.getNfVendorName()); + assertEquals("priority", common.getPriority()); + assertEquals("reportingEntityId", common.getReportingEntityId()); + assertEquals("reportingEntityName", common.getReportingEntityName()); + assertEquals("sourceId", common.getSourceId()); + assertEquals("sourceName", common.getSourceName()); + assertEquals("timeZoneOffset", common.getTimeZoneOffset()); + assertEquals("version", common.getVersion()); + assertEquals("vesEventListenerVersion", common.getVesEventListenerVersion()); + assertEquals(1L, common.getStartEpochMicrosec()); + assertEquals(1, common.getSequence()); + + } + +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/ConfigurationTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/ConfigurationTest.java index 851920d..6fb72c3 100644 --- a/src/test/java/org/onap/dcaegen2/services/sonhms/ConfigurationTest.java +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/ConfigurationTest.java @@ -24,8 +24,11 @@ package org.onap.dcaegen2.services.sonhms; import static org.junit.Assert.assertEquals; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import org.hibernate.sql.ConditionFragment; import org.junit.Test; @@ -39,15 +42,26 @@ public class ConfigurationTest { List list = new ArrayList(); list.add("server"); + Map subscribes = new HashMap<>(); + + configuration.setStreamsSubscribes(subscribes); + configuration.setStreamsPublishes(subscribes); configuration.setDmaapServers(list); configuration.setCg("cg"); configuration.setCid("cid"); - + configuration.setAafPassword("password"); + configuration.setAafUsername("user"); + configuration.setPgHost("pg"); + configuration.setPgPort(5432); + configuration.setPgPassword("password"); + configuration.setPgUsername("user"); configuration.setMaximumClusters(5); configuration.setMinCollision(5); configuration.setMinConfusion(5); configuration.setNumSolutions(1); configuration.setOofService("oofService"); + configuration.setBadThreshold(50); + configuration.setPoorThreshold(70); configuration.setOptimizers(list); configuration.setPollingInterval(30); configuration.setPollingTimeout(100); @@ -57,18 +71,26 @@ public class ConfigurationTest { assertEquals("/callbackUrl", configuration.getCallbackUrl()); assertEquals("cg", configuration.getCg()); assertEquals("cid", configuration.getCid()); - + assertEquals("user", configuration.getAafUsername()); + assertEquals("password", configuration.getAafPassword()); assertEquals(5, configuration.getMaximumClusters()); assertEquals(5, configuration.getMinCollision()); assertEquals(5, configuration.getMinConfusion()); assertEquals(1, configuration.getNumSolutions()); assertEquals("oofService", configuration.getOofService()); assertEquals(list, configuration.getOptimizers()); - + assertEquals("user", configuration.getPgUsername()); + assertEquals("password", configuration.getPgPassword()); + assertEquals("pg", configuration.getPgHost()); + assertEquals(5432, configuration.getPgPort()); assertEquals(30, configuration.getPollingInterval()); assertEquals(100, configuration.getPollingTimeout()); assertEquals("sdnrService", configuration.getConfigDbService()); assertEquals(list, configuration.getDmaapServers()); assertEquals("sourceId", configuration.getSourceId()); + assertEquals(50, configuration.getBadThreshold()); + assertEquals(70, configuration.getPoorThreshold()); + assertEquals(subscribes, configuration.getStreamsSubscribes()); + assertEquals(subscribes, configuration.getStreamsPublishes()); } } diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/DmaapNotificationsComponentTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/DmaapNotificationsComponentTest.java index bf5ef97..5bf76b3 100644 --- a/src/test/java/org/onap/dcaegen2/services/sonhms/DmaapNotificationsComponentTest.java +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/DmaapNotificationsComponentTest.java @@ -23,6 +23,7 @@ package org.onap.dcaegen2.services.sonhms; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.when; import fj.data.Either; @@ -37,7 +38,9 @@ import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; 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.utils.BeanUtil; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; @@ -55,16 +58,23 @@ public class DmaapNotificationsComponentTest { @Mock DmaapNotificationsRepository dmaapNotificationsRepositoryMock; + + @Mock + PerformanceNotificationsRepository performanceNotificationsRepositoryMock; @InjectMocks DmaapNotificationsComponent component; static String notificationString; + static String pmNotificationString; + @BeforeClass public static void setupTest() { notificationString = readFromFile("/notification1.json"); + pmNotificationString=readFromFile("/pmNotification.json"); + } @Test @@ -75,16 +85,34 @@ public class DmaapNotificationsComponentTest { when(dmaapNotificationsRepositoryMock.getNotificationFromQueue()).thenReturn(notificationString); - Either result = component.getDmaapNotifications(); + Either result = component.getSdnrNotifications(); //assertTrue(result.isLeft()); assertNotNull(result.left().value()); when(dmaapNotificationsRepositoryMock.getNotificationFromQueue()).thenReturn("notification"); - result = component.getDmaapNotifications(); + result = component.getSdnrNotifications(); int resultRight = result.right().value(); assertEquals(400, resultRight); + } + + @Test + public void getPmNotificationsTest() { + PowerMockito.mockStatic(BeanUtil.class); + PowerMockito.when(BeanUtil.getBean(PerformanceNotificationsRepository.class)) + .thenReturn(performanceNotificationsRepositoryMock); + when(performanceNotificationsRepositoryMock.getPerformanceNotificationFromQueue()).thenReturn(pmNotificationString); + + Either result = component.getPmNotifications(); + assertTrue(result.isLeft()); + assertNotNull(result.left().value()); + + when(performanceNotificationsRepositoryMock.getPerformanceNotificationFromQueue()).thenReturn("pmNotification"); + result = component.getPmNotifications(); + int res= result.right().value(); + assertEquals(400,res); + } private static String readFromFile(String file) { diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/EventHandlerTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/EventHandlerTest.java index 5032799..02a061b 100644 --- a/src/test/java/org/onap/dcaegen2/services/sonhms/EventHandlerTest.java +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/EventHandlerTest.java @@ -114,7 +114,7 @@ public class EventHandlerTest { Mockito.when(clusterutilsMock.getAllClusters()).thenReturn(clusterDetails); Mockito.when(clusterutilsMock.getClustersForNotification(notification, clusterDetails)).thenReturn(mapping); Mockito.when(clusterutilsMock.getClusterForCell(Mockito.any(), Mockito.any())).thenReturn(existingCluster); - Mockito.when(threadUtilsMock.createNewThread(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(true); + Mockito.when(threadUtilsMock.createNewThread(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(),Mockito.anyString())).thenReturn(true); try { Mockito.when(clusterutilsMock.createCluster(Mockito.any())).thenReturn(cluster); diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/EventTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/EventTest.java new file mode 100644 index 0000000..0fe3037 --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/EventTest.java @@ -0,0 +1,78 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * son-handler + * ================================================================================ + * Copyright (C) 2019 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.dcaegen2.services.sonhms; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.onap.dcaegen2.services.sonhms.CommonEventHeader; +import org.onap.dcaegen2.services.sonhms.FaultEvent; +import org.onap.dcaegen2.services.sonhms.FaultFields; + +public class EventTest { + + FaultEvent faultEvent = new FaultEvent(); + + @Test + public void faultEventTest() { + FaultFields faultFields = new FaultFields(); + faultFields.setAlarmCondition("alarmCondition"); + AlarmAdditionalInformation alarmAdditionalInformation = new AlarmAdditionalInformation(); + alarmAdditionalInformation.setCollisions(1); + alarmAdditionalInformation.setConfusions(3); + alarmAdditionalInformation.setNetworkId("networkId"); + faultFields.setAlarmAdditionalInformation(alarmAdditionalInformation); + + faultFields.setEventSeverity("eventSeverity"); + faultFields.setEventSourceType("eventSourceType"); + faultFields.setFaultFieldsVersion(0); + faultFields.setSpecificProblem("specificProblem"); + faultFields.setVfStatus("vfStatus"); + + CommonEventHeader common = new CommonEventHeader(); + + common.setDomain("domain"); + common.setEventId("eventId"); + common.setEventName("eventName"); + common.setLastEpochMicrosec(2L); + common.setNfNamingCode("nfNamingCode"); + common.setNfVendorName("nfVendorName"); + common.setPriority("priority"); + common.setReportingEntityId("reportingEntityId"); + common.setReportingEntityName("reportingEntityName"); + common.setSequence(1); + common.setSourceId("sourceId"); + common.setSourceName("sourceName"); + common.setStartEpochMicrosec(1L); + common.setTimeZoneOffset("timeZoneOffset"); + common.setVersion("version"); + common.setVesEventListenerVersion("vesEventListenerVersion"); + Event event=new Event(); + event.setCommonEventHeader(common); + event.setFaultFields(faultFields); + faultEvent.setEvent(event); + + assertEquals(common, faultEvent.getEvent().getCommonEventHeader()); + assertEquals(faultFields, faultEvent.getEvent().getFaultFields()); + + } +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/FaultFieldsTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/FaultFieldsTest.java new file mode 100644 index 0000000..c940917 --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/FaultFieldsTest.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * son-handler + * ================================================================================ + * Copyright (C) 2019 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.dcaegen2.services.sonhms; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test;; + +public class FaultFieldsTest { + + FaultFields faultFields=new FaultFields(); + @Test + public void faultFieldsTest() { + faultFields.setAlarmCondition("alarmCondition"); + AlarmAdditionalInformation alarmAdditionalInformation = new AlarmAdditionalInformation(); + alarmAdditionalInformation.setCollisions(1); + alarmAdditionalInformation.setConfusions(3); + alarmAdditionalInformation.setNetworkId("networkId"); + + faultFields.setEventSeverity("eventSeverity"); + faultFields.setEventSourceType("eventSourceType"); + faultFields.setFaultFieldsVersion(0); + faultFields.setAlarmAdditionalInformation(alarmAdditionalInformation); + + faultFields.setSpecificProblem("specificProblem"); + faultFields.setVfStatus("vfStatus"); + assertEquals("alarmCondition", faultFields.getAlarmCondition()); + assertEquals(1, faultFields.getAlarmAdditionalInformation().getCollisions()); + assertEquals(3, faultFields.getAlarmAdditionalInformation().getConfusions()); + assertEquals(0, faultFields.getFaultFieldsVersion()); + assertEquals("eventSeverity", faultFields.getEventSeverity()); + assertEquals("eventSourceType", faultFields.getEventSourceType()); + assertEquals("networkId", faultFields.getAlarmAdditionalInformation().getNetworkId()); + assertEquals("specificProblem", faultFields.getSpecificProblem()); + assertEquals("vfStatus", faultFields.getVfStatus()); + + } + +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/FaultNotificationComponentTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/FaultNotificationComponentTest.java new file mode 100644 index 0000000..17fd484 --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/FaultNotificationComponentTest.java @@ -0,0 +1,102 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * son-handler + * ================================================================================ + * Copyright (C) 2019 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.dcaegen2.services.sonhms; + +import static org.junit.Assert.assertNotNull; +import static org.mockito.Mockito.when; + +import fj.data.Either; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.List; + +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.onap.dcaegen2.services.sonhms.dao.FaultNotificationsRepository; +import org.onap.dcaegen2.services.sonhms.utils.BeanUtil; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.powermock.modules.junit4.PowerMockRunnerDelegate; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(PowerMockRunner.class) +@PowerMockRunnerDelegate(SpringRunner.class) +@PrepareForTest({ BeanUtil.class }) +@SpringBootTest(classes = FaultNotificationComponentTest.class) + +public class FaultNotificationComponentTest { + + @Mock + FaultNotificationsRepository faultNotificationsRepositoryMock; + + @InjectMocks + FaultNotificationComponent component; + + static String notificationString; + + @BeforeClass + public static void setupTest() { + + notificationString = readFromFile("/notification1.json"); + } + + @Test + public void getDmaapNotificationsTestforLeft() { + PowerMockito.mockStatic(BeanUtil.class); + PowerMockito.when(BeanUtil.getBean(FaultNotificationsRepository.class)) + .thenReturn(faultNotificationsRepositoryMock); + when(faultNotificationsRepositoryMock.getFaultNotificationFromQueue()).thenReturn(notificationString); + + Either, Integer> result = component.getFaultNotifications(); + // assertTrue(result.isLeft()); + assertNotNull(result); + + + } + + private static String readFromFile(String file) { + String content = new String(); + try { + + InputStream is = DmaapNotificationsComponentTest.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) { + content = null; + } + return content; + } + +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/HoMetricsComponentTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/HoMetricsComponentTest.java new file mode 100644 index 0000000..9ac056b --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/HoMetricsComponentTest.java @@ -0,0 +1,101 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * son-handler + * ================================================================================ + * Copyright (C) 2019 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.dcaegen2.services.sonhms; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.mockito.Mockito.when; + +import fj.data.Either; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.List; + +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.onap.dcaegen2.services.sonhms.dao.HandOverMetricsRepository; +import org.onap.dcaegen2.services.sonhms.model.HoDetails; +import org.onap.dcaegen2.services.sonhms.utils.BeanUtil; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.powermock.modules.junit4.PowerMockRunnerDelegate; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(PowerMockRunner.class) +@PowerMockRunnerDelegate(SpringRunner.class) +@PrepareForTest({ BeanUtil.class }) +@SpringBootTest(classes = HoMetricsComponentTest.class) +public class HoMetricsComponentTest { + + @Mock + HandOverMetricsRepository handOverMetricsRepositoryMock; + + @InjectMocks + HoMetricsComponent hoMetricsComponent; + + static String hoDetailsString; + + @BeforeClass + public static void setup() { + hoDetailsString=readFromFile("/hoDetails.json"); + } + + @Test + public void getHoMetricsTest() { + PowerMockito.mockStatic(BeanUtil.class); + PowerMockito.when(BeanUtil + .getBean(HandOverMetricsRepository.class)).thenReturn(handOverMetricsRepositoryMock); + when(handOverMetricsRepositoryMock.getHandOverMetrics("")).thenReturn(hoDetailsString); + Either, Integer> result = hoMetricsComponent.getHoMetrics(""); + assertNotNull(result.left().value()); + when(handOverMetricsRepositoryMock.getHandOverMetrics("")).thenReturn("wrongText"); + result = hoMetricsComponent.getHoMetrics(""); + int res= result.right().value(); + assertEquals(400,res); + } + + private static String readFromFile(String file) { + String content = new String(); + try { + + InputStream is = HoMetricsComponentTest.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) { + content = null; + } + return content; + } +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/PMNotificationHandlerTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/PMNotificationHandlerTest.java new file mode 100644 index 0000000..e2e702c --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/PMNotificationHandlerTest.java @@ -0,0 +1,117 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * pcims + * ================================================================================ + * 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========================================================= + ******************************************************************************/ + +package org.onap.dcaegen2.services.sonhms; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.when; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +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.PMNotification; +import org.onap.dcaegen2.services.sonhms.utils.BeanUtil; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.powermock.modules.junit4.PowerMockRunnerDelegate; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(PowerMockRunner.class) +@PowerMockRunnerDelegate(SpringRunner.class) +@PrepareForTest({ BeanUtil.class }) +@SpringBootTest(classes = PMNotificationHandlerTest.class) +public class PMNotificationHandlerTest { + + @Mock + HandOverMetricsRepository handOverMetricsRepositoryMock; + + @InjectMocks + PMNotificationHandler pmNotificationHandler; + + @Mock + PolicyDmaapClient policyDmaapClient; + + private static String pmNotificationsString ; + private static String pmNotificationsString1 ; + 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(); + + try { + pmNotification = mapper.readValue(pmNotificationsString, PMNotification.class); + pmNotification1 = mapper.readValue(pmNotificationsString1, PMNotification.class); + } catch(Exception e) { + e.printStackTrace(); + } + } + + @Test + public void handlePmNotificationsTest() { + PowerMockito.mockStatic(BeanUtil.class); + PowerMockito.when(BeanUtil + .getBean(HandOverMetricsRepository.class)).thenReturn(handOverMetricsRepositoryMock); + when(handOverMetricsRepositoryMock.save(new HandOverMetrics())).thenReturn(null); + when(policyDmaapClient.sendNotificationToPolicy(Mockito.anyString())).thenReturn(true); + assertTrue(pmNotificationHandler.handlePmNotifications(pmNotification, 50)); + assertFalse(pmNotificationHandler.handlePmNotifications(null, 0)); + assertTrue(pmNotificationHandler.handlePmNotifications(pmNotification1, 50)); + } + + private static String readFromFile(String file) { + String content = new String(); + try { + + InputStream is = HoMetricsComponentTest.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) { + content = null; + } + return content; + } + +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadTest.java new file mode 100644 index 0000000..a27360e --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadTest.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * ============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.child; + +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.when; + +import fj.data.Either; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; +import org.onap.dcaegen2.services.sonhms.Configuration; +import org.onap.dcaegen2.services.sonhms.HoMetricsComponent; +import org.onap.dcaegen2.services.sonhms.model.HoDetails; +import org.springframework.boot.test.context.SpringBootTest; + +@RunWith(MockitoJUnitRunner.class) +@SpringBootTest(classes = ChildThreadTest.class) +public class ChildThreadTest { + + @Mock + HoMetricsComponent hoMetricsComponent; + + @InjectMocks + ChildThread childThread; + + @Test + public void checkAnrTriggerTest() { + ArrayList cellidList = new ArrayList<>(); + cellidList.add("cell1"); + //PowerMockito.mockStatic(Configuration.class); + Configuration config = Configuration.getInstance() ; + config.setPoorThreshold(70); + //PowerMockito.when(Configuration.getInstance()).thenReturn(config); + Either, Integer> response = null; + HoDetails hoDetail = new HoDetails(); + hoDetail.setDstCellId("dstCell1"); + hoDetail.setSuccessRate(60); + List hoDetailsList = new ArrayList<>(); + hoDetailsList.add(hoDetail); + response = Either.left(hoDetailsList); + when(hoMetricsComponent.getHoMetrics(Mockito.anyString())).thenReturn(response); + assertTrue(childThread.checkAnrTrigger(cellidList).isLeft()); + } + +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/child/StateOofTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/child/StateOofTest.java new file mode 100644 index 0000000..32bfbcf --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/child/StateOofTest.java @@ -0,0 +1,83 @@ +/******************************************************************************* + * ============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.child; + +import static org.junit.Assert.assertNotNull; + +import java.util.ArrayList; +import java.util.UUID; +import java.util.concurrent.LinkedBlockingQueue; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.onap.dcaegen2.services.sonhms.exceptions.OofNotFoundException; +import org.onap.dcaegen2.services.sonhms.restclient.OofRestClient; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.powermock.modules.junit4.PowerMockRunnerDelegate; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(PowerMockRunner.class) +@PowerMockRunnerDelegate(SpringRunner.class) +@PrepareForTest({OofRestClient.class}) +@SpringBootTest(classes = StateOof.class) +public class StateOofTest { + + StateOof oof; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + oof = new StateOof(new LinkedBlockingQueue<>()); + } + + + UUID transactionId; + + @SuppressWarnings("unchecked") + @Test + public void triggerOofTest() { + ArrayList cellList = new ArrayList<>(); + cellList.add("cell1"); + PowerMockito.mockStatic(OofRestClient.class); + try { + PowerMockito.when(OofRestClient.queryOof(Mockito.anyInt(), Mockito.anyString(), Mockito.anyString(), Mockito.anyList(), + Mockito.anyString(), Mockito.anyList(), Mockito.anyList())).thenReturn("oofResponse"); + } catch (OofNotFoundException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + try { + transactionId = oof.triggerOof(cellList, "networkId", null); + } catch (OofNotFoundException | InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + assertNotNull(transactionId); + } +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/child/TestChildThreadUtils.java b/src/test/java/org/onap/dcaegen2/services/sonhms/child/TestChildThreadUtils.java index ca5f5fd..ab4119d 100644 --- a/src/test/java/org/onap/dcaegen2/services/sonhms/child/TestChildThreadUtils.java +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/child/TestChildThreadUtils.java @@ -21,6 +21,11 @@ package org.onap.dcaegen2.services.sonhms.child; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.when; + import com.fasterxml.jackson.databind.ObjectMapper; import java.io.BufferedReader; @@ -35,77 +40,175 @@ import java.util.Map; import org.junit.Assert; 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.MockitoAnnotations; import org.onap.dcaegen2.services.sonhms.ConfigPolicy; +import org.onap.dcaegen2.services.sonhms.Configuration; +import org.onap.dcaegen2.services.sonhms.dao.SonRequestsRepository; +import org.onap.dcaegen2.services.sonhms.dmaap.PolicyDmaapClient; +import org.onap.dcaegen2.services.sonhms.entity.SonRequests; +import org.onap.dcaegen2.services.sonhms.exceptions.ConfigDbNotFoundException; import org.onap.dcaegen2.services.sonhms.model.CellPciPair; import org.onap.dcaegen2.services.sonhms.model.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; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.powermock.modules.junit4.PowerMockRunnerDelegate; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; +@RunWith(PowerMockRunner.class) +@PowerMockRunnerDelegate(SpringRunner.class) +@PrepareForTest({ BeanUtil.class, SdnrRestClient.class }) +@SpringBootTest(classes = TestChildThreadUtils.class) public class TestChildThreadUtils { - - ChildThreadUtils childThreadUtils; - - @Before - public void setup() { - - ConfigPolicy configPolicy = ConfigPolicy.getInstance(); - - Map configPolicyMap = new HashMap<>(); - configPolicyMap.put("PCI_MODCONFIG_POLICY_NAME", "ControlLoop-vPCI-fb41f388-a5f2-11e8-98d0-529269fb1459"); - configPolicy.setConfig(configPolicyMap); - childThreadUtils = new ChildThreadUtils(configPolicy); - } - - @Test - public void getNotificationStringTest() { - - String policy_notif = readFromFile("/policy_notification.json"); - PolicyNotification expected = new PolicyNotification(); - ObjectMapper mapper = new ObjectMapper(); - - try { - expected = mapper.readValue(policy_notif, PolicyNotification.class); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - String pnfName = "ncserver23"; - List cellPciPairs = new ArrayList<>(); - - cellPciPairs.add(new CellPciPair("Chn0330", 6)); - cellPciPairs.add(new CellPciPair("Chn0331", 7)); - String requestId = "a4130fd5-2291-4a83-8992-04e4c9f32731"; - Long alarmStart = Long.parseLong("1542445563201"); - - String result = childThreadUtils.getNotificationString(pnfName, cellPciPairs, requestId, alarmStart); - PolicyNotification actual = new PolicyNotification(); - try { - actual = mapper.readValue(result, PolicyNotification.class); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - Assert.assertEquals(expected.hashCode(), actual.hashCode()); - } - - private static String readFromFile(String file) { - String content = new String(); + + ChildThreadUtils childThreadUtils; + @Mock + private SonRequestsRepository repository; + + @Mock + private PnfUtils pnfUtils; + @Mock + private PolicyDmaapClient policyDmaapClient; + + @InjectMocks + private ChildThreadUtils childThreadUtils2; + + @Before + public void setup() { + + ConfigPolicy configPolicy = ConfigPolicy.getInstance(); + Configuration config = Configuration.getInstance(); + config.setMinCollision(5); + config.setMinConfusion(5); + Map configPolicyMap = new HashMap<>(); + configPolicyMap.put("PCI_MODCONFIG_POLICY_NAME", "ControlLoop-vPCI-fb41f388-a5f2-11e8-98d0-529269fb1459"); + configPolicy.setConfig(configPolicyMap); + childThreadUtils = new ChildThreadUtils(configPolicy, pnfUtils, policyDmaapClient); + MockitoAnnotations.initMocks(this); + + } + + @Test + public void savePciRequestTest() { + SonRequests sonRequest = new SonRequests(); + sonRequest.setTransactionId("transactionId"); + sonRequest.setChildThreadId(1L); + PowerMockito.mockStatic(BeanUtil.class); + PowerMockito.when(BeanUtil.getBean(SonRequestsRepository.class)) + .thenReturn(repository); + when(repository.save(sonRequest)).thenReturn(sonRequest); + childThreadUtils2.saveRequest("transactionId",1L);; + assertEquals(sonRequest, repository.save(sonRequest)); + } + + @Test + public void triggerOrWaitTest() { + Map> collisionConfusionResult = new HashMap>(); + ArrayList list = new ArrayList(); + list.add(6); + list.add(7); + collisionConfusionResult.put("cellId", list); + + Boolean result = childThreadUtils.triggerOrWait(collisionConfusionResult); + assertTrue(result); + Map> collisionConfusionResult1 = new HashMap>(); + + ArrayList list1 = new ArrayList(); + list1.add(1); + list1.add(2); + collisionConfusionResult1.put("cell1", list1); + result = childThreadUtils.triggerOrWait(collisionConfusionResult1); + assertFalse(result); + + } + + @Test + public void getNotificationStringTest() { + + String policy_notif = readFromFile("/policy_notification.json"); + PolicyNotification expected = new PolicyNotification(); + ObjectMapper mapper = new ObjectMapper(); + + try { + expected = mapper.readValue(policy_notif, PolicyNotification.class); + } catch (IOException e) { + e.printStackTrace(); + } + + String pnfName = "ncserver23"; + List cellPciPairs = new ArrayList<>(); + + cellPciPairs.add(new CellPciPair("Chn0330", 6)); + cellPciPairs.add(new CellPciPair("Chn0331", 7)); + String requestId = "a4130fd5-2291-4a83-8992-04e4c9f32731"; + Long alarmStart = Long.parseLong("1542445563201"); + + String result = childThreadUtils.getNotificationString(pnfName, cellPciPairs, requestId, alarmStart); + PolicyNotification actual = new PolicyNotification(); + try { + actual = mapper.readValue(result, PolicyNotification.class); + } catch (IOException e) { + e.printStackTrace(); + } + System.out.println("actual :; "+result+"\nexp "+policy_notif); + Assert.assertEquals(expected.hashCode(), actual.hashCode()); + } + + @Test + public void sendToPolicyTest() throws ConfigDbNotFoundException { + + PowerMockito.mockStatic(SdnrRestClient.class); + String asyncRspBodyString = readFromFile("/AsyncRespBody.json"); + ObjectMapper mapper = new ObjectMapper(); + AsyncResponseBody async = new AsyncResponseBody (); 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) { + async = mapper.readValue(asyncRspBodyString, AsyncResponseBody.class); + } catch (Exception e) { e.printStackTrace(); - content = null; } - return content; - } + PowerMockito.when(SdnrRestClient.getPci(Mockito.anyString())).thenReturn(3); + PowerMockito.when(SdnrRestClient.getPnfName(Mockito.anyString())).thenReturn("pnfName"); + when(policyDmaapClient.sendNotificationToPolicy(Mockito.anyString())).thenReturn(true); + Map> pnfsMap = new HashMap>(); + CellPciPair cell1 = new CellPciPair("cell0", 1); + CellPciPair cell2 = new CellPciPair("cell1", 2); + CellPciPair cell3 = new CellPciPair("cell2", 3); + List pciPairList = new ArrayList<>(); + pciPairList.add(cell1); + pciPairList.add(cell2); + pciPairList.add(cell3); + pnfsMap.put("pnf1", pciPairList); + when(pnfUtils.getPnfs(Mockito.any(Solutions.class))).thenReturn(pnfsMap); + childThreadUtils.sendToPolicy(async); + } + + 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; + } } diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/child/TestDetection.java b/src/test/java/org/onap/dcaegen2/services/sonhms/child/TestDetection.java index 05d3e79..81641f3 100644 --- a/src/test/java/org/onap/dcaegen2/services/sonhms/child/TestDetection.java +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/child/TestDetection.java @@ -22,6 +22,8 @@ package org.onap.dcaegen2.services.sonhms.child; +import static org.junit.Assert.assertEquals; + import java.util.ArrayList; import java.util.HashMap; import java.util.Map; @@ -105,10 +107,9 @@ public class TestDetection { cluster.setCellPciNeighbourMap(map); - System.out.println("mapsssssss" + cluster.getCellPciNeighbourMap()); Detection detect = new Detection(); - detect.detectCollisionConfusion(cluster); - System.out.println("result" + detect.detectCollisionConfusion(cluster)); + Map> resultmap=detect.detectCollisionConfusion(cluster); + assertEquals("{78=[], 56=[], 67=[], 24=[], 25=[0, 1], 69=[], 38=[], 42=[0, 0], 21=[], 32=[1, 0]}", resultmap.toString()); } diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/child/TestPnfUtils.java b/src/test/java/org/onap/dcaegen2/services/sonhms/child/TestPnfUtils.java index 0349521..4b36598 100644 --- a/src/test/java/org/onap/dcaegen2/services/sonhms/child/TestPnfUtils.java +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/child/TestPnfUtils.java @@ -22,7 +22,6 @@ package org.onap.dcaegen2.services.sonhms.child; import static org.junit.Assert.assertEquals; -import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import java.io.BufferedReader; @@ -48,7 +47,7 @@ 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.SdnrRestClient; -import org.onap.dcaegen2.services.sonhms.restclient.Solution; +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; @@ -69,7 +68,7 @@ public class TestPnfUtils { private CellInfoRepository cellInfoRepositoryMock; private static final Logger log = org.slf4j.LoggerFactory.getLogger(TestPnfUtils.class); - private static List solutions = new ArrayList<>(); + private static Solutions solutions = new Solutions(); private static Optional cellInfo; private static Optional cellInfoNull; @@ -85,7 +84,7 @@ public class TestPnfUtils { ObjectMapper mapper = new ObjectMapper(); try { - solutions=mapper.readValue(solutionsString,new TypeReference>(){}); + solutions=mapper.readValue(solutionsString, Solutions.class); } catch (IOException e) { log.debug("Exception in StateOof Test "+e); e.printStackTrace(); diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationProducerTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationProducerTest.java index 4fa8227..486ed27 100644 --- a/src/test/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationProducerTest.java +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationProducerTest.java @@ -27,6 +27,7 @@ import static org.mockito.Mockito.when; import com.att.nsa.cambria.client.CambriaBatchingPublisher; import java.io.IOException; + import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/entity/PciRequestsTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/entity/PciRequestsTest.java index bf22fd6..488c671 100644 --- a/src/test/java/org/onap/dcaegen2/services/sonhms/entity/PciRequestsTest.java +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/entity/PciRequestsTest.java @@ -29,10 +29,10 @@ public class PciRequestsTest { @Test public void pciRequestsTest() { - PciRequests pciRequests=new PciRequests(); - pciRequests.setChildThreadId(1L); - pciRequests.setTransactionId("transactionId"); - assertEquals(1L, pciRequests.getChildThreadId()); - assertEquals("transactionId", pciRequests.getTransactionId()); + SonRequests sonRequests=new SonRequests(); + sonRequests.setChildThreadId(1L); + sonRequests.setTransactionId("transactionId"); + assertEquals(1L, sonRequests.getChildThreadId()); + assertEquals("transactionId", sonRequests.getTransactionId()); } } diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/model/NotificationTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/model/NotificationTest.java index 29590f9..12c4912 100644 --- a/src/test/java/org/onap/dcaegen2/services/sonhms/model/NotificationTest.java +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/model/NotificationTest.java @@ -45,7 +45,7 @@ public class NotificationTest { ArrayList list = new ArrayList<>(); list.add(lteNeighborListInUseLteCell); - NeighborListInUse neighborListInUse = new NeighborListInUse(list, "1"); + NeighborListInUse neighborListInUse = new NeighborListInUse(list, null, "1"); NotificationRan notificationRan = new NotificationRan(neighborListInUse, "Cell25"); NotificationLte notificationLte = new NotificationLte(notificationRan); diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/model/PayloadTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/model/PayloadTest.java index 1aae8c2..e89c8c3 100644 --- a/src/test/java/org/onap/dcaegen2/services/sonhms/model/PayloadTest.java +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/model/PayloadTest.java @@ -35,7 +35,7 @@ public class PayloadTest { public void payloadTest() { Common common = new Common("cell1"); - Ran ran = new Ran(common); + Ran ran = new Ran(common, null); Lte lte = new Lte(ran); diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/AsyncResponseBodyTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/AsyncResponseBodyTest.java index fcc2c31..a97bd1a 100644 --- a/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/AsyncResponseBodyTest.java +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/AsyncResponseBodyTest.java @@ -21,6 +21,8 @@ package org.onap.dcaegen2.services.sonhms.restclient; +import static org.junit.Assert.assertEquals; + import java.util.ArrayList; import java.util.List; @@ -35,20 +37,28 @@ public class AsyncResponseBodyTest { AsyncResponseBody asyncResponseBody = new AsyncResponseBody(); asyncResponseBody.setRequestId("e44a4165-3cf4-4362-89de-e2375eed97e7"); asyncResponseBody.setRequestStatus("completed"); - SonSolution pciSolutions = new SonSolution(); + PciSolutions pciSolutions = new PciSolutions(); + AnrSolutions anrSolutions = new AnrSolutions(); + pciSolutions.setCellId("EXP001"); pciSolutions.setPci(101); - List pciSolutionsList = new ArrayList(); + anrSolutions.setCellId("cell2"); + + List pciSolutionsList = new ArrayList(); + List anrSolutionsList = new ArrayList(); + + anrSolutionsList.add(anrSolutions); pciSolutionsList.add(pciSolutions); - Solution solutions = new Solution(); - solutions.setFinishTime("2018-10-01T00:40+01.00"); - solutions.setNetworkId("EXP001"); + Solutions solutions = new Solutions(); solutions.setPciSolutions(pciSolutionsList); - solutions.setStartTime("2018-10-01T00:30+01:00"); - ArrayList solutionsList = new ArrayList(); - solutionsList.add(solutions); - asyncResponseBody.setSolutions(solutionsList); + solutions.setAnrSolutions(anrSolutionsList); + asyncResponseBody.setSolutions(solutions); asyncResponseBody.setStatusMessage("success"); asyncResponseBody.setTransactionId("3df7b0e9-26d1-4080-ba42-28e8a3139689"); + assertEquals("success", asyncResponseBody.getStatusMessage()); + assertEquals("3df7b0e9-26d1-4080-ba42-28e8a3139689", asyncResponseBody.getTransactionId()); + assertEquals(solutions, asyncResponseBody.getSolutions()); + assertEquals("completed", asyncResponseBody.getRequestStatus()); + assertEquals("e44a4165-3cf4-4362-89de-e2375eed97e7", asyncResponseBody.getRequestId()); } } diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/OofRestClientTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/OofRestClientTest.java index 75af4fe..7451ca5 100644 --- a/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/OofRestClientTest.java +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/OofRestClientTest.java @@ -34,6 +34,7 @@ import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.onap.dcaegen2.services.sonhms.Configuration; import org.onap.dcaegen2.services.sonhms.exceptions.OofNotFoundException; +import org.onap.dcaegen2.services.sonhms.model.AnrInput; import org.onap.dcaegen2.services.sonhms.utils.SonHandlerRestTemplate; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; @@ -85,6 +86,7 @@ public class OofRestClientTest { cellIdList.add("EXP001"); List optimizers=new ArrayList(); optimizers.add("pci"); + List anrInputList = new ArrayList<>(); PowerMockito.mockStatic(SonHandlerRestTemplate.class); PowerMockito.mockStatic(Configuration.class); @@ -94,7 +96,8 @@ public class OofRestClientTest { try { - String result=OofRestClient.queryOof(1, "xxx-xxx-xxxx", "create", cellIdList, "NTWK005", optimizers); + + String result=OofRestClient.queryOof(1, "xxx-xxx-xxxx", "create", cellIdList, "NTWK005", optimizers, anrInputList); assertEquals(ResponseEntity.ok(responseBody).getBody(), result); @@ -105,9 +108,8 @@ public class OofRestClientTest { PowerMockito.when(SonHandlerRestTemplate.sendPostRequestToOof(Mockito.anyString(),Mockito.anyString() ,Matchers.>any())) .thenReturn(null); try { - String result=OofRestClient.queryOof(1, "xxx-xxx-xxxx", "create", cellIdList, "NTWK005", optimizers); - assertEquals(ResponseEntity.ok(responseBody).getBody(), result); + OofRestClient.queryOof(1, "xxx-xxx-xxxx", "create", cellIdList, "NTWK005", optimizers, new ArrayList<>()); } catch (OofNotFoundException e) { // TODO Auto-generated catch block diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/PciSolutionsTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/PciSolutionsTest.java index 79d27ad..1ff0546 100644 --- a/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/PciSolutionsTest.java +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/PciSolutionsTest.java @@ -29,7 +29,7 @@ import org.junit.Test; public class PciSolutionsTest { @Test public void pciSolutionsTest() { - SonSolution pciSolutions = new SonSolution(); + PciSolutions pciSolutions = new PciSolutions(); pciSolutions.setCellId("EXP001"); pciSolutions.setPci(101); assertEquals("EXP001", pciSolutions.getCellId()); diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/SdnrRestClientTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/SdnrRestClientTest.java index bffccfc..1557e51 100644 --- a/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/SdnrRestClientTest.java +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/SdnrRestClientTest.java @@ -37,6 +37,7 @@ import org.mockito.MockitoAnnotations; 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; @@ -53,7 +54,9 @@ import org.springframework.test.context.junit4.SpringRunner; @PrepareForTest({ SonHandlerRestTemplate.class,Configuration.class }) @SpringBootTest(classes = SdnrRestClientTest.class) public class SdnrRestClientTest { - + + + Configuration configuration = Configuration.getInstance(); private static final Logger log = org.slf4j.LoggerFactory.getLogger(SdnrRestClient.class); @Before @@ -68,6 +71,7 @@ public class SdnrRestClientTest { " \"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.>any())) diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/SolutionsTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/SolutionsTest.java index 9286629..75cd881 100644 --- a/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/SolutionsTest.java +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/SolutionsTest.java @@ -35,20 +35,26 @@ public class SolutionsTest { @Test public void solutionsTest() { - SonSolution pciSolutions = new SonSolution(); + Solutions solutions = new Solutions(); + List anrSolutionsList = new ArrayList<>(); + List pciSolutionsList = new ArrayList<>(); + + PciSolutions pciSolutions = new PciSolutions(); pciSolutions.setCellId("EXP001"); pciSolutions.setPci(101); - List pciSolutionsList = new ArrayList(); pciSolutionsList.add(pciSolutions); - Solution solutions = new Solution(); - solutions.setFinishTime("2018-10-01T00:40+01.00"); + AnrSolutions anrSolutions = new AnrSolutions(); + anrSolutions.setCellId("EXP001"); + List removeableNeighbors = new ArrayList<>(); + removeableNeighbors.add("cell001"); + anrSolutions.setRemoveableNeighbors(removeableNeighbors); + anrSolutionsList.add(anrSolutions); solutions.setNetworkId("EXP001"); solutions.setPciSolutions(pciSolutionsList); - solutions.setStartTime("2018-10-01T00:30+01:00"); - assertEquals("2018-10-01T00:40+01.00", solutions.getFinishTime()); + solutions.setAnrSolutions(anrSolutionsList); assertEquals("EXP001", solutions.getNetworkId()); assertEquals(pciSolutionsList, solutions.getPciSolutions()); - assertEquals("2018-10-01T00:30+01:00", solutions.getStartTime()); + assertEquals(anrSolutionsList, solutions.getAnrSolutions()); } diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtilsTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtilsTest.java index 48813e1..03305a1 100644 --- a/src/test/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtilsTest.java +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtilsTest.java @@ -67,205 +67,211 @@ import org.springframework.test.context.junit4.SpringRunner; @PowerMockRunnerDelegate(SpringRunner.class) @PrepareForTest({ SdnrRestClient.class, BeanUtil.class }) @SpringBootTest(classes = ClusterUtils.class) -public class ClusterUtilsTest { - +public class ClusterUtilsTest { + @Mock private ClusterDetailsRepository clusterDetailsRepositoryMock; - + @InjectMocks ClusterUtils clusterUtils; - + private static Notification notification1; private static Notification notification2; private static List clusterDetailsForGetClusterDetailsFromClusterIdTest; private static Graph cluster; private static List clusterDetails = new ArrayList<>(); - + @BeforeClass public static void setup() { - + notification1 = new Notification(); notification2 = new Notification(); clusterDetailsForGetClusterDetailsFromClusterIdTest = new ArrayList(); - + String notificationString1 = readFromFile("/notification1.json"); String notificationString2 = readFromFile("/notification2.json"); - String clusterDetailsListString=readFromFile("/ClusterDetailsTest.json"); - + String clusterDetailsListString = readFromFile("/ClusterDetailsTest.json"); + String clusterInfo1 = readFromFile("/clusterInfo1.json"); String clusterInfo2 = readFromFile("/clusterInfo2.json"); String clusterInfo3 = readFromFile("/clusterInfo3.json"); String clusterInfo4 = readFromFile("/clusterInfo4.json"); String clusterInfo = readFromFile("/clusterInfo5.json"); - cluster=new Graph(clusterInfo); - + cluster = new Graph(clusterInfo); + clusterDetails.add(new ClusterDetails("1", clusterInfo1, 35)); clusterDetails.add(new ClusterDetails("2", clusterInfo2, 36)); clusterDetails.add(new ClusterDetails("3", clusterInfo3, 37)); clusterDetails.add(new ClusterDetails("4", clusterInfo4, 38)); - - + ObjectMapper mapper = new ObjectMapper(); - + try { notification1 = mapper.readValue(notificationString1, Notification.class); notification2 = mapper.readValue(notificationString2, Notification.class); - clusterDetailsForGetClusterDetailsFromClusterIdTest=mapper.readValue(clusterDetailsListString,new TypeReference>(){}); + clusterDetailsForGetClusterDetailsFromClusterIdTest = mapper.readValue(clusterDetailsListString, + new TypeReference>() { + }); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } - - - + } - + @Before public void setupTest() { - clusterUtils = new ClusterUtils(); + clusterUtils = new ClusterUtils(); MockitoAnnotations.initMocks(this); - } - + } + @Test - public void getClustersForNotificationTest(){ - + public void getClustersForNotificationTest() { + NotificationToClusterMapping expected = new NotificationToClusterMapping(); Map cellsinCluster = new HashMap<>(); cellsinCluster.put(notification1.getPayload().getRadioAccess().getFapServiceList().get(0), "2"); expected.setCellsinCluster(cellsinCluster); expected.setNewCells(new ArrayList()); - + NotificationToClusterMapping result = clusterUtils.getClustersForNotification(notification1, clusterDetails); assertEquals(expected, result); - + expected = new NotificationToClusterMapping(); List newCells = new ArrayList<>(); newCells.add(notification2.getPayload().getRadioAccess().getFapServiceList().get(0)); expected.setCellsinCluster(new HashMap<>()); expected.setNewCells(newCells); - + result = clusterUtils.getClustersForNotification(notification2, clusterDetails); assertEquals(expected, result); } - + @Test public void createClusterTest() throws ConfigDbNotFoundException { - - FapServiceList fapServiceList = notification1.getPayload().getRadioAccess().getFapServiceList().get(0); - + + Map> clusterMap = new HashMap>(); + + List firstNbrList = new ArrayList<>(); List nbrList = new ArrayList<>(); - + + firstNbrList.add(new CellPciPair("48", 0)); nbrList.add(new CellPciPair("44", 3)); - + PowerMockito.mockStatic(SdnrRestClient.class); - + PowerMockito.when(SdnrRestClient.getNbrList(Mockito.anyString())).thenReturn(nbrList); - - assertEquals(cluster, clusterUtils.createCluster(fapServiceList)); - - - + + clusterMap.put(new CellPciPair("45", 310), (ArrayList) firstNbrList); + + assertEquals(cluster, clusterUtils.createCluster(clusterMap)); + } - + @Test public void getClusterDetailsFromClusterIdTest() { - ClusterDetails responseValue=null; + ClusterDetails responseValue = null; Integer responseVal = null; - Integer expectedValue=404; - Either response=clusterUtils.getClusterDetailsFromClusterId("0",clusterDetailsForGetClusterDetailsFromClusterIdTest); + Integer expectedValue = 404; + Either response = clusterUtils.getClusterDetailsFromClusterId("0", + clusterDetailsForGetClusterDetailsFromClusterIdTest); assertTrue(response.isLeft()); - if(response.isLeft()) { - responseValue=response.left().value(); + if (response.isLeft()) { + responseValue = response.left().value(); } - assertEquals(clusterDetailsForGetClusterDetailsFromClusterIdTest.get(0),responseValue); - response=clusterUtils.getClusterDetailsFromClusterId("1",clusterDetailsForGetClusterDetailsFromClusterIdTest); + assertEquals(clusterDetailsForGetClusterDetailsFromClusterIdTest.get(0), responseValue); + response = clusterUtils.getClusterDetailsFromClusterId("1", + clusterDetailsForGetClusterDetailsFromClusterIdTest); assertTrue(response.isLeft()); - if(response.isLeft()) { - responseValue=response.left().value(); + if (response.isLeft()) { + responseValue = response.left().value(); } - assertEquals(clusterDetailsForGetClusterDetailsFromClusterIdTest.get(1),responseValue); - response=clusterUtils.getClusterDetailsFromClusterId("9",clusterDetailsForGetClusterDetailsFromClusterIdTest); + assertEquals(clusterDetailsForGetClusterDetailsFromClusterIdTest.get(1), responseValue); + response = clusterUtils.getClusterDetailsFromClusterId("9", + clusterDetailsForGetClusterDetailsFromClusterIdTest); assertTrue(response.isRight()); - if(response.isRight()) { - responseVal=response.right().value(); + if (response.isRight()) { + responseVal = response.right().value(); } - assertEquals(expectedValue,responseVal); + assertEquals(expectedValue, responseVal); } - + @Test public void saveClusterTest() { - ClusterDetails details = new ClusterDetails(); - details.setClusterId("123e4567-e89b-12d3-a456-426655440000"); - details.setClusterInfo("cellPciNeighbourString"); - details.setChildThreadId(978668); - PowerMockito.mockStatic(BeanUtil.class); - PowerMockito.when(BeanUtil.getBean(ClusterDetailsRepository.class)) - .thenReturn(clusterDetailsRepositoryMock); - Mockito.when(clusterDetailsRepositoryMock.save(details)).thenReturn(details); - Long threadId=(long) 978668; - clusterUtils.saveCluster(cluster, UUID.fromString("123e4567-e89b-12d3-a456-426655440000"),threadId); - assertEquals(details, clusterDetailsRepositoryMock.save(details)); + ClusterDetails details = new ClusterDetails(); + details.setClusterId("123e4567-e89b-12d3-a456-426655440000"); + details.setClusterInfo("cellPciNeighbourString"); + details.setChildThreadId(978668); + PowerMockito.mockStatic(BeanUtil.class); + PowerMockito.when(BeanUtil.getBean(ClusterDetailsRepository.class)).thenReturn(clusterDetailsRepositoryMock); + Mockito.when(clusterDetailsRepositoryMock.save(details)).thenReturn(details); + Long threadId = (long) 978668; + clusterUtils.saveCluster(cluster, UUID.fromString("123e4567-e89b-12d3-a456-426655440000"), threadId); + assertEquals(details, clusterDetailsRepositoryMock.save(details)); } - + @Test public void getClusterForCellTest() { - FapServiceList fapServiceList= notification1.getPayload().getRadioAccess().getFapServiceList().get(0); - String clusterInfo1=readFromFile("/clusterInfo1.json"); - String clusterInfo2=readFromFile("/clusterInfo2.json"); - Graph graph1=new Graph(clusterInfo1); - Graph graph2=new Graph(clusterInfo2); - List newClusters=new ArrayList(); + FapServiceList fapServiceList = notification1.getPayload().getRadioAccess().getFapServiceList().get(0); + String clusterInfo1 = readFromFile("/clusterInfo1.json"); + String clusterInfo2 = readFromFile("/clusterInfo2.json"); + Graph graph1 = new Graph(clusterInfo1); + Graph graph2 = new Graph(clusterInfo2); + List newClusters = new ArrayList(); newClusters.add(graph1); newClusters.add(graph2); - Either result=clusterUtils.getClusterForCell(fapServiceList, newClusters); + Either result = clusterUtils.getClusterForCell(fapServiceList, newClusters); assertTrue(result.isLeft()); - + newClusters = new ArrayList<>(); newClusters.add(graph1); - result=clusterUtils.getClusterForCell(fapServiceList, newClusters); + result = clusterUtils.getClusterForCell(fapServiceList, newClusters); assertTrue(result.isRight()); - int resultRight=result.right().value(); + int resultRight = result.right().value(); assertEquals(404, resultRight); - - List emptyList=new ArrayList(); - - result=clusterUtils.getClusterForCell(fapServiceList, emptyList); + + List emptyList = new ArrayList(); + + result = clusterUtils.getClusterForCell(fapServiceList, emptyList); assertTrue(result.isRight()); - resultRight=result.right().value(); + resultRight = result.right().value(); assertEquals(404, resultRight); - + } - + @Test public void modifyClusterTest() { - + String clusterInfo = readFromFile("/clusterInfo2.json"); String clusterInfo2 = readFromFile("/clusterInfo6.json"); - + Graph cluster = new Graph(clusterInfo); Graph expected = new Graph(clusterInfo2); - - assertEquals(expected, clusterUtils.modifyCluster(cluster, notification1.getPayload().getRadioAccess().getFapServiceList().get(0))); + Map> clusterMap = new HashMap>(); + + ArrayList firstNbrList = new ArrayList<>(); + firstNbrList.add(new CellPciPair("48",0)); + clusterMap.put(new CellPciPair("45",310),firstNbrList); + assertEquals(expected, clusterUtils.modifyCluster(cluster,clusterMap)); } - + private static String readFromFile(String file) { - String content = new String(); + 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) { + while ((temp = bufferedReader.readLine()) != null) { content = content.concat(temp); } content = content.trim(); bufferedReader.close(); - } - catch(Exception e) { - content = null; + } catch (Exception e) { + content = null; } return content; } diff --git a/src/test/resources/AsyncRespBody.json b/src/test/resources/AsyncRespBody.json new file mode 100644 index 0000000..08a8e51 --- /dev/null +++ b/src/test/resources/AsyncRespBody.json @@ -0,0 +1,23 @@ +{ + "requestId":"9d2d790e-a5f0-11e8-98d0-529269fb1459", + "transactionId":"9d2d790e-a5f0-11e8-98d0-529269fb1458", + "statusMessage":"accepted", + "requestStatus":"success", + "solutions":{ + "networkId":"NTWK005", + "pciSolutions":[ + { + "cellId":"EXP001", + "pci":"101" + }, + { + "cellId":"EXP002", + "pci":"102" + } + ], + "anrSolutions":[ + {"cellId":"EXP003", + "removeableNeighbors":["EXP006"]} + ] + } +} diff --git a/src/test/resources/ClusterDetailsTest.json b/src/test/resources/ClusterDetailsTest.json index 01839ae..24b6d8d 100644 --- a/src/test/resources/ClusterDetailsTest.json +++ b/src/test/resources/ClusterDetailsTest.json @@ -1,10 +1,13 @@ -[{"clusterId":"0", -"clusterInfo":"", - "childThreadId":986476 -}, -{"clusterId":"1", -"clusterInfo":"", - "childThreadId":986475 -} +[ + { + "clusterId": "0", + "clusterInfo": "", + "childThreadId": 986476 + }, + { + "clusterId": "1", + "clusterInfo": "", + "childThreadId": 986475 + } ] diff --git a/src/test/resources/clusterInfo1.json b/src/test/resources/clusterInfo1.json index 685d923..d78d86e 100644 --- a/src/test/resources/clusterInfo1.json +++ b/src/test/resources/clusterInfo1.json @@ -1 +1,12 @@ -[{"cellId":"29","physicalCellId":209,"neighbours":"[]"},{"cellId":"25","physicalCellId":32,"neighbours":"[{\"physicalCellId\":209,\"cellId\":\"29\"}]"}] +[ + { + "cellId": "29", + "physicalCellId": 209, + "neighbours": "[]" + }, + { + "cellId": "25", + "physicalCellId": 32, + "neighbours": "[{\"physicalCellId\":209,\"cellId\":\"29\"}]" + } +] diff --git a/src/test/resources/clusterInfo2.json b/src/test/resources/clusterInfo2.json index 6fe6d5e..eeadde3 100644 --- a/src/test/resources/clusterInfo2.json +++ b/src/test/resources/clusterInfo2.json @@ -1 +1,12 @@ -[{"cellId":"45","physicalCellId":310,"neighbours":"[]"},{"cellId":"47","physicalCellId":302,"neighbours":"[{\"physicalCellId\":310,\"cellId\":\"45\"}]"}] +[ + { + "cellId": "45", + "physicalCellId": 310, + "neighbours": "[]" + }, + { + "cellId": "47", + "physicalCellId": 302, + "neighbours": "[{\"physicalCellId\":310,\"cellId\":\"45\"}]" + } +] diff --git a/src/test/resources/clusterInfo3.json b/src/test/resources/clusterInfo3.json index 71e7736..2188654 100644 --- a/src/test/resources/clusterInfo3.json +++ b/src/test/resources/clusterInfo3.json @@ -1 +1,12 @@ -[{"cellId":"72","physicalCellId":2,"neighbours":"[]"},{"cellId":"63","physicalCellId":5,"neighbours":"[{\"physicalCellId\":2,\"cellId\":\"72\"}]"}] +[ + { + "cellId": "72", + "physicalCellId": 2, + "neighbours": "[]" + }, + { + "cellId": "63", + "physicalCellId": 5, + "neighbours": "[{\"physicalCellId\":2,\"cellId\":\"72\"}]" + } +] diff --git a/src/test/resources/clusterInfo4.json b/src/test/resources/clusterInfo4.json index 4da8c07..f620e73 100644 --- a/src/test/resources/clusterInfo4.json +++ b/src/test/resources/clusterInfo4.json @@ -1 +1,12 @@ -[{"cellId":"2","physicalCellId":20,"neighbours":"[]"},{"cellId":"5","physicalCellId":30,"neighbours":"[{\"physicalCellId\":20,\"cellId\":\"2\"}]"}] +[ + { + "cellId": "2", + "physicalCellId": 20, + "neighbours": "[]" + }, + { + "cellId": "5", + "physicalCellId": 30, + "neighbours": "[{\"physicalCellId\":20,\"cellId\":\"2\"}]" + } +] diff --git a/src/test/resources/clusterInfo5.json b/src/test/resources/clusterInfo5.json index 7612d10..37c1a13 100644 --- a/src/test/resources/clusterInfo5.json +++ b/src/test/resources/clusterInfo5.json @@ -1 +1,17 @@ -[{"cellId":"44","physicalCellId":3,"neighbours":"[]"},{"cellId":"48","physicalCellId":0,"neighbours":"[{\"physicalCellId\":3,\"cellId\":\"44\"}]"},{"cellId":"45","physicalCellId":310,"neighbours":"[{\"physicalCellId\":0,\"cellId\":\"48\"}]"}] +[ + { + "cellId": "44", + "physicalCellId": 3, + "neighbours": "[]" + }, + { + "cellId": "48", + "physicalCellId": 0, + "neighbours": "[{\"physicalCellId\":3,\"cellId\":\"44\"}]" + }, + { + "cellId": "45", + "physicalCellId": 310, + "neighbours": "[{\"physicalCellId\":0,\"cellId\":\"48\"}]" + } +] diff --git a/src/test/resources/clusterInfo6.json b/src/test/resources/clusterInfo6.json index 88e0763..a49ab9a 100644 --- a/src/test/resources/clusterInfo6.json +++ b/src/test/resources/clusterInfo6.json @@ -1 +1,17 @@ -[{"cellId":"48","physicalCellId":0,"neighbours":"[]"},{"cellId":"45","physicalCellId":310,"neighbours":"[{\"physicalCellId\":0,\"cellId\":\"48\"}]"},{"cellId":"47","physicalCellId":302,"neighbours":"[{\"physicalCellId\":310,\"cellId\":\"45\"}]"}] +[ + { + "cellId": "48", + "physicalCellId": 0, + "neighbours": "[]" + }, + { + "cellId": "45", + "physicalCellId": 310, + "neighbours": "[{\"physicalCellId\":0,\"cellId\":\"48\"}]" + }, + { + "cellId": "47", + "physicalCellId": 302, + "neighbours": "[{\"physicalCellId\":310,\"cellId\":\"45\"}]" + } +] diff --git a/src/test/resources/clusterInfo7.json b/src/test/resources/clusterInfo7.json index 1d8dc7d..b9ebc65 100644 --- a/src/test/resources/clusterInfo7.json +++ b/src/test/resources/clusterInfo7.json @@ -1 +1,12 @@ -[{"cellId":"82","physicalCellId":32,"neighbours":"[]"},{"cellId":"81","physicalCellId":31,"neighbours":"[{\"physicalCellId\":32,\"cellId\":\"82\"}]"}] +[ + { + "cellId": "82", + "physicalCellId": 32, + "neighbours": "[]" + }, + { + "cellId": "81", + "physicalCellId": 31, + "neighbours": "[{\"physicalCellId\":32,\"cellId\":\"82\"}]" + } +] diff --git a/src/test/resources/hoDetails.json b/src/test/resources/hoDetails.json new file mode 100644 index 0000000..be8f161 --- /dev/null +++ b/src/test/resources/hoDetails.json @@ -0,0 +1,14 @@ +[ + { + "dstCellId":"Chn0014", + "attemptsCount":200, + "successCount":190, + "successRate":95 + }, + { + "dstCellId":"Chn0013", + "attemptsCount":300, + "successCount":210, + "successRate":70 + } +] diff --git a/src/test/resources/notification1.json b/src/test/resources/notification1.json index 87f60e6..ee6c847 100644 --- a/src/test/resources/notification1.json +++ b/src/test/resources/notification1.json @@ -1,45 +1,45 @@ { - "requestID":"9d2d790e-a5f0-11e8-98d0-529269fb1459", - "AAI":{ - - }, - "from":"SDNR", - "version":"1.0.2", - "Action":"NeighborListModified", - "Payload":{ - "RadioAccess":{ - "FAPServiceNumberOfEntries":"1", - "FAPServiceList":[ - { - "alias":"45", - "X0005b9Lte":{ - "phyCellIdInUse":"310", - "pnfName":"ncserver2" - }, - "CellConfig":{ - "LTE":{ - "RAN":{ - "CellIdentity":"45", - "NeighborListInUse":{ - "LTECellNumberOfEntries":"1", - "LTENeighborListInUseLTECell":[ - { - "pnfName":"ncserver1", - "enable":"true", - "alias":"48", - "mustInclude":"true", - "plmnid":"ran-1", - "cid":"48", - "phyCellId":"0", - "blacklisted":"false" - } - ] - } - } - } - } - } - ] - } - } + "requestID": "9d2d790e-a5f0-11e8-98d0-529269fb1459", + "AAI": { + + }, + "from": "SDNR", + "version": "1.0.2", + "Action": "NeighborListModified", + "Payload": { + "RadioAccess": { + "FAPServiceNumberOfEntries": "1", + "FAPServiceList": [ + { + "alias": "45", + "X0005b9Lte": { + "phyCellIdInUse": "310", + "pnfName": "ncserver2" + }, + "CellConfig": { + "LTE": { + "RAN": { + "CellIdentity": "45", + "NeighborListInUse": { + "LTECellNumberOfEntries": "1", + "LTENeighborListInUseLTECell": [ + { + "pnfName": "ncserver1", + "enable": "true", + "alias": "48", + "mustInclude": "true", + "plmnid": "ran-1", + "cid": "48", + "phyCellId": "0", + "blacklisted": "false" + } + ] + } + } + } + } + } + ] + } + } } diff --git a/src/test/resources/notification2.json b/src/test/resources/notification2.json index 702b643..7d0a8ad 100644 --- a/src/test/resources/notification2.json +++ b/src/test/resources/notification2.json @@ -1,55 +1,55 @@ { - "requestID":"9d2d790e-a5f0-11e8-98d0-529269fb1459", - "AAI":{ - - }, - "from":"SDNR", - "version":"1.0.2", - "Action":"NeighborListModified", - "Payload":{ - "RadioAccess":{ - "FAPServiceNumberOfEntries":"1", - "FAPServiceList":[ - { - "alias":"120", - "X0005b9Lte":{ - "phyCellIdInUse":"2", - "pnfName":"ncserver2" - }, - "CellConfig":{ - "LTE":{ - "RAN":{ - "CellIdentity":"120", - "NeighborListInUse":{ - "LTECellNumberOfEntries":"3", - "LTENeighborListInUseLTECell":[ - { - "pnfName":"ncserver1", - "enable":"true", - "alias":"123", - "mustInclude":"true", - "plmnid":"ran-1", - "cid":"123", - "phyCellId":"6", - "blacklisted":"false" - }, - { - "pnfName":"ncserver1", - "enable":"true", - "alias":"49", - "mustInclude":"true", - "plmnid":"ran-1", - "cid":"124", - "phyCellId":"4", - "blacklisted":"false" - } - ] - } - } - } - } - } - ] - } - } + "requestID": "9d2d790e-a5f0-11e8-98d0-529269fb1459", + "AAI": { + + }, + "from": "SDNR", + "version": "1.0.2", + "Action": "NeighborListModified", + "Payload": { + "RadioAccess": { + "FAPServiceNumberOfEntries": "1", + "FAPServiceList": [ + { + "alias": "120", + "X0005b9Lte": { + "phyCellIdInUse": "2", + "pnfName": "ncserver2" + }, + "CellConfig": { + "LTE": { + "RAN": { + "CellIdentity": "120", + "NeighborListInUse": { + "LTECellNumberOfEntries": "3", + "LTENeighborListInUseLTECell": [ + { + "pnfName": "ncserver1", + "enable": "true", + "alias": "123", + "mustInclude": "true", + "plmnid": "ran-1", + "cid": "123", + "phyCellId": "6", + "blacklisted": "false" + }, + { + "pnfName": "ncserver1", + "enable": "true", + "alias": "49", + "mustInclude": "true", + "plmnid": "ran-1", + "cid": "124", + "phyCellId": "4", + "blacklisted": "false" + } + ] + } + } + } + } + } + ] + } + } } diff --git a/src/test/resources/notification3.json b/src/test/resources/notification3.json index 4a3a2a0..2588f3c 100644 --- a/src/test/resources/notification3.json +++ b/src/test/resources/notification3.json @@ -1,45 +1,45 @@ { - "requestID":"9d2d790e-a5f0-11e8-98d0-529269fb1459", - "AAI":{ - - }, - "from":"SDNR", - "version":"1.0.2", - "Action":"NeighborListModified", - "Payload":{ - "RadioAccess":{ - "FAPServiceNumberOfEntries":"1", - "FAPServiceList":[ - { - "alias":"81", - "X0005b9Lte":{ - "phyCellIdInUse":"31", - "pnfName":"ncserver2" - }, - "CellConfig":{ - "LTE":{ - "RAN":{ - "CellIdentity":"81", - "NeighborListInUse":{ - "LTECellNumberOfEntries":"1", - "LTENeighborListInUseLTECell":[ - { - "pnfName":"ncserver1", - "enable":"true", - "alias":"82", - "mustInclude":"true", - "plmnid":"ran-1", - "cid":"82", - "phyCellId":"32", - "blacklisted":"false" - } - ] - } - } - } - } - } - ] - } - } + "requestID": "9d2d790e-a5f0-11e8-98d0-529269fb1459", + "AAI": { + + }, + "from": "SDNR", + "version": "1.0.2", + "Action": "NeighborListModified", + "Payload": { + "RadioAccess": { + "FAPServiceNumberOfEntries": "1", + "FAPServiceList": [ + { + "alias": "81", + "X0005b9Lte": { + "phyCellIdInUse": "31", + "pnfName": "ncserver2" + }, + "CellConfig": { + "LTE": { + "RAN": { + "CellIdentity": "81", + "NeighborListInUse": { + "LTECellNumberOfEntries": "1", + "LTENeighborListInUseLTECell": [ + { + "pnfName": "ncserver1", + "enable": "true", + "alias": "82", + "mustInclude": "true", + "plmnid": "ran-1", + "cid": "82", + "phyCellId": "32", + "blacklisted": "false" + } + ] + } + } + } + } + } + ] + } + } } diff --git a/src/test/resources/pmNotification.json b/src/test/resources/pmNotification.json new file mode 100644 index 0000000..a956ae4 --- /dev/null +++ b/src/test/resources/pmNotification.json @@ -0,0 +1,56 @@ + + { + "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" + }, + "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" + } + ] + } + } + } diff --git a/src/test/resources/pmNotification1.json b/src/test/resources/pmNotification1.json new file mode 100644 index 0000000..0f046e2 --- /dev/null +++ b/src/test/resources/pmNotification1.json @@ -0,0 +1,55 @@ +{ + "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" + }, + "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" + } + ] + } + } + } diff --git a/src/test/resources/policy_notification.json b/src/test/resources/policy_notification.json index b9a6910..3863d1c 100644 --- a/src/test/resources/policy_notification.json +++ b/src/test/resources/policy_notification.json @@ -1,20 +1,18 @@ { - - "closedLoopControlName":"ControlLoop-vPCI-fb41f388-a5f2-11e8-98d0-529269fb1459", - "closedLoopAlarmStart":1542445563201, - "closedLoopEventClient":"microservice.PCI", - "closedLoopEventStatus":"ONSET", - "target_type":"VNF", - "target":"generic-vnf.vnf-id", - "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\"}}}}}}}]}", - "AAI":{ - "generic-vnf.prov-status":"ACTIVE", - "generic-vnf.is-closed-loop-disabled":"false", - "generic-vnf.vnf-id":"ncserver23" - }, - "Action":"ModifyConfig" - + "closedLoopControlName": "ControlLoop-vPCI-fb41f388-a5f2-11e8-98d0-529269fb1459", + "closedLoopAlarmStart": 1542445563201, + "closedLoopEventClient": "microservice.PCI", + "closedLoopEventStatus": "ONSET", + "target_type": "VNF", + "target": "generic-vnf.vnf-id", + "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\"}}}}}}}]}", + "AAI": { + "generic-vnf.prov-status": "ACTIVE", + "generic-vnf.is-closed-loop-disabled": "false", + "generic-vnf.vnf-id": "ncserver23" + }, + "Action": "ModifyConfig" } diff --git a/src/test/resources/solutions.json b/src/test/resources/solutions.json index cf82283..8f6f41f 100644 --- a/src/test/resources/solutions.json +++ b/src/test/resources/solutions.json @@ -1 +1,16 @@ -[{"startTime":"2016-10-01T00:30+01:00","finishTime":"2016-10-01T00:40+01.00","networkId":"NTWK005","pciSolutions":[{"cellId":"EXP001","pci":"101"},{"cellId":"EXP002","pci":"102"}]}] +{ + "networkId":"NTWK005", + "pciSolutions":[ + { + "cellId":"EXP001", + "pci":"101" + }, + { + "cellId":"EXP002", + "pci":"102" + } + ], + "anrSolutions":[ + + ] +} diff --git a/version.properties b/version.properties index 1b04310..ad1d4b0 100644 --- a/version.properties +++ b/version.properties @@ -1,3 +1,23 @@ +############################################################################### +# ============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========================================================= +# +############################################################################### major=1 minor=0 patch=0 -- 2.16.6