diff options
author | krishnaa96 <krishna.moorthy6@wipro.com> | 2019-04-05 18:13:32 +0530 |
---|---|---|
committer | krishnaa96 <krishna.moorthy6@wipro.com> | 2019-04-05 18:13:32 +0530 |
commit | 80b0c61808d0958ef7d38a772a206f2c17dfd2a5 (patch) | |
tree | 7e261770b7f974cdc50b5634138714beb311aaaa | |
parent | ab400d51a639a01f31a60ac9d1e127d4d4d28b24 (diff) |
Implement Enhancements to the Microservice
Change-Id: Ie3b11fe14f1794fdd6880c40bc382eccbef34aa2
Issue-ID: DCAEGEN2-1109
Signed-off-by: krishna moorthy <krishna.moorthy6@wipro.com>
130 files changed, 6222 insertions, 2683 deletions
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" + } + ] } @@ -1,357 +1,327 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- - ============LICENSE_START======================================================= - son-handler - ================================================================================ - Copyright (C) 2019 Wipro Limited. - ============================================================================== - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ============LICENSE_END========================================================= - - --> +<!-- ============LICENSE_START======================================================= + son-handler ================================================================================ + Copyright (C) 2019 Wipro Limited. ============================================================================== + Licensed under the Apache License, Version 2.0 (the "License"); you may not + use this file except in compliance with the License. You may obtain a copy + of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required + by applicable law or agreed to in writing, software distributed under the + License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS + OF ANY KIND, either express or implied. See the License for the specific + language governing permissions and limitations under the License. ============LICENSE_END========================================================= --> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>org.onap.dcaegen2.services.son-handler</groupId> - <artifactId>son-handler</artifactId> - <name>dcaegen2-services-son-handler</name> - <version>1.0.0-SNAPSHOT</version> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.onap.dcaegen2.services.son-handler</groupId> + <artifactId>son-handler</artifactId> + <name>dcaegen2-services-son-handler</name> + <version>1.0.0-SNAPSHOT</version> - <!--parent> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-parent</artifactId> - <version>2.0.4.RELEASE</version> - </parent--> - - <parent> - <groupId>org.onap.oparent</groupId> - <artifactId>oparent</artifactId> - <version>1.2.1</version> - <relativePath/> - </parent> + <!--parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> + <version>2.0.4.RELEASE</version> </parent --> + <parent> + <groupId>org.onap.oparent</groupId> + <artifactId>oparent</artifactId> + <version>1.2.1</version> + <relativePath /> + </parent> - <properties> - <sdk.version>1.1.3</sdk.version> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <maven.compiler.source>1.8</maven.compiler.source> - <maven.compiler.target>1.8</maven.compiler.target> - <docker.image.name>onap/org.onap.dcaegen2.services.son-handler</docker.image.name> - <!-- NEXUS RELATED SETTINGS --> - <nexusproxy>https://nexus.onap.org</nexusproxy> - <snapshots.path>content/repositories/snapshots/</snapshots.path> - <releases.path>content/repositories/releases/</releases.path> - <site.path>content/sites/site/org/onap/dcaegen2/services/son-handler/${project.artifactId}/${project.version}</site.path> - <maven.build.timestamp.format>yyyyMMdd'T'HHmmss</maven.build.timestamp.format> - </properties> - <dependencies> - <!-- cbs client --> - <dependency> - <groupId>org.onap.dcaegen2.services.sdk.rest.services</groupId> - <artifactId>cbs-client</artifactId> - <version>${sdk.version}</version> - </dependency> - - <dependency> - <groupId>org.onap.dcaegen2.services.sdk.security.crypt</groupId> - <artifactId>crypt-password</artifactId> - <version>${sdk.version}</version> - </dependency> - <dependency> - <!-- Import dependency management from Spring Boot --> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-dependencies</artifactId> - <version>2.0.4.RELEASE</version> - <type>pom</type> - <scope>import</scope> - </dependency> - <dependency> - <groupId>com.att.nsa</groupId> - <artifactId>cambriaClient</artifactId> - <version>0.0.1</version> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>com.fasterxml.jackson.core</groupId> - <artifactId>jackson-core</artifactId> - <version>2.9.8</version> - </dependency> - <dependency> - <groupId>com.fasterxml.jackson.core</groupId> - <artifactId>jackson-databind</artifactId> - <version>2.9.8</version> - </dependency> -<!-- https://mvnrepository.com/artifact/javax.json/javax.json-api --> -<dependency> - <groupId>javax.json</groupId> - <artifactId>javax.json-api</artifactId> - <version>1.1.2</version> - </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-web</artifactId> - <version>2.0.4.RELEASE</version> - </dependency> - <dependency> - <groupId>org.postgresql</groupId> - <artifactId>postgresql</artifactId> - <version>42.2.5</version> - </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-data-jpa</artifactId> - <version>2.0.4.RELEASE</version> - </dependency> -<dependency> - <groupId>org.springframework.data</groupId> - <artifactId>spring-data-commons-core</artifactId> - <version>1.4.0.RELEASE</version> -</dependency> + <properties> + <sdk.version>1.1.4-SNAPSHOT</sdk.version> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <maven.compiler.source>1.8</maven.compiler.source> + <maven.compiler.target>1.8</maven.compiler.target> + <docker.image.name>onap/org.onap.dcaegen2.services.son-handler</docker.image.name> + <!-- NEXUS RELATED SETTINGS --> + <nexusproxy>https://nexus.onap.org</nexusproxy> + <snapshots.path>content/repositories/snapshots/</snapshots.path> + <releases.path>content/repositories/releases/</releases.path> + <site.path>content/sites/site/org/onap/dcaegen2/services/son-handler/${project.artifactId}/${project.version}</site.path> + <maven.build.timestamp.format>yyyyMMdd'T'HHmmss</maven.build.timestamp.format> + </properties> + <dependencies> + <!-- cbs client --> + <dependency> + <groupId>org.onap.dcaegen2.services.sdk.rest.services</groupId> + <artifactId>cbs-client</artifactId> + <version>${sdk.version}</version> + </dependency> - -<!-- https://mvnrepository.com/artifact/org.codehaus.jackson/jackson-mapper-asl --> - <dependency> - <groupId>org.codehaus.jackson</groupId> - <artifactId>jackson-mapper-asl</artifactId> - <version>1.9.13</version> - </dependency> - <dependency> - <groupId>org.hibernate.javax.persistence</groupId> - <artifactId>hibernate-jpa-2.0-api</artifactId> - <version>1.0.1.Final</version> - </dependency> -<!-- https://mvnrepository.com/artifact/org.springframework/spring-beans --> -<dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-beans</artifactId> - <version>5.0.10.RELEASE</version> -</dependency> + <dependency> + <groupId>org.onap.dcaegen2.services.sdk.security.crypt</groupId> + <artifactId>crypt-password</artifactId> + <version>${sdk.version}</version> + </dependency> + <dependency> + <!-- Import dependency management from Spring Boot --> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-dependencies</artifactId> + <version>2.0.4.RELEASE</version> + <type>pom</type> + <scope>import</scope> + </dependency> + <dependency> + <groupId>com.att.nsa</groupId> + <artifactId>cambriaClient</artifactId> + <version>0.0.1</version> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-core</artifactId> + <version>2.9.8</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-databind</artifactId> + <version>2.9.8</version> + </dependency> + <!-- https://mvnrepository.com/artifact/javax.json/javax.json-api --> + <dependency> + <groupId>javax.json</groupId> + <artifactId>javax.json-api</artifactId> + <version>1.1.2</version> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-web</artifactId> + <version>2.0.4.RELEASE</version> + </dependency> + <dependency> + <groupId>org.postgresql</groupId> + <artifactId>postgresql</artifactId> + <version>42.2.5</version> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-data-jpa</artifactId> + <version>2.0.4.RELEASE</version> + </dependency> + <dependency> + <groupId>org.springframework.data</groupId> + <artifactId>spring-data-commons-core</artifactId> + <version>1.4.0.RELEASE</version> + </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-test</artifactId> -<version>2.0.4.RELEASE</version> - <scope>test</scope> - <!-- exclusions> - <exclusion> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> - </exclusion> - </exclusions--> - </dependency> - <!-- https://mvnrepository.com/artifact/org.mockito/mockito-core --> - -<dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> - <version>1.10.16</version> - <scope>test</scope> -</dependency> - - -<dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>4.12</version> - <scope>test</scope> - </dependency> - <!-- https://mvnrepository.com/artifact/org.powermock/powermock-module-junit4 --> -<!-- https://mvnrepository.com/artifact/org.powermock/powermock-api-mockito --> -<dependency> - <groupId>org.powermock</groupId> - <artifactId>powermock-api-mockito</artifactId> - <version>1.6.4</version> - <scope>test</scope> -</dependency> -<!-- https://mvnrepository.com/artifact/org.powermock/powermock-module-junit4 --> -<dependency> - <groupId>org.powermock</groupId> - <artifactId>powermock-module-junit4</artifactId> - <version>1.6.4</version> - <scope>test</scope> -</dependency> -<dependency> - <groupId>org.functionaljava</groupId> - <artifactId>functionaljava</artifactId> - <version>3.0</version> -</dependency> - - </dependencies> + <!-- https://mvnrepository.com/artifact/org.codehaus.jackson/jackson-mapper-asl --> + <dependency> + <groupId>org.codehaus.jackson</groupId> + <artifactId>jackson-mapper-asl</artifactId> + <version>1.9.13</version> + </dependency> + <dependency> + <groupId>org.hibernate.javax.persistence</groupId> + <artifactId>hibernate-jpa-2.0-api</artifactId> + <version>1.0.1.Final</version> + </dependency> + <!-- https://mvnrepository.com/artifact/org.springframework/spring-beans --> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-beans</artifactId> + <version>5.0.10.RELEASE</version> + </dependency> - <build> - <plugins> - <plugin> - <artifactId>maven-checkstyle-plugin</artifactId> - <executions> - <execution> - <id>onap-java-style</id> - <goals> - <goal>check</goal> - </goals> - <phase>process-sources</phase> - <configuration> - <!-- Use Google Java Style Guide: - https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml - with minor changes --> - <configLocation>onap-checkstyle/onap-java-style.xml</configLocation> - <!-- <sourceDirectory> is needed so that checkstyle ignores the generated sources directory --> - <sourceDirectories> - <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory> - </sourceDirectories> - <includeResources>true</includeResources> - <includeTestSourceDirectory>false</includeTestSourceDirectory> - <includeTestResources>false</includeTestResources> - <excludes> - </excludes> - <consoleOutput>true</consoleOutput> - <failsOnViolation>false</failsOnViolation> - <violationSeverity>warning</violationSeverity> - </configuration> - </execution> - </executions> - <dependencies> - <dependency> - <groupId>org.onap.oparent</groupId> - <artifactId>checkstyle</artifactId> - <version>1.2.3</version> - <scope>compile</scope> - </dependency> - </dependencies> - </plugin> - <!--plugin> - <groupId>org.eclipse.m2e</groupId> - <artifactId>lifecycle-mapping</artifactId> - <configuration> - <lifecycleMappingMetadata> - <pluginExecutions> - <pluginExecution> - <pluginExecutionFilter> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-checkstyle-plugin</artifactId> - <versionRange>2.17,)</versionRange> - <goals> - <goal>check</goal> - </goals> - </pluginExecutionFilter> - <action> - <ignore /> - </action> - </pluginExecution> - </pluginExecutions> - </lifecycleMappingMetadata> - </configuration> - </plugin--> - <plugin> + <dependency> <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-maven-plugin</artifactId> - <version>2.0.4.RELEASE</version> - <executions> - <execution> - <goals> - <goal>repackage</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <groupId>com.spotify</groupId> - <artifactId>docker-maven-plugin</artifactId> - <configuration> - <serverId>${onap.nexus.dockerregistry.daily}</serverId> + <artifactId>spring-boot-starter-test</artifactId> + <version>2.0.4.RELEASE</version> + <scope>test</scope> + <!-- exclusions> <exclusion> <groupId>org.mockito</groupId> <artifactId>mockito-core</artifactId> + </exclusion> </exclusions --> + </dependency> + <!-- https://mvnrepository.com/artifact/org.mockito/mockito-core --> + + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + <version>1.10.16</version> + <scope>test</scope> + </dependency> + + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.12</version> + <scope>test</scope> + </dependency> + <!-- https://mvnrepository.com/artifact/org.powermock/powermock-module-junit4 --> + <!-- https://mvnrepository.com/artifact/org.powermock/powermock-api-mockito --> + <dependency> + <groupId>org.powermock</groupId> + <artifactId>powermock-api-mockito</artifactId> + <version>1.6.4</version> + <scope>test</scope> + </dependency> + <!-- https://mvnrepository.com/artifact/org.powermock/powermock-module-junit4 --> + <dependency> + <groupId>org.powermock</groupId> + <artifactId>powermock-module-junit4</artifactId> + <version>1.6.4</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.functionaljava</groupId> + <artifactId>functionaljava</artifactId> + <version>3.0</version> + </dependency> + + + </dependencies> + + <build> + <plugins> + <plugin> + <artifactId>maven-checkstyle-plugin</artifactId> + <executions> + <execution> + <id>onap-java-style</id> + <goals> + <goal>check</goal> + </goals> + <phase>process-sources</phase> + <configuration> + <!-- Use Google Java Style Guide: https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml + with minor changes --> + <configLocation>onap-checkstyle/onap-java-style.xml</configLocation> + <!-- <sourceDirectory> is needed so that checkstyle ignores the generated + sources directory --> + <sourceDirectories> + <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory> + </sourceDirectories> + <includeResources>true</includeResources> + <includeTestSourceDirectory>false</includeTestSourceDirectory> + <includeTestResources>false</includeTestResources> + <excludes> + </excludes> + <consoleOutput>true</consoleOutput> + <failsOnViolation>false</failsOnViolation> + <violationSeverity>warning</violationSeverity> + </configuration> + </execution> + </executions> + <dependencies> + <dependency> + <groupId>org.onap.oparent</groupId> + <artifactId>checkstyle</artifactId> + <version>1.2.3</version> + <scope>compile</scope> + </dependency> + </dependencies> + </plugin> + <!--plugin> <groupId>org.eclipse.m2e</groupId> <artifactId>lifecycle-mapping</artifactId> + <configuration> <lifecycleMappingMetadata> <pluginExecutions> <pluginExecution> + <pluginExecutionFilter> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> + <versionRange>2.17,)</versionRange> <goals> <goal>check</goal> </goals> </pluginExecutionFilter> + <action> <ignore /> </action> </pluginExecution> </pluginExecutions> </lifecycleMappingMetadata> + </configuration> </plugin --> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + <version>2.0.4.RELEASE</version> + <executions> + <execution> + <goals> + <goal>repackage</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>com.spotify</groupId> + <artifactId>docker-maven-plugin</artifactId> + <configuration> + <serverId>${onap.nexus.dockerregistry.daily}</serverId> - <imageName>${docker.image.name}</imageName> - <imageTags> - <tag>latest</tag> - </imageTags> - <baseImage>java:openjdk-8</baseImage> - <resources> - <resource> - <targetPath>/bin</targetPath> - <directory>${project.build.directory}</directory> - <include>${project.artifactId}-${project.version}.jar</include> - </resource> - <resource> - <targetPath>/bin</targetPath> - <directory>${project.basedir}</directory> - <include>entrypoint.sh</include> - </resource> - </resources> - <runs> - <!-- Maven is loosing file permissions during artifacts copy --> - <run>chmod +x /bin/entrypoint.sh</run> - <run>mv /bin/*.jar /bin/application.jar</run> - </runs> - <exposes> - <expose>8080</expose> - </exposes> - <entryPoint>/bin/entrypoint.sh</entryPoint> - </configuration> - <executions> - <execution> - <id>build-image</id> - <phase>package</phase> - <goals> - <goal>build</goal> - </goals> - </execution> - <execution> - <id>tag-and-push-image-latest</id> - <phase>deploy</phase> - <goals> - <goal>tag</goal> - </goals> - <configuration> - <image>${docker.image.name}:latest</image> - <newName>${onap.nexus.dockerregistry.daily}/${docker.image.name}:latest</newName> - <pushImage>true</pushImage> - </configuration> - </execution> - <execution> - <id>tag-and-push-image-with-version</id> - <phase>deploy</phase> - <goals> - <goal>tag</goal> - </goals> - <configuration> - <image>${docker.image.name}:latest</image> - <newName>${onap.nexus.dockerregistry.daily}/${docker.image.name}:${project.version}</newName> - <pushImage>true</pushImage> - </configuration> - </execution> - <execution> - <id>tag-and-push-image-with-version-and-date</id> - <phase>deploy</phase> - <goals> - <goal>tag</goal> - </goals> - <configuration> - <image>${docker.image.name}:latest</image> - <newName>${onap.nexus.dockerregistry.daily}/${docker.image.name}:${project.version}-${maven.build.timestamp}Z</newName> - <pushImage>true</pushImage> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> + <imageName>${docker.image.name}</imageName> + <imageTags> + <tag>latest</tag> + </imageTags> + <baseImage>java:openjdk-8</baseImage> + <user>sonhms</user> + <resources> + <resource> + <targetPath>/bin</targetPath> + <directory>${project.build.directory}</directory> + <include>${project.artifactId}-${project.version}.jar</include> + </resource> + <resource> + <targetPath>/bin</targetPath> + <directory>${project.basedir}</directory> + <include>entrypoint.sh</include> + </resource> + </resources> + <runs> + <!-- Maven is loosing file permissions during artifacts copy --> + <run>chmod +x /bin/entrypoint.sh</run> + <run>mv /bin/*.jar /bin/application.jar</run> + <run>chmod -R 777 /bin</run> + <run>mkdir /var/log/onap</run> + <run>chmod -R 777 /var/log/onap</run> + </runs> + <exposes> + <expose>8080</expose> + </exposes> + <entryPoint>/bin/entrypoint.sh</entryPoint> + </configuration> + <executions> + <execution> + <id>build-image</id> + <phase>package</phase> + <goals> + <goal>build</goal> + </goals> + </execution> + <execution> + <id>tag-and-push-image-latest</id> + <phase>deploy</phase> + <goals> + <goal>tag</goal> + </goals> + <configuration> + <image>${docker.image.name}:latest</image> + <newName>${onap.nexus.dockerregistry.daily}/${docker.image.name}:latest</newName> + <pushImage>true</pushImage> + </configuration> + </execution> + <execution> + <id>tag-and-push-image-with-version</id> + <phase>deploy</phase> + <goals> + <goal>tag</goal> + </goals> + <configuration> + <image>${docker.image.name}:latest</image> + <newName>${onap.nexus.dockerregistry.daily}/${docker.image.name}:${project.version}</newName> + <pushImage>true</pushImage> + </configuration> + </execution> + <execution> + <id>tag-and-push-image-with-version-and-date</id> + <phase>deploy</phase> + <goals> + <goal>tag</goal> + </goals> + <configuration> + <image>${docker.image.name}:latest</image> + <newName>${onap.nexus.dockerregistry.daily}/${docker.image.name}:${project.version}-${maven.build.timestamp}Z</newName> + <pushImage>true</pushImage> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> </project> 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<String> optimizers; private int numSolutions; private int bufferTime; - private int maximumClusters; + private int maximumClusters; private String aafUsername; private String aafPassword; - private Map<String,Object> streamsSubscribes; - private Map<String,Object> streamsPublishes; + private Map<String, Object> streamsSubscribes; + private Map<String, Object> 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<String, Object> getStreamsSubscribes() { - return streamsSubscribes; - } + public Map<String, Object> getStreamsSubscribes() { + return streamsSubscribes; + } - public void setStreamsSubscribes(Map<String, Object> streamsSubscribes) { - this.streamsSubscribes = streamsSubscribes; - } + public void setStreamsSubscribes(Map<String, Object> streamsSubscribes) { + this.streamsSubscribes = streamsSubscribes; + } - public Map<String, Object> getStreamsPublishes() { - return streamsPublishes; - } + public Map<String, Object> getStreamsPublishes() { + return streamsPublishes; + } - public void setStreamsPublishes(Map<String, Object> streamsPublishes) { - this.streamsPublishes = streamsPublishes; - } + public void setStreamsPublishes(Map<String, Object> 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<String> getDmaapServers() { - return dmaapServers; - } - - public void setDmaapServers(List<String> dmaapServers) { - this.dmaapServers = dmaapServers; - } - - public String getConfigDbService() { - return configDbService; - } - - public void setConfigDbService(String configDbService) { - this.configDbService = configDbService; - } + public List<String> getDmaapServers() { + return dmaapServers; + } + public void setDmaapServers(List<String> 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<Notification, Integer> getDmaapNotifications() { + public Either<Notification, Integer> 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<PMNotification,Integer> getPmNotifications(){ + PerformanceNotificationsRepository pmNotificationRepository = BeanUtil.getBean(PerformanceNotificationsRepository.class); + String pmNotificationString = pmNotificationRepository.getPerformanceNotificationFromQueue(); + if (pmNotificationString == null) { + return Either.right(404); + } + ObjectMapper mapper = new ObjectMapper(); + PMNotification pmNotification = new PMNotification(); + + 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; /** @@ -76,15 +79,152 @@ public class EventHandler { } /** + * Handles fault notifications. + */ + public Boolean handleFaultNotification(List<FaultEvent> fmNotification) { + + log.info("Handling Fault notification"); + log.info("fm notification {}", fmNotification); + + Set<String> cellIds = new HashSet<>(); + List<ClusterDetails> clusterDetails = clusterUtils.getAllClusters(); + String networkId = ""; + Map<String, ArrayList<Integer>> collisionConfusionMap = new HashMap<>(); + + for (FaultEvent faultEvent : fmNotification) { + String cellId = faultEvent.getEvent().getCommonEventHeader().getSourceName(); + cellIds.add(cellId); + networkId = faultEvent.getEvent().getFaultFields().getAlarmAdditionalInformation().getNetworkId(); + ArrayList<Integer> 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> clusterDetails) throws ConfigDbNotFoundException { + Map<String, String> cellsinCluster = faultNotificationtoClusterMapping.getCellsinCluster(); + log.info("Handling Matching cells for FM notification"); + + for (Entry<String, String> entry : cellsinCluster.entrySet()) { + + String cellId = entry.getKey(); + String clusterId = entry.getValue(); + Map<CellPciPair, ArrayList<CellPciPair>> clusterMap = clusterUtils.findClusterMap(cellId); + + Either<ClusterDetails, Integer> 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<String> newCells = faultNotificationtoClusterMapping.getNewCells(); + log.info("Handle Unmatching cells for FM notificatins newCells{}", newCells); + List<Graph> newClusters = new ArrayList<>(); + + for (String cellId : newCells) { + ArrayList<Integer> collisionConfusionCount = faultNotificationtoClusterMapping.getCollisionConfusionMap() + .get(cellId); + log.info("Handle Unmatching cells for FM notificatins,collisionConfusionCount{}", collisionConfusionCount); + + Either<Graph, Integer> existingCluster = clusterUtils.getClusterForFMCell(cellId, newClusters); + if (existingCluster.isRight()) { + try { + Map<CellPciPair, ArrayList<CellPciPair>> clusterMap = clusterUtils.findClusterMap(cellId); + Graph cluster = clusterUtils.createCluster(clusterMap); + cluster.setNetworkId(networkId); + Map<String, ArrayList<Integer>> 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<String, ArrayList<Integer>> 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> 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<FapServiceList> newCells) { + private void handleUnMatchingCells(List<FapServiceList> newCells) throws ConfigDbNotFoundException { + + log.info("handling unmatched cells"); + List<Graph> newClusters = new ArrayList<>(); for (FapServiceList fapService : newCells) { + Map<CellPciPair, ArrayList<CellPciPair>> clusterMap = clusterUtils.findClusterMap(fapService.getAlias()); Either<Graph, Integer> 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<FapServiceList, String> cellsInCluster, List<ClusterDetails> clusterDetails) { + private void handleMatchingCells(Map<FapServiceList, String> cellsInCluster, List<ClusterDetails> clusterDetails) + throws ConfigDbNotFoundException { + + log.info("handling matching cells"); + for (Entry<FapServiceList, String> entry : cellsInCluster.entrySet()) { FapServiceList fapService = entry.getKey(); String clusterId = entry.getValue(); + String cellId = fapService.getAlias(); + int pci = fapService.getX0005b9Lte().getPhyCellIdInUse(); + ArrayList<CellPciPair> 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<CellPciPair, ArrayList<CellPciPair>> clusterMap = new HashMap<>(); + clusterMap.put(new CellPciPair(cellId, pci), neighbours); + Either<ClusterDetails, Integer> 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<CellPciPair, ArrayList<CellPciPair>> 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<String> 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<String> bufferedNotifications = bufferNotificationComponent.getBufferedNotification(clusterId); - - if (bufferedNotifications == null || bufferedNotifications.isEmpty()) { - log.info("No buffered notification for this thread"); - - Set<Thread> 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<String> 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<List<FaultEvent>,Integer> getFaultNotifications() { + FaultNotificationsRepository faultNotificationsRepository = BeanUtil + .getBean(FaultNotificationsRepository.class); + String notificationString = faultNotificationsRepository.getFaultNotificationFromQueue(); + log.info("get fault notifications method"); + if (notificationString == null) { + return Either.right(404); + } + ObjectMapper mapper = new ObjectMapper(); + FaultEvent faultEvent = new FaultEvent(); + List<FaultEvent> faultEvents = new ArrayList<>(); + try { + faultEvent = mapper.readValue(notificationString,FaultEvent.class); + log.info("Parsing FM notification"); + + } catch (IOException e) { + log.error("Exception in parsing Notification {}", e); + return Either.right(400); + } + + faultEvents.add(faultEvent); + + return Either.left(faultEvents); + + } + +} 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<String, String> getCellsinCluster() { + return cellsinCluster; + } + + public void setCellsinCluster(Map<String, String> cellsinCluster) { + this.cellsinCluster = cellsinCluster; + } + + public List<String> getNewCells() { + return newCells; + } + + public void setNewCells(List<String> newCells) { + this.newCells = newCells; + } + + private Map<String, ArrayList<Integer>> collisionConfusionMap; + + //map that returns cellid and its matching cluster id + + public Map<String, ArrayList<Integer>> getCollisionConfusionMap() { + return collisionConfusionMap; + } + + public void setCollisionConfusionMap(Map<String, ArrayList<Integer>> collisionConfusionMap) { + this.collisionConfusionMap = collisionConfusionMap; + } + + private Map<String, String> cellsinCluster; + + //cells that dont match + private List<String> 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<List<HoDetails>, Integer> getHoMetrics(String srcCellId) { + HandOverMetricsRepository handOverMetricsRepository = BeanUtil.getBean(HandOverMetricsRepository.class); + String hoDetailsString = handOverMetricsRepository.getHandOverMetrics(srcCellId); + if (hoDetailsString != null) { + ObjectMapper mapper = new ObjectMapper(); + List<HoDetails> hoDetails = new ArrayList<>(); + try { + hoDetails = mapper.readValue(hoDetailsString, new TypeReference<ArrayList<HoDetails>>() { + }); + 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<List<String>> childStatusQueue; - + private DmaapNotificationsComponent dmaapNotificationsComponent; - + + private FaultNotificationComponent faultNotificationComponent; + private EventHandler eventHandler; - + + private Map<String, FaultEvent> bufferedFMNotificationCells; + + private List<String> sdnrNotificationCells; + + private Boolean isTimer; + + private Timestamp startTimer; + + List<FaultEvent> 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<FaultEvent> 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<String> childState = childStatusQueue.poll(); @@ -76,12 +124,57 @@ public class MainThread implements Runnable { } if (newNotification.getNewNotif()) { - Either<Notification, Integer> notification = dmaapNotificationsComponent.getDmaapNotifications(); + Either<Notification, Integer> 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<FapServiceList> 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<List<FaultEvent>, 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 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<HoDetails> hoDetailsList = new ArrayList<>(); + List<LteCell> 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<LteCell> lteCellList) { + ObjectMapper mapper = new ObjectMapper(); + try { + mapper.setSerializationInclusion(Include.NON_NULL); + ArrayList<Configurations> configurations = new ArrayList<>(); + String cellId = pmNotification.getEvent().getCommonEventHeader().getSourceName(); + Configurations configuration = new Configurations( + new Data(new FapService(cellId, null, new CellConfig(new Lte(new Ran(new Common(cellId), + new NeighborListInUse(null, lteCellList, String.valueOf(lteCellList.size())))))))); + 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<HoDetails> 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, Integer> 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<List<String>> childStatusUpdate; - private BlockingQueue<FapServiceList> queue = new LinkedBlockingQueue<>(); + private BlockingQueue<Map<CellPciPair, ArrayList<CellPciPair>>> queue = new LinkedBlockingQueue<>(); private static Map<Long, AsyncResponseBody> responseMap = new HashMap<>(); private Graph cluster; private ThreadId threadId; - FapServiceList fapServiceList = new FapServiceList(); + Map<CellPciPair, ArrayList<CellPciPair>> clusterMap; + HoMetricsComponent hoMetricsComponent; private static final Logger log = org.slf4j.LoggerFactory.getLogger(ChildThread.class); /** * Constructor with parameters. */ public ChildThread(BlockingQueue<List<String>> childStatusUpdate, Graph cluster, - BlockingQueue<FapServiceList> queue, ThreadId threadId) { + BlockingQueue<Map<CellPciPair, ArrayList<CellPciPair>>> 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<CellPciPair, ArrayList<CellPciPair>> 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<CellPciPair, ArrayList<CellPciPair>> 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<String, ArrayList<Integer>> collisionConfusionResult; while (!done) { + if (cluster.getCollisionConfusionMap().isEmpty()) { - Map<String, ArrayList<Integer>> 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<CellPciPair, ArrayList<CellPciPair>> 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<String> cellidList = new ArrayList<>(); + ArrayList<String> cellIds = new ArrayList<>(); + + for (Map.Entry<String, ArrayList<Integer>> entry : collisionConfusionResult.entrySet()) { + String key = entry.getKey(); + ArrayList<Integer> arr; + arr = entry.getValue(); + if (!arr.isEmpty()) { + Set<Integer> 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<List<AnrInput>, 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<AnrInput> 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<String> 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<FapServiceList> fapServiceLists = bufferNotification(); - for (FapServiceList fapService : fapServiceLists) { - cluster = clusterUtils.modifyCluster(cluster, fapService); + Either<List<String>, Integer> bufferedNotifications = getBufferedNotifications(); + + if (bufferedNotifications.isRight()) { + log.info("No buffered notifications"); + done = true; + } else { + List<Map<CellPciPair, ArrayList<CellPciPair>>> clusterMaps = getClusterMapsFromNotifications( + bufferedNotifications.left().value()); + for (Map<CellPciPair, ArrayList<CellPciPair>> 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<Map<CellPciPair, ArrayList<CellPciPair>>> getClusterMapsFromNotifications(List<String> notifications) { + ObjectMapper mapper = new ObjectMapper(); + List<Map<CellPciPair, ArrayList<CellPciPair>>> clusterMaps = new ArrayList<>(); + for (String notification : notifications) { + Map<CellPciPair, ArrayList<CellPciPair>> 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<List<String>, 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<String> 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<String> 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<FapServiceList> bufferNotification() { + public List<Map<CellPciPair, ArrayList<CellPciPair>>> bufferNotification() { // Processing Buffered notifications - List<FapServiceList> fapServiceLists = new ArrayList<>(); + List<Map<CellPciPair, ArrayList<CellPciPair>>> 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<CellPciPair, ArrayList<CellPciPair>> clusterMap; + clusterMap = queue.poll(); + clusterMapList.add(clusterMap); } + } - return fapServiceLists; + return clusterMapList; } + public Either<List<AnrInput>, Integer> checkAnrTrigger(List<String> cellidList) { + + List<AnrInput> anrInputList = new ArrayList<>(); + Configuration configuration = Configuration.getInstance(); + int poorThreshold = configuration.getPoorThreshold(); + List<HoDetails> hoDetailsList; + Either<List<HoDetails>, Integer> response; + for (String cellId : cellidList) { + response = hoMetricsComponent.getHoMetrics(cellId); + List<String> 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<String, ArrayList<Integer>> collisionConfusionResult) { + // determine collision or confusion + + Configuration configuration = Configuration.getInstance(); + int collisionSum = 0; + int confusionSum = 0; + + for (Map.Entry<String, ArrayList<Integer>> entry : collisionConfusionResult.entrySet()) { + + ArrayList<Integer> 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<String, List<CellPciPair>> pnfs = pnfUtils.getPnfs(solutions); + + for (Map.Entry<String, List<CellPciPair>> entry : pnfs.entrySet()) { + String pnfName = entry.getKey(); + List<CellPciPair> cellPciPairs = entry.getValue(); + + 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> configurations = new ArrayList<>(); + for (AnrSolutions anrSolution : solutions.getAnrSolutions()) { + String cellId = anrSolution.getCellId(); + List<LteCell> lteCellList = new ArrayList<>(); + for (String removeableNeighbor : anrSolution.getRemoveableNeighbors()) { + LteCell lteCell = new LteCell(); + lteCell.setBlacklisted("true"); + lteCell.setPlmnId(solutions.getNetworkId()); + lteCell.setCid(removeableNeighbor); + int pci = SdnrRestClient.getPci(cellId); + String pnfName = SdnrRestClient.getPnfName(cellId); + lteCell.setPhyCellId(pci); + lteCell.setPnfName(pnfName); + lteCellList.add(lteCell); + } + 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<FapServiceList> queue; - private ClusterUtils clusterUtils; - private Detection detect; - Properties confProp; - ClusterDetails details = new ClusterDetails(); - - public ClusterFormation() { - this.detect = new Detection(); - } - - /** - * parameterized constructor. - * - */ - public ClusterFormation(BlockingQueue<FapServiceList> 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<String, ArrayList<Integer>> collisionConfusionResult) { - // determine collision or confusion - - Configuration configuration = Configuration.getInstance(); - int collisionSum = 0; - int confusionSum = 0; - - for (Map.Entry<String, ArrayList<Integer>> entry : collisionConfusionResult.entrySet()) { - - ArrayList<Integer> 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<String, ArrayList<Integer>> waitForNotification(Map<String, ArrayList<Integer>> 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<String, ArrayList<Integer>> detectCollisionConfusion(Graph cluster) { + log.info("Finding collision and confusion count"); Map<CellPciPair, ArrayList<CellPciPair>> clusterMap = cluster.getCellPciNeighbourMap(); HashMap<String, ArrayList<Integer>> 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<CellPciPair, ArrayList<CellPciPair>> cellPciNeighbourMap; private UUID graphId; + + private String networkId; + + public String getNetworkId() { + return networkId; + } + + public void setNetworkId(String networkId) { + this.networkId = networkId; + } + + + private Map<String, ArrayList<Integer>> collisionConfusionMap; + + public Map<String, ArrayList<Integer>> getCollisionConfusionMap() { + return collisionConfusionMap; + } + + public void setCollisionConfusionMap(Map<String, ArrayList<Integer>> collisionConfusionMap) { + this.collisionConfusionMap = collisionConfusionMap; + } /** * Parameterized constructor. */ - public Graph(String clusterInfo) { + public Graph(String clusterInfo) { JSONArray cells = new JSONArray(clusterInfo); Map<CellPciPair, ArrayList<CellPciPair>> cellMap = new HashMap<>(); @@ -62,9 +83,10 @@ public class Graph { ArrayList<CellPciPair> neighbours = new ArrayList<>(); try { neighbours = mapper.readValue(cell.getString("neighbours"), - new TypeReference<ArrayList<CellPciPair>>() { }); + new TypeReference<ArrayList<CellPciPair>>() { + }); } 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<String, List<CellPciPair>> getPnfs(List<Solution> solutions) throws ConfigDbNotFoundException { + public Map<String, List<CellPciPair>> getPnfs(Solutions solutions) throws ConfigDbNotFoundException { Map<String, List<CellPciPair>> pnfs = new HashMap<>(); - - for (Solution solution : solutions) { - List<SonSolution> pciSolutions = solution.getPciSolutions(); - for (SonSolution pciSolution : pciSolutions) { + List<PciSolutions> 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<List<String>> 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<String, ArrayList<Integer>> result, - String networkId) throws OofNotFoundException, InterruptedException { - // check for 0 collision and 0 confusion - ArrayList<String> cellidList = new ArrayList<>(); - ArrayList<String> cellIds = new ArrayList<>(); - - for (Map.Entry<String, ArrayList<Integer>> entry : result.entrySet()) { - String key = entry.getKey(); - ArrayList<Integer> arr; - arr = entry.getValue(); - if (!arr.isEmpty()) { - Set<Integer> 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<String> cellidList, + String networkId, List<AnrInput> anrInputList) throws OofNotFoundException, InterruptedException { + + log.info("Triggering oof"); + log.debug("the cells triggering the oof are {}", cellidList); UUID transactionId = UUID.randomUUID(); @@ -97,8 +66,8 @@ public class StateOof { List<String> 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<String> 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<Solution> solutions; - solutions = async.getSolutions(); - PnfUtils pnfUtils = new PnfUtils(); - Map<String, List<CellPciPair>> pnfs = pnfUtils.getPnfs(solutions); - - for (Map.Entry<String, List<CellPciPair>> entry : pnfs.entrySet()) { - String pnfName = entry.getKey(); - List<CellPciPair> cellPciPairs = entry.getValue(); - - 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<String,Object> streamsSubscribes=(Map<String, Object>) jsonObject.get("streams_subscribes"); - final Map<String,Object> streamsPublishes=(Map<String, Object>) 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<String> dmaapServers = (List<String>) 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<String> optimizers = (List<String>) 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<Map<String, Object>>() {}.getType(); + JsonObject policyJson = jsonObject.getAsJsonObject("policy"); + Map<String,Object> policy = new Gson().fromJson(policyJson, mapType); + configPolicy.setConfig(policy); + }, throwable -> log.warn("Ooops", throwable)) ; + + } + + 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<Map<String, Object>>() {}.getType(); + + JsonObject subscribes = jsonObject.getAsJsonObject("streams_subscribes"); + Map<String, Object> streamsSubscribes = new Gson().fromJson(subscribes, mapType); + + JsonObject publishes = jsonObject.getAsJsonObject("streams_publishes"); + Map<String, Object> streamsPublishes = new Gson().fromJson(publishes, mapType); + + int pgPort = jsonObject.get("postgres.port").getAsInt(); + int pollingInterval = jsonObject.get("sonhandler.pollingInterval").getAsInt(); + String pgPassword = jsonObject.get("postgres.password").getAsString(); + 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<List<String>>() {}.getType(); + List<String> dmaapServers = new Gson().fromJson(servers, listType); + + String cg = jsonObject.get("sonhandler.cg").getAsString(); + int bufferTime = jsonObject.get("sonhandler.bufferTime").getAsInt(); + String cid = jsonObject.get("sonhandler.cid").getAsString(); + String configDbService = jsonObject.get("sonhandler.configDb.service").getAsString(); + + String callbackUrl = "http://" + System.getenv("HOSTNAME") + ":8080/callbackUrl"; + + JsonArray optimizersJson = jsonObject.getAsJsonArray("sonhandler.optimizers"); + List<String> 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<HandOverMetrics, String> { + + @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<PerformanceNotifications, String> { + + @Query(nativeQuery = true, + value = "DELETE FROM performance_notifications " + + "WHERE notification = ( SELECT notification FROM performance_notifications ORDER BY " + + "created_at FOR UPDATE SKIP LOCKED LIMIT 1 ) RETURNING notification;") + + 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<PciRequests, String> { +public interface SonRequestsRepository extends CrudRepository<SonRequests, String> { @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<String,Object> streamSubscribes= Configuration.getInstance().getStreamsSubscribes(); - String sdnrTopicUrl =((Map<String,String>)((Map<String,Object>)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<String, Object> streamSubscribes = Configuration.getInstance().getStreamsSubscribes(); + String sdnrTopicUrl = ((Map<String, String>) ((Map<String, Object>) 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<String, String>) ((Map<String, Object>) 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<String, String>) ((Map<String, Object>) 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<String,Object> streamSubscribes= Configuration.getInstance().getStreamsPublishes(); - String policyTopicUrl =((Map<String,String>)((Map<String,Object>)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<String, Object> streamsPublishes = Configuration.getInstance().getStreamsPublishes(); + String policyTopicUrl = ((Map<String, String>) ((Map<String, Object>) streamsPublishes.get("CL_topic")) + .get("dmaap_info")).get("topic_url"); + String[] policyTopicSplit = policyTopicUrl.split("\\/"); + String policyTopic = policyTopicSplit[policyTopicSplit.length - 1]; + Configuration configuration = Configuration.getInstance(); + CambriaBatchingPublisher cambriaBatchingPublisher; + try { + + 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 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<Map<String,String>> arrayOfNamedHashMap; + + public AdditionalMeasurements() { + + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public List<Map<String, String>> getArrayOfNamedHashMap() { + return arrayOfNamedHashMap; + } + public void setArrayOfNamedHashMap(List<Map<String, String>> 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<String> removeableNeighbors; + + public AnrInput() { + + } + /** + * Parameterized Constructor. + */ + + public AnrInput(String cellId, List<String> removeableNeighbors) { + super(); + this.cellId = cellId; + this.removeableNeighbors = removeableNeighbors; + } + public String getCellId() { + return cellId; + } + public void setCellId(String cellId) { + this.cellId = cellId; + } + public List<String> getRemoveableNeighbors() { + return removeableNeighbors; + } + public void setRemoveableNeighbors(List<String> removeableNeighbors) { + this.removeableNeighbors = removeableNeighbors; + } + + +} 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<CellPciPair> neighbourList; + + public ClusterMap() { + + } + + /** + * Constructor. + */ + public ClusterMap(CellPciPair cell, ArrayList<CellPciPair> neighbourList) { + super(); + this.cell = cell; + this.neighbourList = neighbourList; + } + + public CellPciPair getCell() { + return cell; + } + + public void setCell(CellPciPair cell) { + this.cell = cell; + } + + public ArrayList<CellPciPair> getNeighbourList() { + return neighbourList; + } + + public void setNeighbourList(ArrayList<CellPciPair> 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> additionalMeasurements; + + /** + * default constructor + */ + public Measurement() { + + } + public String getMeasurementInterval() { + return measurementInterval; + } + + public void setMeasurementInterval(String measurementInterval) { + this.measurementInterval = measurementInterval; + } + + public List<AdditionalMeasurements> getAdditionalMeasurements() { + return additionalMeasurements; + } + + public void setAdditionalMeasurements(List<AdditionalMeasurements> 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> lteNeighborListInUseLteCell; + @JsonProperty("LTECell") + private List<LteCell> lteCell; + @JsonProperty("LTECellNumberOfEntries") private String lteCellNumberOfEntries; @@ -39,13 +42,14 @@ public class NeighborListInUse { /** * Parameterized Constructor. */ - - public NeighborListInUse(List<LteNeighborListInUseLteCell> lteNeighborListInUseLteCell, + public NeighborListInUse(List<LteNeighborListInUseLteCell> lteNeighborListInUseLteCell, List<LteCell> lteCell, String lteCellNumberOfEntries) { super(); this.lteNeighborListInUseLteCell = lteNeighborListInUseLteCell; + this.lteCell = lteCell; this.lteCellNumberOfEntries = lteCellNumberOfEntries; } + public List<LteNeighborListInUseLteCell> 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<String> removeableNeighbors = new ArrayList<>(); + + public AnrSolutions() { + + } + + public AnrSolutions(String cellId, List<String> removeableNeighbors) { + super(); + this.cellId = cellId; + this.removeableNeighbors = removeableNeighbors; + } + + public String getCellId() { + return cellId; + } + public void setCellId(String cellId) { + this.cellId = cellId; + } + public List<String> getRemoveableNeighbors() { + return removeableNeighbors; + } + public void setRemoveableNeighbors(List<String> removeableNeighbors) { + this.removeableNeighbors = removeableNeighbors; + } + @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<Solution> solutions; + Solutions solutions; public String getTransactionId() { return transactionId; @@ -69,11 +67,11 @@ public class AsyncResponseBody { this.statusMessage = statusMessage; } - public List<Solution> getSolutions() { + public Solutions getSolutions() { return solutions; } - public void setSolutions(List<Solution> 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<String> cellIdList = new ArrayList<>(); + protected List<AnrInput> anrInputList = new ArrayList<>(); + String trigger; + + + public List<AnrInput> getAnrInputList() { + return anrInputList; + } + + public void setAnrInputList(List<AnrInput> 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<String> cellIdList, - String networkId, List<String> optimizers) throws OofNotFoundException { + String networkId, List<String> optimizers, List<AnrInput> 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<String,String> 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 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<String> optimizers = null; + protected Map<String, String> callbackHeader = new HashMap<>(); + + + public Map<String, String> getCallbackHeader() { + return callbackHeader; + } + + public void setCallbackHeader(Map<String, String> callbackHeader) { + this.callbackHeader = callbackHeader; + } public void setOptimizers(List<String> 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<CellPciPair> 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 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<SonSolution> 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> pciSolutions = new ArrayList<>(); + List<AnrSolutions> anrSolutions = new ArrayList<>(); + + public Solutions() { + } - public String getNetworkId() { return networkId; } @@ -54,22 +41,33 @@ public class Solution { this.networkId = networkId; } - public List<SonSolution> getPciSolutions() { + public List<PciSolutions> getPciSolutions() { return pciSolutions; } /** * Sets PciSolutions. */ - public void setPciSolutions(List<SonSolution> pciSolutions) { + public void setPciSolutions(List<PciSolutions> pciSolutions) { this.pciSolutions = pciSolutions; } + public List<AnrSolutions> getAnrSolutions() { + return anrSolutions; + } + + public void setAnrSolutions(List<AnrSolutions> 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<ClusterDetails> getAllClusters() { ClusterDetailsComponent clusterDetailsComponent = new ClusterDetailsComponent(); - return clusterDetailsComponent.getClusterDetails(); + return clusterDetailsComponent.getClusterDetails(); + } + + /** + * Get cluster for FM notifications. + */ + public FaultNotificationtoClusterMapping getClustersForFmNotification(Set<String> cellIds, + List<ClusterDetails> clusterDetails) { + List<String> newCells = new ArrayList<>(); + Map<String, String> cellsInCluster = new HashMap<String, String>(); + FaultNotificationtoClusterMapping faultNotificationtoClusterMapping = new FaultNotificationtoClusterMapping(); + for (String cellId : cellIds) { + for (ClusterDetails clusterDetail : clusterDetails) { + Graph cluster = new Graph(clusterDetail.getClusterInfo()); + + Set<String> 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<FapServiceList, String> cellsInCluster = new HashMap<>(); List<FapServiceList> newCells = new ArrayList<>(); - + List<FapServiceList> fapServiceList = notification.getPayload().getRadioAccess().getFapServiceList(); - + for (FapServiceList fapService : fapServiceList) { for (ClusterDetails clusterDetail : clusterDetails) { Set<String> cellsInNotification = getCellsInNotification(fapService); - + Graph cluster = new Graph(clusterDetail.getClusterInfo()); Set<String> 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<Graph, Integer> getClusterForCell(FapServiceList fapService, List<Graph> newClusters) { - + if (newClusters.isEmpty()) { return Either.right(404); } - - + for (Graph cluster : newClusters) { - + Set<String> cellsInNotification = getCellsInNotification(fapService); Set<String> clusterCells = getCellsInCluster(cluster); @@ -139,7 +173,31 @@ public class ClusterUtils { return Either.right(404); } - + + /** + * Get clusters for FM Cell. + */ + public Either<Graph, Integer> getClusterForFMCell(String cellId, List<Graph> newClusters) { + if (newClusters.isEmpty()) { + log.info("getClusterForFMCell 404"); + return Either.right(404); + } + for (Graph cluster : newClusters) { + + Set<String> clusterCells = getCellsInCluster(cluster); + for (String clusterCell : clusterCells) { + if (cellId.equals(clusterCell)) { + return Either.left(cluster); + + } + + } + + } + return Either.right(404); + + } + private Set<String> getCellsInNotification(FapServiceList fapService) { Set<String> 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<CellPciPair, ArrayList<CellPciPair>> 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<LteNeighborListInUseLteCell> 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<CellPciPair> keySet = clusterMap.keySet(); + Iterator<CellPciPair> iterate = keySet.iterator(); + CellPciPair val = (CellPciPair) iterate.next(); + + List<CellPciPair> 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<CellPciPair> nbrList = SdnrRestClient.getNbrList(neighbourlist.get(i).getAlias()); + List<CellPciPair> 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<LteNeighborListInUseLteCell> 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<CellPciPair, ArrayList<CellPciPair>> clusterMap; - clusterMap = cluster.getCellPciNeighbourMap(); + /** + * Find cluster Map. + */ + public Map<CellPciPair, ArrayList<CellPciPair>> 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<CellPciPair> cellPciPairs; + cellPciPairs = (ArrayList<CellPciPair>) SdnrRestClient.getNbrList(cellId); + Map<CellPciPair, ArrayList<CellPciPair>> clusterMap = new HashMap<>(); + clusterMap.put(main, cellPciPairs); + log.info("clusterMap{}", clusterMap); + + return clusterMap; + } + + /** + * Modify cluster. + */ + public Graph modifyCluster(Graph cluster, Map<CellPciPair, ArrayList<CellPciPair>> clusterMap) { + Set<CellPciPair> keySet = clusterMap.keySet(); + Iterator<CellPciPair> iterate = keySet.iterator(); + CellPciPair mainCellPciPair = (CellPciPair) iterate.next(); + String cellId = mainCellPciPair.getCellId(); + List<CellPciPair> newNeighbourList = clusterMap.get(mainCellPciPair); + + Map<CellPciPair, ArrayList<CellPciPair>> existingClusterMap; + existingClusterMap = cluster.getCellPciNeighbourMap(); // coe List<CellPciPair> tempCellPair = new ArrayList<>(); - for (Map.Entry<CellPciPair, ArrayList<CellPciPair>> entry : clusterMap.entrySet()) { + for (Map.Entry<CellPciPair, ArrayList<CellPciPair>> 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<CellPciPair> 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 extends CambriaClient> T buildCambriaClient( - CambriaClientBuilders.AbstractAuthenticatedManagerBuilder<? extends CambriaClient> 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 extends CambriaClient> T buildCambriaClient( + CambriaClientBuilders.AbstractAuthenticatedManagerBuilder<? extends CambriaClient> 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<Object> 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 <T> ResponseEntity<T> sendPostToPolicy(String requestUrl, String requestBody, - ParameterizedTypeReference<T> 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<Object> 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<Void> 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<Object> 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<Object> 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<Graph> newClusters, BlockingQueue<List<String>> childStatusQueue, - ExecutorService pool, EventHandler eventHandler) { + ExecutorService pool, EventHandler eventHandler,String cellId) { + + for (Graph cluster : newClusters) { - BlockingQueue<FapServiceList> queue = new LinkedBlockingQueue<>(); + BlockingQueue<Map<CellPciPair, ArrayList<CellPciPair>>> 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 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- - ============LICENSE_START======================================================= - son-handler - ================================================================================ - Copyright (C) 2019 Wipro Limited. - ============================================================================== - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ============LICENSE_END========================================================= - - --> +<!-- ============LICENSE_START======================================================= + son-handler ================================================================================ + Copyright (C) 2019 Wipro Limited. ============================================================================== + Licensed under the Apache License, Version 2.0 (the "License"); you may not + use this file except in compliance with the License. You may obtain a copy + of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required + by applicable law or agreed to in writing, software distributed under the + License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS + OF ANY KIND, either express or implied. See the License for the specific + language governing permissions and limitations under the License. ============LICENSE_END========================================================= --> <configuration> <appender name="FILE-THREAD" class="ch.qos.logback.classic.sift.SiftingAppender"> <discriminator> @@ -27,23 +17,27 @@ </discriminator> <sift> - <appender name="file-${logFileName}" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <file>/var/log/onap/son-handler/${logFileName}.log</file> - <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> - <fileNamePattern>${logFileName}.%i.log.zip</fileNamePattern> - <minIndex>1</minIndex> - <maxIndex>5</maxIndex> - </rollingPolicy> - <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> - <maxFileSize>5MB</maxFileSize> - </triggeringPolicy> - <encoder> - <pattern>%d{dd-MM-yyyy HH:mm:ss.SSS} %magenta([%thread]) %highlight(%-5level) %logger{36}.%M - %msg%n</pattern> - </encoder> - </appender> - </sift> + <appender name="file-${logFileName}" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>/var/log/onap/son-handler/${logFileName}.log</file> + <rollingPolicy + class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> + <fileNamePattern>${logFileName}.%i.log.zip</fileNamePattern> + <minIndex>1</minIndex> + <maxIndex>5</maxIndex> + </rollingPolicy> + <triggeringPolicy + class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> + <maxFileSize>5MB</maxFileSize> + </triggeringPolicy> + <encoder> + <pattern>%d{dd-MM-yyyy HH:mm:ss.SSS} %magenta([%thread]) + %highlight(%-5level) %logger{36}.%M - %msg%n</pattern> + </encoder> + </appender> + </sift> </appender> - <root level="debug"> - <appender-ref ref="FILE-THREAD" /> - </root> + <root level="info"> + <appender-ref ref="FILE-THREAD" /> + </root> </configuration> 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<String> list = new ArrayList<String>(); list.add("server"); + Map<String, Object> 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,17 +85,35 @@ public class DmaapNotificationsComponentTest { when(dmaapNotificationsRepositoryMock.getNotificationFromQueue()).thenReturn(notificationString); - Either<Notification, Integer> result = component.getDmaapNotifications(); + Either<Notification, Integer> 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<PMNotification,Integer> 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) { String content = new String(); 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<List<FaultEvent>, 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<List<HoDetails>, 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<String> cellidList = new ArrayList<>(); + cellidList.add("cell1"); + //PowerMockito.mockStatic(Configuration.class); + Configuration config = Configuration.getInstance() ; + config.setPoorThreshold(70); + //PowerMockito.when(Configuration.getInstance()).thenReturn(config); + Either<List<HoDetails>, Integer> response = null; + HoDetails hoDetail = new HoDetails(); + hoDetail.setDstCellId("dstCell1"); + hoDetail.setSuccessRate(60); + List<HoDetails> 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<String> 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<String, Object> configPolicyMap = new HashMap<>(); - configPolicyMap.put("PCI_MODCONFIG_POLICY_NAME", "ControlLoop-vPCI-fb41f388-a5f2-11e8-98d0-529269fb1459"); - configPolicy.setConfig(configPolicyMap); - childThreadUtils = new ChildThreadUtils(configPolicy); - } - - @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<CellPciPair> 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<String, Object> configPolicyMap = new HashMap<>(); + configPolicyMap.put("PCI_MODCONFIG_POLICY_NAME", "ControlLoop-vPCI-fb41f388-a5f2-11e8-98d0-529269fb1459"); + configPolicy.setConfig(configPolicyMap); + childThreadUtils = new ChildThreadUtils(configPolicy, pnfUtils, policyDmaapClient); + 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<String, ArrayList<Integer>> collisionConfusionResult = new HashMap<String, ArrayList<Integer>>(); + ArrayList<Integer> list = new ArrayList<Integer>(); + list.add(6); + list.add(7); + collisionConfusionResult.put("cellId", list); + + Boolean result = childThreadUtils.triggerOrWait(collisionConfusionResult); + assertTrue(result); + Map<String, ArrayList<Integer>> collisionConfusionResult1 = new HashMap<String, ArrayList<Integer>>(); + + ArrayList<Integer> list1 = new ArrayList<Integer>(); + 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<CellPciPair> 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<String,List<CellPciPair>> pnfsMap = new HashMap<String,List<CellPciPair>>(); + CellPciPair cell1 = new CellPciPair("cell0", 1); + CellPciPair cell2 = new CellPciPair("cell1", 2); + CellPciPair cell3 = new CellPciPair("cell2", 3); + List<CellPciPair> 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<String,ArrayList<Integer>> 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<Solution> solutions = new ArrayList<>(); + private static Solutions solutions = new Solutions(); private static Optional<CellInfo> cellInfo; private static Optional<CellInfo> cellInfoNull; @@ -85,7 +84,7 @@ public class TestPnfUtils { ObjectMapper mapper = new ObjectMapper(); try { - solutions=mapper.readValue(solutionsString,new TypeReference<List<Solution>>(){}); + 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<LteNeighborListInUseLteCell> 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<SonSolution> pciSolutionsList = new ArrayList<SonSolution>(); + anrSolutions.setCellId("cell2"); + + List<PciSolutions> pciSolutionsList = new ArrayList<PciSolutions>(); + List<AnrSolutions> anrSolutionsList = new ArrayList<AnrSolutions>(); + + 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<Solution> solutionsList = new ArrayList<Solution>(); - 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<String> optimizers=new ArrayList<String>(); optimizers.add("pci"); + List<AnrInput> 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.<ParameterizedTypeReference<String>>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.<ParameterizedTypeReference<String>>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<AnrSolutions> anrSolutionsList = new ArrayList<>(); + List<PciSolutions> pciSolutionsList = new ArrayList<>(); + + PciSolutions pciSolutions = new PciSolutions(); pciSolutions.setCellId("EXP001"); pciSolutions.setPci(101); - List<SonSolution> pciSolutionsList = new ArrayList<SonSolution>(); pciSolutionsList.add(pciSolutions); - Solution solutions = new Solution(); - solutions.setFinishTime("2018-10-01T00:40+01.00"); + AnrSolutions anrSolutions = new AnrSolutions(); + anrSolutions.setCellId("EXP001"); + List<String> 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<ClusterDetails> clusterDetailsForGetClusterDetailsFromClusterIdTest; private static Graph cluster; private static List<ClusterDetails> clusterDetails = new ArrayList<>(); - + @BeforeClass public static void setup() { - + notification1 = new Notification(); notification2 = new Notification(); clusterDetailsForGetClusterDetailsFromClusterIdTest = new ArrayList<ClusterDetails>(); - + 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<List<ClusterDetails>>(){}); + clusterDetailsForGetClusterDetailsFromClusterIdTest = mapper.readValue(clusterDetailsListString, + new TypeReference<List<ClusterDetails>>() { + }); } 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<FapServiceList, String> cellsinCluster = new HashMap<>(); cellsinCluster.put(notification1.getPayload().getRadioAccess().getFapServiceList().get(0), "2"); expected.setCellsinCluster(cellsinCluster); expected.setNewCells(new ArrayList<FapServiceList>()); - + NotificationToClusterMapping result = clusterUtils.getClustersForNotification(notification1, clusterDetails); assertEquals(expected, result); - + expected = new NotificationToClusterMapping(); List<FapServiceList> 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<CellPciPair, ArrayList<CellPciPair>> clusterMap = new HashMap<CellPciPair, ArrayList<CellPciPair>>(); + + List<CellPciPair> firstNbrList = new ArrayList<>(); List<CellPciPair> 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<CellPciPair>) firstNbrList); + + assertEquals(cluster, clusterUtils.createCluster(clusterMap)); + } - + @Test public void getClusterDetailsFromClusterIdTest() { - ClusterDetails responseValue=null; + ClusterDetails responseValue = null; Integer responseVal = null; - Integer expectedValue=404; - Either<ClusterDetails, Integer> response=clusterUtils.getClusterDetailsFromClusterId("0",clusterDetailsForGetClusterDetailsFromClusterIdTest); + Integer expectedValue = 404; + Either<ClusterDetails, Integer> 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<Graph> newClusters=new ArrayList<Graph>(); + 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<Graph> newClusters = new ArrayList<Graph>(); newClusters.add(graph1); newClusters.add(graph2); - Either<Graph, Integer> result=clusterUtils.getClusterForCell(fapServiceList, newClusters); + Either<Graph, Integer> 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<Graph> emptyList=new ArrayList<Graph>(); - - result=clusterUtils.getClusterForCell(fapServiceList, emptyList); + + List<Graph> emptyList = new ArrayList<Graph>(); + + 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<CellPciPair, ArrayList<CellPciPair>> clusterMap = new HashMap<CellPciPair, ArrayList<CellPciPair>>(); + + ArrayList<CellPciPair> 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
|