--- /dev/null
+# ============LICENSE_START=======================================================
+# son-handler
+# ================================================================================
+# Copyright (C) 2019 Wipro Limited.
+# ==============================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+
+pgaas_cluster_name: dcae-pg-primary.onap
+database_name: sonhms
+tag_version: nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.son-handler:latest
+replicas: 1
+aaf_username:
+aaf_password:
+polling_interval: 20
+polling_timeout: 60
+num_solutions: 5
+min_collision: 5
+min_confusion: 5
+max_clusters: 5
+dmaap: message-router
+buffer_time: 60
+cg: sonhms-cg
+cid: sonhms-cid
+config_db: http://sdnc.onap.svc.cluster.local:8181
+oof: http://oof.onap.svc.cluster.local:8080
+pci_optimizer: pci
+log_path: /dockerdata-nfs/son-handler
+topic00_location: onap
+topic00_client_role: son-subscriber
+topic00_client_id: sdnr-son-1
+topic00_url: https://message-router.onap.svc.cluster.local:3905/events/unauthenticated.SEC_MEASUREMENT_OUTPUT
+topic01_location: onap
+topic01_client_role: son-subscriber
+topic01_client_id: sdnr-son-1
+topic01_url: https://message-router.onap.svc.cluster.local:3905/events/unauthenticated.SEC_FAULT_OUTPUT
+topic02_location: onap
+topic02_client_role: son-subscriber
+topic02_client_id: sdnr-son-1
+topic02_url: https://message-router.onap.svc.cluster.local:3905/events/PCI-NOTIF-TOPIC-NGHBR-LIST-CHANGE-INFO
+topic03_location: onap
+topic03_client_role: son-subscriber
+topic03_client_id: sdnr-son-1
+topic03_url: https://message-router.onap.svc.cluster.local:3905/events/DCAE_CL_OUTPUT
--- /dev/null
+ #============LICENSE_START=======================================================
+ # son-handler
+ # ================================================================================
+ # Copyright (C) 2019 Wipro Limited.
+ # ==============================================================================
+ # Licensed under the Apache License, Version 2.0 (the "License");
+ # you may not use this file except in compliance with the License.
+ # You may obtain a copy of the License at
+ #
+ # http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing, software
+ # distributed under the License is distributed on an "AS IS" BASIS,
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ # ============LICENSE_END=========================================================
+
+tosca_definitions_version: cloudify_dsl_1_3
+imports:
+ - "http://www.getcloudify.org/spec/cloudify/3.4/types.yaml"
+ - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/k8splugin/1.4.5/k8splugin_types.yaml
+ - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.ccsdk.platform.plugins/type_files/pgaas/1.1.0/pgaas_types.yaml
+inputs:
+ replicas:
+ type: integer
+ description: replica count for deployment
+ default: 1
+ tag_version:
+ type: string
+ description: docker image name and version
+ default: "nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.son-handler:latest"
+ pgaas_cluster_name:
+ type: string
+ description: pg cluster
+ default: "dcae-postgres.onap.svc.cluster.local"
+ database_name:
+ type: string
+ description: database name
+ default: sonhms
+ aaf_username:
+ type: string
+ description: aaf username
+ aaf_password:
+ type: string
+ description: aaf password
+ polling_interval:
+ type: integer
+ description: dmaap polling interval
+ default: 20
+ polling_timeout:
+ type: integer
+ description: dmaap polling timeout
+ default: 60
+ num_solutions:
+ type: integer
+ description: num of solutions
+ default: 5
+ min_collision:
+ type: integer
+ description: minimum no. of collisions
+ default: 5
+ min_confusion:
+ type: integer
+ description: minimum no. of confusions
+ default: 5
+ max_clusters:
+ type: integer
+ description: maximum clusters
+ default: 5
+ dmaap:
+ type: string
+ description: dmaap server
+ default: message-router
+ buffer_time:
+ type: integer
+ description: buffer time
+ default: 60
+ cg:
+ type: string
+ description: consumer group
+ default: sonhms-cg
+ cid:
+ type: string
+ description: consumer id
+ default: sonhms-cid
+ config_db:
+ type: string
+ description: config db location
+ oof:
+ type: string
+ description: oof location
+ pci_optimizer:
+ type: string
+ description: pci optimizer name in oof
+ default: pci
+ log_path:
+ type: string
+ description: log location in host
+ default: /dockerdata-nfs/son-handler
+ topic00_location:
+ topic01_location:
+ topic02_location:
+ topic03_location:
+ topic00_client_role:
+ topic01_client_role:
+ topic02_client_role:
+ topic03_client_role:
+ topic00_client_id:
+ topic01_client_id:
+ topic02_client_id:
+ topic03_client_id:
+ topic00_url:
+ topic01_url:
+ topic02_url:
+ topic03_url:
+
+node_templates:
+ pgaasvm:
+ type: dcae.nodes.pgaas.database
+ properties:
+ writerfqdn: { get_input: pgaas_cluster_name }
+ name: { get_input: database_name }
+ use_existing: false
+
+ sonhms:
+ type: dcae.nodes.ContainerizedServiceComponent
+ interfaces:
+ cloudify.interfaces.lifecycle:
+ start:
+ inputs:
+ ports:
+ - "8080:0"
+ volumes:
+ - host:
+ path: { get_input: log_path }
+ container:
+ bind: /var/log/onap
+ mode: rw
+ properties:
+ image:
+ get_input: tag_version
+ service_component_type: 'dcae-sonhms'
+ service_id: 'sonhms'
+ always_pull_image: true
+ replicas: {get_input: replicas}
+ docker_config:
+ healthcheck:
+ endpoint: /healthcheck
+ interval: 15s
+ timeout: 1s
+ type: http
+ application_config:
+ streams_subscribes:
+ performance_management_topic:
+ aaf_username: { get_input: aaf_username }
+ aaf_password: { get_input: aaf_password }
+ dmaap_info:
+ location: { get_input: topic00_location }
+ client_role: { get_input: topic00_client_role }
+ client_id: { get_input: topic00_client_id }
+ topic_url: { get_input: topic00_url }
+ type: message-router
+ fault_management_topic:
+ aaf_username: { get_input: aaf_username }
+ aaf_password: { get_input: aaf_password }
+ dmaap_info:
+ location: { get_input: topic01_location }
+ client_role: { get_input: topic01_client_role }
+ client_id: { get_input: topic01_client_id }
+ topic_url: { get_input: topic01_url }
+ type: message-router
+ nbr_list_change_topic:
+ aaf_username: { get_input: aaf_username }
+ aaf_password: { get_input: aaf_password }
+ dmaap_info:
+ location: { get_input: topic02_location }
+ client_role: { get_input: topic02_client_role }
+ client_id: { get_input: topic02_client_id }
+ topic_url: { get_input: topic02_url }
+ type: message-router
+ streams__publishes:
+ CL_topic:
+ aaf_username: { get_input: aaf_username }
+ aaf_password: { get_input: aaf_password }
+ dmaap_info:
+ location: { get_input: topic03_location }
+ client_role: { get_input: topic03_client_role }
+ client_id: { get_input: topic03_client_id }
+ topic_url: { get_input: topic03_url }
+ type: message-router
+ postgres.host: { get_attribute: [ pgaasvm, admin, host ] }
+ postgres.port: { get_attribute: [ pgaasvm, admin, port ] }
+ postgres.username: { get_attribute: [ pgaasvm, admin, user ] }
+ postgres.password: { get_attribute: [ pgaasvm, admin, password ] }
+ sonhandler.pollingInterval: { get_input: polling_interval}
+ sonhandler.pollingTimeout: { get_input: polling_timeout }
+ sonhandler.numSolutions: { get_input: num_solutions }
+ sonhandler.minCollision: { get_input: min_collision }
+ sonhandler.minConfusion: { get_input: min_confusion }
+ sonhandler.maximumClusters: { get_input: max_clusters }
+ sonhandler.sourceId: SONHMS
+ sonhandler.dmaap.server:
+ - { get_input: dmaap }
+ sonhandler.bufferTime: { get_input: buffer_time }
+ sonhandler.cg: { get_input: cg }
+ sonhandler.cid: { get_input: cid }
+ sonhandler.configDb.service: { get_input: config_db }
+ sonhandler.oof.service: { get_input: oof }
+ sonhandler.optimizers:
+ - { get_input: pci_optimizer }
+ service_calls:
+ sdnr-getpnfname: []
+ sdnr-getpci: []
+ sdnr-getnbrlist: []
+ sdnr-getcelllist: []
+ oof-req: []
+ policy-req: []
+ relationships:
+ - type: cloudify.relationships.depends_on
+ target: pgaasvm
+
+
+
+
--- /dev/null
+{
+ "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"
+ }
+}
+
--- /dev/null
+{
+ "self": {
+ "name": "CONFIGDB-REQ",
+ "version": "1.0.0",
+ "description": "Request to config DB"
+
+ },
+ "dataformatversion": "1.0.0",
+ "unstructured": {
+ "encoding": "UTF-8"
+ }
+}
--- /dev/null
+{"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"
+ }
+}
+}
--- /dev/null
+{
+ "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"
+ }
+}
+
--- /dev/null
+{
+ "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"
+ }
+}
--- /dev/null
+{
+ "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"
+ }
+}
--- /dev/null
+{
+ "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"
+ }
+}
+
--- /dev/null
+{
+ "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"
+ }
+}
+
--- /dev/null
+{
+ "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"
+ }
+}
--- /dev/null
+{
+ "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"
+ }
+}
+
--- /dev/null
+{
+ "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"
+ }
+}
+
--- /dev/null
+{
+ "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"
+ }
+}
+
--- /dev/null
+{
+ "dataformatversion": "1.0.0",
+ "jsonschema": {
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "additionalproperties": true,
+ "description": "",
+ "properties": {
+ "AAI": {
+ "additionalproperties": true,
+ "description": "",
+ "properties": {
+ "generic-vnf.is-closed-loop-disabled": {
+ "description": "",
+ "type": "string"
+ },
+ "generic-vnf.prov-status": {
+ "description": "",
+ "type": "string"
+ },
+ "generic-vnf.vnf-id": {
+ "description": "",
+ "type": "string"
+ }
+ },
+ "required": [
+ "generic-vnf.is-closed-loop-disabled",
+ "generic-vnf.prov-status",
+ "generic-vnf.vnf-id"
+ ],
+ "type": "object"
+ },
+ "Action": {
+ "description": "",
+ "type": "string"
+ },
+ "closedLoopAlarmStart": {
+ "description": "",
+ "type": "integer"
+ },
+ "closedLoopControlName": {
+ "description": "",
+ "type": "string"
+ },
+ "closedLoopEventClient": {
+ "description": "",
+ "type": "string"
+ },
+ "closedLoopEventStatus": {
+ "description": "",
+ "type": "string"
+ },
+ "from": {
+ "description": "",
+ "type": "string"
+ },
+ "payload": {
+ "description": "",
+ "type": "string"
+ },
+ "requestID": {
+ "description": "",
+ "type": "string"
+ },
+ "target": {
+ "description": "",
+ "type": "string"
+ },
+ "target_type": {
+ "description": "",
+ "type": "string"
+ },
+ "version": {
+ "description": "",
+ "type": "string"
+ }
+ },
+ "required": [
+ "AAI", "Action", "closedLoopAlarmStart", "closedLoopControlName", "closedLoopEventClient", "closedLoopEventStatus", "from", "payload", "requestID", "target", "target_type", "version"
+ ],
+ "type": "object"
+ },
+ "self": {
+ "description": "",
+ "name": "SON_TO_POLICY_DMAAP",
+ "version": "1.0.0"
+ }
+}
--- /dev/null
+{
+ "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"
+ }
+}
+
--- /dev/null
+{
+ "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"
+ }
+ ]
+}
#
#*******************************************************************************
-psql -U postgres -tc "SELECT 1 FROM pg_database WHERE datname = 'pci_ms'" | grep -q 1 || psql -U postgres -c "CREATE DATABASE pci_ms"
+java -jar /bin/application.jar
+
<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>javax.json-api</artifactId>
<version>1.1.2</version>
</dependency>
-
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<dependency>
<groupId>org.onap.oparent</groupId>
<artifactId>checkstyle</artifactId>
- <version>1.2.3-SNAPSHOT</version>
+ <version>1.2.3</version>
<scope>compile</scope>
</dependency>
</dependencies>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.0.4.RELEASE</version>
<executions>
- <execution>
- <goals>
- <goal>repackage</goal>
- </goals>
- </execution>
- </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>
</project>
+++ /dev/null
-from busybox
-
-RUN mkdir /docker-entrypoint-initdb.d
-
-ADD createdb.sql /tmp
-
-
+++ /dev/null
-FROM java:openjdk-8
-
-ADD config.json /etc/config.json
-
-ADD policy.crt /policy.crt
-
-RUN keytool -import -file /policy.crt -alias policycert -keystore /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/security/cacerts -storepass changeit -noprompt
-
-COPY pci-handler-1.0-SNAPSHOT.jar application.jar
-
-ADD entrypoint.sh .
-
-RUN chmod +x entrypoint.sh
-
-EXPOSE 8080
-
-ENTRYPOINT ["./entrypoint.sh"]
+++ /dev/null
-{
- "topics":[
- {
- "name": "PCI-NOTIF-TOPIC-NGHBR-LIST-CHANGE-INFO",
- "producer": "SDNR_API_KEY",
- "consumer": "PCIMS_API_KEY"
- },
- {
- "name": "DCAE_CL_OUTPUT",
- "producer": "PCIMS_API_KEY",
- "consumer": "POLICY_API_KEY"
- },
- {
- "name": "SDNR-CL",
- "producer": "POLICY_API_KEY",
- "consumer": "SDNR_API_KEY"
- },
- {
- "name": "SDNR-CL-RSP",
- "producer": "SDNR_API_KEY",
- "consumer": "POLICY_API_KEY"
- }
- ],
- "sdnrTopic": "PCI-NOTIF-TOPIC-NGHBR-LIST-CHANGE-INFO",
- "policyTopic": "DCAE_CL_OUTPUT",
- "servers": ["DMAAP_SERVER:3904"],
- "managerApiKey": "MANAGER_API_KEY",
- "managerSecretKey": "MANAGER_SECRET_KEY",
- "pcimsApiKey": "PCIMS_API_KEY",
- "pcimsSecretKey": "PCIMS_SECRET_KEY",
- "cg": "pcims-cg",
- "cid": "pcims-cid",
- "pollingTimeout": "60",
- "pollingInterval": "20",
- "minCollision": "5",
- "minConfusion": "5",
- "sdnrService": "http://SDNR_SERVICE",
- "oofService": "http://OOF_SERVICE",
- "policyService": "https://POLICY_SERVICE",
- "sourceId": "PCIHMS",
- "callbackUrl": "http://pcims.onap:8080/callbackUrl",
- "policyName": "com.Config_PCIMS_CONFIG_POLICY.1.xml",
- "configName": "PCIMS_CONFIG_POLICY",
- "optimizers": ["pci"],
- "bufferTime": "60000",
- "numSolutions": "1",
- "maximumClusters": "5"
-}
+++ /dev/null
-#!/bin/bash
-#*******************************************************************************
-# ============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=========================================================
-#
-#*******************************************************************************
-
-sed -i s/DMAAP_SERVER/$DMAAPSERVER/ /etc/config.json
-sed -i s/SDNR_SERVICE/$SDNRSERVICE/ /etc/config.json
-sed -i s/OOF_SERVICE/$OOFSERVICE/ /etc/config.json
-sed -i s/POLICY_SERVICE/$POLICYSERVICE/ /etc/config.json
-sed -i s/PCIMS_SERVICE_HOST/$PCIMS_SERVICE_HOST/ /etc/config.json
-sed -i s/MANAGER_API_KEY/$MANAGERAPIKEY/ /etc/config.json
-sed -i s/MANAGER_SECRET_KEY/$MANAGERSECRETKEY/ /etc/config.json
-sed -i s/PCIMS_API_KEY/$PCIMSAPIKEY/ /etc/config.json
-sed -i s/PCIMS_SECRET_KEY/$PCIMSSECRETKEY/ /etc/config.json
-sed -i s/SDNR_API_KEY/$SDNRAPIKEY/ /etc/config.json
-sed -i s/POLICY_API_KEY/$POLICYAPIKEY/ /etc/config.json
-java -jar application.jar
-
+++ /dev/null
------BEGIN CERTIFICATE-----\r
-MIIEkzCCA3ugAwIBAgIIaG5i2/yYcycwDQYJKoZIhvcNAQELBQAwRzELMAkGA1UE\r
-BhMCVVMxDTALBgNVBAoMBE9OQVAxDjAMBgNVBAsMBU9TQUFGMRkwFwYDVQQDDBBp\r
-bnRlcm1lZGlhdGVDQV85MB4XDTE4MTAxMTIyMDkwNVoXDTE5MDQxMTIyMDkwNVow\r
-bzEPMA0GA1UEAwwGcG9saWN5MQ8wDQYJKoZIhvcNAQkBFgAxHzAdBgNVBAsMFnBv\r
-bGljeUBwb2xpY3kub25hcC5vcmcxDjAMBgNVBAsMBU9TQUFGMQ0wCwYDVQQKDARP\r
-TkFQMQswCQYDVQQGEwJVUzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB\r
-ALdwMkNAqr43X9eBdGV9xT+Gi2usZC8GdOvAuEJ0srqdLY1baSMrGDY6sN4o5o/X\r
-fD+wwoaTYtnrrESC13BEoXRo7vIuqxKnNjqkljHcgk09m8BaBB5zQQQULoeEEVIV\r
-7c9+agrE+Jg3BPsilyWnJco6zLPpjSuTlqEvCtUjk6aQ+dS8ItHN26c/W42AuyLn\r
-iofaWY2HZdhOZJg6UetyITOywQ5o3vl09tE+zPzk7cixsxVUJy2aunUuDcrFiyKf\r
-tSX3XBAxaspgVtnNrUheudwkWc5pdBFNYSJS8NSCc7yDuAz0AfrCS7Tcd4IZG7Lw\r
-zJjMoIj0fOsinFViPkiyAA8CAwEAAaOCAVkwggFVMAkGA1UdEwQCMAAwDgYDVR0P\r
-AQH/BAQDAgXgMCAGA1UdJQEB/wQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjBUBgNV\r
-HSMETTBLgBSB95lbELnIjN7zUl7qTmmgQz6s3aEwpC4wLDEOMAwGA1UECwwFT1NB\r
-QUYxDTALBgNVBAoMBE9OQVAxCzAJBgNVBAYTAlVTggEHMB0GA1UdDgQWBBTO1RjR\r
-xvjgraJ+1nZUENDKSngpITCBoAYDVR0RBIGYMIGVggZwb2xpY3mCBSoucGRwghwq\r
-LnBkcC5vbmFwLnN2Yy5jbHVzdGVyLmxvY2FsggZicm1zZ3eCC2JybXNndy5vbmFw\r
-ggZkcm9vbHOCC2Ryb29scy5vbmFwggNwYXCCCHBhcC5vbmFwggNwZHCCCHBkcC5v\r
-bmFwgh5wb2xpY3kuYXBpLnNpbXBsZWRlbW8ub25hcC5vcmcwDQYJKoZIhvcNAQEL\r
-BQADggEBAHuhhuTD5zcrBaPGU7NT9V82BwrCPfEH2UTxracU/P/3YRQ4yBcnnyX4\r
-FznNAHJOrNnwdz7kht0XLV2Td5iI+Gs0X5AVlQE2paSgiJRXPkwU7un5xk7a6cbN\r
-7lnx5RcAxVBi6Nf078cSPu0I+E344MUoYwKb4haBKTB2lN48W7HxzePdnWZiPhrR\r
-iTIKwUa1WvKPG9KpbOZDbukCfStPeMb2i0G3rk4T/Vr1cDRLyG8u1nnJEHeAoU+t\r
-SWAq9bKpspFW0rRd2m8jOcql9ja7OUSgU0Qt10xoUQrkogS3Y8P8ib0Nf/kuyTnJ\r
-aAchKp0OSx2z8HceBCQPEJsR5Cj1h2M=\r
------END CERTIFICATE-----\r
package org.onap.dcaegen2.services.sonhms;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.onap.dcaegen2.services.sonhms.dmaap.DmaapClient;
-import org.onap.dcaegen2.services.sonhms.restclient.PolicyRestClient;
-import org.onap.dcaegen2.services.sonhms.utils.FileIo;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.annotation.PostConstruct;
+import javax.sql.DataSource;
+import org.onap.dcaegen2.services.sonhms.controller.ConfigFetchFromCbs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.jdbc.DataSourceBuilder;
+import org.springframework.context.annotation.Bean;
-@SpringBootApplication
+@SpringBootApplication
public class Application {
- @Autowired
- DmaapClient dmaapClient;
-
- @Autowired
- MainThreadComponent mainThreadComponent;
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);
+ }
+ log.info("after 10s sleep");
+ log.info("Starting spring boot application");
SpringApplication.run(Application.class);
}
/**
- * initialization.
- */
- @PostConstruct
- void init() {
- getConfig();
- fetchIntialConfigFromPolicy();
- NewNotification newNotification = new NewNotification(false);
- dmaapClient.initClient(newNotification);
- mainThreadComponent.init(newNotification);
- }
-
- /**
- * Gets configuration from policy.
- */
- @SuppressWarnings("unchecked")
- private void fetchIntialConfigFromPolicy() {
- log.debug("fetch initial config from policy");
- String configPolicyResponseJson = PolicyRestClient.fetchConfigFromPolicy();
- if (configPolicyResponseJson.equals("Post failed")) {
- log.debug("cannot fetch config from policy");
- return;
- }
- ObjectMapper mapper = new ObjectMapper();
- List<HashMap<String, Object>> configPolicyResponse = new ArrayList<>();
- try {
- configPolicyResponse = mapper.readValue(configPolicyResponseJson, List.class);
- } catch (IOException e) {
- log.debug("exception during parsing response from policy", e);
- }
- String configPolicyJson = null;
- if (configPolicyResponse != null) {
- configPolicyJson = (String) configPolicyResponse.get(0).get("config");
- } else {
- return;
- }
- Map<String, Object> configPolicyMap = new HashMap<>();
- try {
- configPolicyMap = mapper.readValue(configPolicyJson, HashMap.class);
- } catch (IOException e) {
- log.debug("exception during parsing config body from policy", e);
- }
- ConfigPolicy configPolicy = ConfigPolicy.getInstance();
- configPolicy.setConfig(configPolicyMap);
- if (log.isDebugEnabled()) {
- log.debug(configPolicy.toString());
- }
- }
-
- /**
- * Gets config from config.json.
- *
+ * DataSource bean.
*/
- private void getConfig() {
- log.debug("getting initial config");
- String configJson = FileIo.readFromFile("/etc/config.json");
- ObjectMapper mapper = new ObjectMapper();
+ @Bean
+ public DataSource dataSource() {
Configuration configuration = Configuration.getInstance();
- try {
- mapper.readerForUpdating(configuration).readValue(configJson);
- if (log.isDebugEnabled()) {
- log.debug(configuration.toString());
- }
- } catch (IOException e) {
- log.debug("exception during parsing configuration", e);
- }
+
+ String url = "jdbc:postgresql://" + configuration.getPgHost() + ":" + configuration.getPgPort() + "/sonhms";
+
+ return DataSourceBuilder
+ .create()
+ .url(url)
+ .username(configuration.getPgUsername())
+ .password(configuration.getPgPassword())
+ .build();
}
+
}
package org.onap.dcaegen2.services.sonhms;
+import java.util.List;
+
import org.onap.dcaegen2.services.sonhms.dao.BufferedNotificationsRepository;
import org.onap.dcaegen2.services.sonhms.entity.BufferedNotifications;
import org.onap.dcaegen2.services.sonhms.utils.BeanUtil;
-import java.util.List;
public class BufferNotificationComponent {
* Retrieves buffered notification from the database.
*/
public List<String> getBufferedNotification(String clusterId) {
- BufferedNotificationsRepository bufferedNotificationsRepository = BeanUtil
+ BufferedNotificationsRepository bufferedNotificationsRepository = BeanUtil
.getBean(BufferedNotificationsRepository.class);
return bufferedNotificationsRepository.getNotificationsFromQueue(clusterId);
package org.onap.dcaegen2.services.sonhms;
+import java.util.List;
+
import org.onap.dcaegen2.services.sonhms.dao.ClusterDetailsRepository;
import org.onap.dcaegen2.services.sonhms.entity.ClusterDetails;
import org.onap.dcaegen2.services.sonhms.utils.BeanUtil;
-import java.util.List;
-
public class ClusterDetailsComponent {
package org.onap.dcaegen2.services.sonhms;
import java.util.List;
+import java.util.Map;
public class Configuration {
private static Configuration instance = null;
- private List<Topic> topics;
- private String sdnrTopic;
- private String policyTopic;
- private List<String> servers;
- private String managerApiKey;
- private String managerSecretKey;
- private String pcimsApiKey;
- private String pcimsSecretKey;
+ private String pgHost;
+ private int pgPort;
+ private String pgUsername;
+ private String pgPassword;
+ private List<String> dmaapServers;
+ private String configDbService;
+ private String oofService;
private String cg;
private String cid;
private int pollingInterval;
private int pollingTimeout;
private int minCollision;
private int minConfusion;
- private String sdnrService;
- private String policyService;
- private String oofService;
private String sourceId;
- private String policyName;
- private String configName;
private String callbackUrl;
private List<String> optimizers;
private int numSolutions;
private int bufferTime;
- private int maximumClusters;
- private String consulHost;
- private String hostName;
- private String configBindingService;
+ private int maximumClusters;
+ private String aafUsername;
+ private String aafPassword;
+ private Map<String,Object> streamsSubscribes;
+ private Map<String,Object> streamsPublishes;
- public String getConsulHost() {
- return consulHost;
- }
+ public boolean isSecured() {
+ if(aafUsername.equals("")||aafUsername==null){
+ return false;
+ }
+ else
+ return true;
+ }
- public void setConsulHost(String consulHost) {
- this.consulHost = consulHost;
- }
- public String getHostName() {
- return hostName;
- }
+
+ public String getAafUsername() {
+ return aafUsername;
+ }
- public void setHostName(String hostName) {
- this.hostName = hostName;
- }
- public String getConfigBindingService() {
- return configBindingService;
- }
- public void setConfigBindingService(String configBindingService) {
- this.configBindingService = configBindingService;
- }
+ public void setAafUsername(String aafUsername) {
+ this.aafUsername = aafUsername;
+ }
+
+
+
+ public String getAafPassword() {
+ return aafPassword;
+ }
+
+
+
+ public void setAafPassword(String aafPassword) {
+ this.aafPassword = aafPassword;
+ }
+
+
- public int getMaximumClusters() {
+ public Map<String, Object> getStreamsSubscribes() {
+ return streamsSubscribes;
+ }
+
+ public void setStreamsSubscribes(Map<String, Object> streamsSubscribes) {
+ this.streamsSubscribes = streamsSubscribes;
+ }
+
+ public Map<String, Object> getStreamsPublishes() {
+ return streamsPublishes;
+ }
+
+ public void setStreamsPublishes(Map<String, Object> streamsPublishes) {
+ this.streamsPublishes = streamsPublishes;
+ }
+
+ public int getMaximumClusters() {
return maximumClusters;
}
return instance;
}
- public List<String> getServers() {
- return servers;
- }
-
- public void setServers(List<String> servers) {
- this.servers = servers;
- }
-
- public String getManagerApiKey() {
- return managerApiKey;
- }
-
- public void setManagerApiKey(String managerApiKey) {
- this.managerApiKey = managerApiKey;
- }
-
- public String getManagerSecretKey() {
- return managerSecretKey;
- }
-
- public void setManagerSecretKey(String managerSecretKey) {
- this.managerSecretKey = managerSecretKey;
- }
-
- public String getPcimsApiKey() {
- return pcimsApiKey;
- }
-
- public void setPcimsApiKey(String pcimsApiKey) {
- this.pcimsApiKey = pcimsApiKey;
- }
-
- public String getPcimsSecretKey() {
- return pcimsSecretKey;
- }
-
- public void setPcimsSecretKey(String pcimsSecretKey) {
- this.pcimsSecretKey = pcimsSecretKey;
- }
-
public String getCg() {
return cg;
}
this.minConfusion = minConfusion;
}
- public String getSdnrService() {
- return sdnrService;
- }
-
- public void setSdnrService(String sdnrService) {
- this.sdnrService = sdnrService;
- }
-
- public String getPolicyService() {
- return policyService;
- }
-
- public void setPolicyService(String policyService) {
- this.policyService = policyService;
- }
-
public String getOofService() {
return oofService;
}
this.sourceId = sourceId;
}
- public String getPolicyName() {
- return policyName;
- }
-
- public void setPolicyName(String policyName) {
- this.policyName = policyName;
- }
-
- public String getConfigName() {
- return configName;
- }
-
- public void setConfigName(String configName) {
- this.configName = configName;
- }
-
- public String getCallbackUrl() {
+ public String getCallbackUrl() {
return callbackUrl;
}
this.bufferTime = bufferTime;
}
- public List<Topic> getTopics() {
- return topics;
+ public String getPgHost() {
+ return pgHost;
+ }
+
+ public void setPgHost(String pgHost) {
+ this.pgHost = pgHost;
}
- public void setTopics(List<Topic> topics) {
- this.topics = topics;
+ public int getPgPort() {
+ return pgPort;
}
- public String getSdnrTopic() {
- return sdnrTopic;
+ public void setPgPort(int pgPort) {
+ this.pgPort = pgPort;
}
- public void setSdnrTopic(String sdnrTopic) {
- this.sdnrTopic = sdnrTopic;
+ public String getPgUsername() {
+ return pgUsername;
}
- public String getPolicyTopic() {
- return policyTopic;
+ public void setPgUsername(String pgUsername) {
+ this.pgUsername = pgUsername;
}
- public void setPolicyTopic(String policyTopic) {
- this.policyTopic = policyTopic;
+ public String getPgPassword() {
+ return pgPassword;
}
- @Override
- public String toString() {
- return "Configuration [topics=" + topics + ", sdnrTopic=" + sdnrTopic + ", policyTopic=" + policyTopic
- + ", servers=" + servers + ", managerApiKey=" + managerApiKey + ", managerSecretKey=" + managerSecretKey
- + ", pcimsApiKey=" + pcimsApiKey + ", pcimsSecretKey=" + pcimsSecretKey + ", cg=" + cg + ", cid=" + cid
- + ", pollingInterval=" + pollingInterval + ", pollingTimeout=" + pollingTimeout + ", minCollision="
- + minCollision + ", minConfusion=" + minConfusion + ", sdnrService=" + sdnrService + ", policyService="
- + policyService + ", oofService=" + oofService + ", sourceId=" + sourceId + ", policyName=" + policyName
- + ", configName=" + configName + ", callbackUrl=" + callbackUrl + ", optimizers=" + optimizers
- + ", numSolutions=" + numSolutions + ", bufferTime=" + bufferTime + ", maximumClusters="
- + maximumClusters + "]";
+ 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;
+ }
+
+
+
+ @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 + "]";
+ }
+
+
+
+
}
+++ /dev/null
-/*******************************************************************************
- * ============LICENSE_START=======================================================
- * son-handler
- * ================================================================================
- * Copyright (C) 2019 Wipro Limited.
- * ==============================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- *
- *******************************************************************************/
-
-package org.onap.dcaegen2.services.sonhms;
-
-import org.onap.dcaegen2.services.sonhms.utils.SonHandlerRestTemplate;
-
-import org.json.JSONArray;
-import org.json.JSONObject;
-import org.json.JSONTokener;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.core.ParameterizedTypeReference;
-import org.springframework.http.ResponseEntity;
-
-
-public class ConfigurationFetcher {
- private static Logger log = LoggerFactory.getLogger(ConfigurationFetcher.class);
-
- /**
- * method that fetches config from config binding service.
- */
- public void fetchFromCbs() {
-
- Configuration configuration = Configuration.getInstance();
- String consulHost = configuration.getConsulHost();
- String configBindingService = configuration.getConfigBindingService();
- ResponseEntity<String> response = null;
- String requestUrl = "";
- if ((consulHost != null) && (configBindingService != null)) {
- requestUrl = consulHost + ":8500/v1/catalog/service/" + configBindingService;
- response = SonHandlerRestTemplate.sendPostRequest(requestUrl, "",
- new ParameterizedTypeReference<String>() {});
- }
- JSONTokener jsonTokener = new JSONTokener(response.getBody());
- JSONObject cbsjobj = (JSONObject) new JSONArray(jsonTokener).get(0);
- String cbsUrl = "";
- String configurationRequestUrl = "";
- ResponseEntity<String> configurationResponse = null;
- if (cbsjobj.has("ServiceAddress") && cbsjobj.has("ServicePort")) {
- cbsUrl = cbsjobj.getString("ServiceAddress") + ":" + cbsjobj.getInt("ServicePort");
-
- }
-
- configurationRequestUrl = cbsUrl + "/service_component/" + configuration.getHostName();
- configurationResponse = SonHandlerRestTemplate.sendPostRequest1(configurationRequestUrl, "",
- new ParameterizedTypeReference<String>() {});
- JSONObject config = new JSONObject(new JSONTokener(configurationResponse.getBody()));
- String configString = config.toString();
- log.debug("config:{}",configString);
- }
-
-
-}
\ No newline at end of file
package org.onap.dcaegen2.services.sonhms;
import com.fasterxml.jackson.databind.ObjectMapper;
-import org.onap.dcaegen2.services.sonhms.dao.DmaapNotificationsRepository;
-import org.onap.dcaegen2.services.sonhms.model.Notification;
-import org.onap.dcaegen2.services.sonhms.utils.BeanUtil;
+
import fj.data.Either;
import java.io.IOException;
+import org.onap.dcaegen2.services.sonhms.dao.DmaapNotificationsRepository;
+import org.onap.dcaegen2.services.sonhms.model.Notification;
+import org.onap.dcaegen2.services.sonhms.utils.BeanUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
-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.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;
import fj.data.Either;
+
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Set;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
+
+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.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;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
try {
List<ClusterDetails> clusterDetails = clusterUtils.getAllClusters();
- NotificationToClusterMapping mapping = new NotificationToClusterMapping();
- mapping = clusterUtils.getClustersForNotification(notification, clusterDetails);
+ NotificationToClusterMapping mapping = clusterUtils.getClustersForNotification(notification,
+ clusterDetails);
// Matching cells
- System.out.println(mapping);
if (mapping.getCellsinCluster() != null) {
handleMatchingCells(mapping.getCellsinCluster(), clusterDetails);
}
package org.onap.dcaegen2.services.sonhms;
-import org.onap.dcaegen2.services.sonhms.model.Notification;
-import org.onap.dcaegen2.services.sonhms.utils.ClusterUtils;
-import org.onap.dcaegen2.services.sonhms.utils.ThreadUtils;
-
import fj.data.Either;
import java.util.HashMap;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
+import org.onap.dcaegen2.services.sonhms.model.Notification;
+import org.onap.dcaegen2.services.sonhms.utils.ClusterUtils;
+import org.onap.dcaegen2.services.sonhms.utils.ThreadUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package org.onap.dcaegen2.services.sonhms;
+import javax.annotation.PostConstruct;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
private static Logger log = LoggerFactory.getLogger(MainThreadComponent.class);
-
+ @Autowired
+ private NewNotification newNotification;
/**
* main thread initialization.
*/
- public void init(NewNotification newNotification) {
+ @PostConstruct
+ public void init() {
log.debug("initializing main thread");
Thread thread = new Thread(new MainThread(newNotification));
thread.start();
package org.onap.dcaegen2.services.sonhms;
+import org.springframework.stereotype.Component;
+
+@Component
public class NewNotification {
private Boolean newNotif;
super();
this.newNotif = newNotif;
}
+
+ public NewNotification() {
+
+ }
}
package org.onap.dcaegen2.services.sonhms;
-import org.onap.dcaegen2.services.sonhms.model.FapServiceList;
-
import java.util.List;
import java.util.Map;
+import org.onap.dcaegen2.services.sonhms.model.FapServiceList;
+
public class NotificationToClusterMapping {
import org.onap.dcaegen2.services.sonhms.child.ChildThread;
import org.onap.dcaegen2.services.sonhms.restclient.AsyncResponseBody;
-
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
package org.onap.dcaegen2.services.sonhms;
import org.onap.dcaegen2.services.sonhms.dao.SonRequestsRepository;
-
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
package org.onap.dcaegen2.services.sonhms.child;
-import org.onap.dcaegen2.services.sonhms.Configuration;
-import org.onap.dcaegen2.services.sonhms.dao.ClusterDetailsRepository;
-import org.onap.dcaegen2.services.sonhms.model.FapServiceList;
-import org.onap.dcaegen2.services.sonhms.model.ThreadId;
-import org.onap.dcaegen2.services.sonhms.restclient.AsyncResponseBody;
-import org.onap.dcaegen2.services.sonhms.utils.BeanUtil;
-import org.onap.dcaegen2.services.sonhms.utils.ClusterUtils;
-
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.UUID;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
+
+import org.onap.dcaegen2.services.sonhms.Configuration;
+import org.onap.dcaegen2.services.sonhms.dao.ClusterDetailsRepository;
+import org.onap.dcaegen2.services.sonhms.model.FapServiceList;
+import org.onap.dcaegen2.services.sonhms.model.ThreadId;
+import org.onap.dcaegen2.services.sonhms.restclient.AsyncResponseBody;
+import org.onap.dcaegen2.services.sonhms.utils.BeanUtil;
+import org.onap.dcaegen2.services.sonhms.utils.ClusterUtils;
import org.slf4j.Logger;
import org.slf4j.MDC;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
+
+import java.util.ArrayList;
+import java.util.List;
+
import org.onap.dcaegen2.services.sonhms.ConfigPolicy;
import org.onap.dcaegen2.services.sonhms.model.CellConfig;
import org.onap.dcaegen2.services.sonhms.model.CellPciPair;
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 java.util.ArrayList;
-import java.util.List;
import org.slf4j.Logger;
public class ChildThreadUtils {
package org.onap.dcaegen2.services.sonhms.child;
-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 java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Map;
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;
package org.onap.dcaegen2.services.sonhms.child;
-import org.onap.dcaegen2.services.sonhms.model.CellPciPair;
-
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
+import org.onap.dcaegen2.services.sonhms.model.CellPciPair;
import org.slf4j.Logger;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
-import org.onap.dcaegen2.services.sonhms.model.CellNeighbourList;
-import org.onap.dcaegen2.services.sonhms.model.CellPciPair;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;
-
import java.util.concurrent.ConcurrentHashMap;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
+import org.onap.dcaegen2.services.sonhms.model.CellNeighbourList;
+import org.onap.dcaegen2.services.sonhms.model.CellPciPair;
import org.slf4j.Logger;
public class Graph {
package org.onap.dcaegen2.services.sonhms.child;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
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.restclient.SonSolution;
import org.onap.dcaegen2.services.sonhms.utils.BeanUtil;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-
public class PnfUtils {
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.restclient.OofRestClient;
import org.onap.dcaegen2.services.sonhms.restclient.Solution;
import org.onap.dcaegen2.services.sonhms.utils.BeanUtil;
-
-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.slf4j.Logger;
public class StateOof {
--- /dev/null
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.controller;
+
+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.model.EnvProperties;
+import org.onap.dcaegen2.services.sdk.rest.services.model.logging.RequestDiagnosticContext;
+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);
+
+ /**
+ * Gets app config from CBS.
+ */
+ @SuppressWarnings("unchecked")
+ public void getAppConfig() {
+
+ // Generate RequestID and InvocationID which will be used when logging and in
+ // HTTP requests
+ log.debug("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();
+
+ // Create the client and use it to get the configuration
+ CbsClientFactory.createCbsClient(env).flatMap(cbsClient -> cbsClient.get(diagnosticContext))
+ .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 {}", configuration);
+ }, throwable -> {
+ log.warn("Ooops", throwable);
+ });
+
+ }
+
+}
@RestController
public class HealthCheck {
- @RequestMapping(value = "/healthcheck", method = RequestMethod.GET)
- ResponseEntity<HttpStatus> healthCheck() {
- return new ResponseEntity(HttpStatus.OK);
- }
+ @RequestMapping(value = "/healthcheck", method = RequestMethod.GET)
+ ResponseEntity<HttpStatus> healthCheck() {
+ return new ResponseEntity<>(HttpStatus.OK);
+ }
}
package org.onap.dcaegen2.services.sonhms.dao;
-import org.onap.dcaegen2.services.sonhms.entity.BufferedNotifications;
-
import java.util.List;
+import org.onap.dcaegen2.services.sonhms.entity.BufferedNotifications;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
package org.onap.dcaegen2.services.sonhms.dao;
import org.onap.dcaegen2.services.sonhms.entity.CellInfo;
-
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
package org.onap.dcaegen2.services.sonhms.dao;
-import org.onap.dcaegen2.services.sonhms.entity.ClusterDetails;
-
import java.util.List;
+import org.onap.dcaegen2.services.sonhms.entity.ClusterDetails;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
package org.onap.dcaegen2.services.sonhms.dao;
import org.onap.dcaegen2.services.sonhms.entity.DmaapNotifications;
-
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
* ============LICENSE_END=========================================================
*
*******************************************************************************/
-package org.onap.dcaegen2.services.sonhms;
-public class ApplicationTest {
+package org.onap.dcaegen2.services.sonhms.dao;
+
+import org.onap.dcaegen2.services.sonhms.entity.FaultNotifications;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.CrudRepository;
+import org.springframework.stereotype.Repository;
+
+
+@Repository
+public interface FaultNotificationsRepository extends CrudRepository<FaultNotifications, String> {
+
+ @Query(nativeQuery = true,
+ value = "DELETE FROM fault_notifications "
+ + "WHERE notification = ( SELECT notification FROM fault_notifications ORDER BY "
+ + "created_at FOR UPDATE SKIP LOCKED LIMIT 1 ) RETURNING notification;")
+
+ public String getFaultNotificationFromQueue();
}
+
+
+
package org.onap.dcaegen2.services.sonhms.dao;
import org.onap.dcaegen2.services.sonhms.entity.PciRequests;
-
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
package org.onap.dcaegen2.services.sonhms.dmaap;
-import com.att.nsa.apiClient.http.HttpException;
-import com.att.nsa.cambria.client.CambriaClient;
-import com.att.nsa.cambria.client.CambriaClientBuilders;
-import com.att.nsa.cambria.client.CambriaClientBuilders.ConsumerBuilder;
-import com.att.nsa.cambria.client.CambriaClientBuilders.TopicManagerBuilder;
import com.att.nsa.cambria.client.CambriaConsumer;
-import com.att.nsa.cambria.client.CambriaTopicManager;
+
import org.onap.dcaegen2.services.sonhms.Configuration;
import org.onap.dcaegen2.services.sonhms.NewNotification;
-import org.onap.dcaegen2.services.sonhms.Topic;
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.io.IOException;
-import java.net.MalformedURLException;
-import java.security.GeneralSecurityException;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@Component
public class DmaapClient {
- @Autowired
- private DmaapNotificationsRepository dmaapNotificationsRepository;
- private Configuration configuration;
- private static Logger log = LoggerFactory.getLogger(DmaapClient.class);
- private static final String CONSUMER = "CONSUMER";
- private static final String PRODUCER = "PRODUCER";
- private static final String DESCRIPTION = "api keys for OOF PCI use case";
- private static final int PARTITION_COUNT = 1;
- private static final int REPLICATION_COUNT = 1;
- private NewNotification newNotification;
- private CambriaTopicManager topicManager;
-
- 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(NewNotification newNotification) {
- log.debug("initializing client");
- configuration = Configuration.getInstance();
- if (log.isDebugEnabled()) {
- log.debug(configuration.toString());
- }
- this.newNotification = newNotification;
-
- createAndConfigureTopics();
- startClient();
- }
-
- /**
- * create and configures topics.
- */
- private void createAndConfigureTopics() {
-
- try {
- topicManager = buildCambriaClient(new TopicManagerBuilder().usingHosts(configuration.getServers())
- .authenticatedBy(configuration.getManagerApiKey(), configuration.getManagerSecretKey()));
- } catch (GeneralSecurityException | IOException e) {
- log.debug("exception during creating topic", e);
- }
- List<Topic> topics = configuration.getTopics();
-
- for (Topic topic : topics) {
- Set<String> topicsInDmaap = getAllTopicsFromDmaap();
-
- createTopic(topic, topicsInDmaap);
- subscribeToTopic(topic.getName(), topic.getProducer(), PRODUCER);
- subscribeToTopic(topic.getName(), topic.getConsumer(), CONSUMER);
-
- }
-
- topicManager.close();
-
- }
-
- /**
- * create topic.
- */
- private void createTopic(Topic topic, Set<String> topicsInDmaap) {
- if (topicsInDmaap.contains(topic.getName())) {
- log.debug("topic exists in dmaap");
- } else {
- try {
- topicManager.createTopic(topic.getName(), DESCRIPTION, PARTITION_COUNT, REPLICATION_COUNT);
- } catch (HttpException | IOException e) {
- log.debug("error while creating topic: {}", e);
- }
- }
- }
-
- /**
- * get all topics from dmaap.
- */
- private Set<String> getAllTopicsFromDmaap() {
- Set<String> topics = new HashSet<>();
- try {
- topics = topicManager.getTopics();
- } catch (IOException e) {
- log.debug("IOException while fetching topics");
- }
- return topics;
-
- }
-
- /**
- * start dmaap client.
- */
- private synchronized void startClient() {
-
- ScheduledExecutorService executorPool;
- CambriaConsumer cambriaConsumer = null;
-
- try {
- 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);
- } catch (MalformedURLException | GeneralSecurityException e) {
- log.debug("exception during starting client", e);
- }
-
- }
-
- /**
- * subscribe to topic.
- */
- private void subscribeToTopic(String topicName, String subscriberApiKey, String subscriberType) {
- if (subscriberType.equals(PRODUCER)) {
- try {
- topicManager.allowProducer(topicName, subscriberApiKey);
- } catch (HttpException | IOException e) {
- log.debug("error while subscribing to a topic: {}", e);
- }
- } else if (subscriberType.equals(CONSUMER)) {
- try {
- topicManager.allowConsumer(topicName, subscriberApiKey);
- } catch (HttpException | IOException e) {
- log.debug("error while subscribing to a topic: {}", e);
- }
- }
-
- }
-
- @SuppressWarnings("unchecked")
- private static <T extends CambriaClient> T buildCambriaClient(
- CambriaClientBuilders.AbstractAuthenticatedManagerBuilder<? extends CambriaClient> client)
- throws MalformedURLException, GeneralSecurityException {
- return (T) client.build();
- }
-
+ @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);
+
+ }
+
}
package org.onap.dcaegen2.services.sonhms.dmaap;
import com.att.nsa.cambria.client.CambriaConsumer;
-import org.onap.dcaegen2.services.sonhms.dmaap.DmaapClient.NotificationCallback;
import java.io.IOException;
+import org.onap.dcaegen2.services.sonhms.dmaap.DmaapClient.NotificationCallback;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package org.onap.dcaegen2.services.sonhms.dmaap;
import com.att.nsa.cambria.client.CambriaBatchingPublisher;
+
import java.io.IOException;
-import java.security.GeneralSecurityException;
public class NotificationProducer {
/**
- * Parameterised constructor.
+ * Parameterized constructor.
*/
public NotificationProducer(CambriaBatchingPublisher cambriaBatchingPublisher) {
super();
/**
* sends notification to dmaap.
*/
- public int sendNotification(String msg) throws GeneralSecurityException, IOException {
+ public int sendNotification(String msg) throws IOException {
- int result = cambriaBatchingPublisher.send("", msg);
- System.out.println(result);
- return result;
+ return cambriaBatchingPublisher.send("", msg);
}
package org.onap.dcaegen2.services.sonhms.dmaap;
import com.att.nsa.cambria.client.CambriaBatchingPublisher;
-import com.att.nsa.cambria.client.CambriaClientBuilders.PublisherBuilder;
import org.onap.dcaegen2.services.sonhms.Configuration;
+import org.onap.dcaegen2.services.sonhms.utils.DmaapUtils;
import java.io.IOException;
-import java.security.GeneralSecurityException;
+import java.util.Map;
public class PolicyDmaapClient {
+ DmaapUtils dmaapUtils = new DmaapUtils();
- /**
- * Method stub for sending notification to policy.
- */
- public boolean sendNotificationToPolicy(String msg) {
-
- Configuration configuration = Configuration.getInstance();
- CambriaBatchingPublisher cambriaBatchingPublisher;
- try {
- cambriaBatchingPublisher = new PublisherBuilder().usingHosts(configuration.getServers())
- .onTopic(configuration.getPolicyTopic())
- .authenticatedBy(configuration.getPcimsApiKey(), configuration.getPcimsSecretKey()).build();
- NotificationProducer notificationProducer = new NotificationProducer(cambriaBatchingPublisher);
- notificationProducer.sendNotification(msg);
- } catch (GeneralSecurityException | IOException e) {
- return false;
- }
- return true;
- }
+ /**
+ * 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;
+ }
}
--- /dev/null
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.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 = "FAULT_NOTIFICATIONS")
+public class FaultNotifications {
+
+ @Id
+ @Column(name = "notification", columnDefinition = "text")
+ private String notification;
+
+ @CreationTimestamp
+ @Column(name = "created_at", columnDefinition = "timestamp")
+ private Timestamp createdAt;
+
+ public FaultNotifications() {
+ }
+
+ public FaultNotifications(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;
+ }
+
+}
package org.onap.dcaegen2.services.sonhms.model;
import com.fasterxml.jackson.annotation.JsonProperty;
+
import java.util.List;
public class NeighborListInUse {
package org.onap.dcaegen2.services.sonhms.model;
import com.fasterxml.jackson.annotation.JsonProperty;
+
import java.util.List;
public class Payload {
return result;
}
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ return (this.hashCode() == obj.hashCode());
+ }
+
+
+
}
package org.onap.dcaegen2.services.sonhms.model;
import com.fasterxml.jackson.annotation.JsonProperty;
+
import java.util.List;
public class RadioAccess {
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
+
+import java.util.List;
+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.utils.SonHandlerRestTemplate;
-
-import java.util.List;
-import java.util.UUID;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.ParameterizedTypeReference;
/**
* rest client that pci uses to query the OOF for pci solutions.
- * @throws OofNotFoundException when request to oof fails
+ *
+ * @throws OofNotFoundException
+ * when request to oof fails
*/
- public static String queryOof(int numSolutions, String transactionId, String requestType,
- List<String> cellIdList, String networkId, List<String> optimizers) throws OofNotFoundException {
+ public static String queryOof(int numSolutions, String transactionId, String requestType, List<String> cellIdList,
+ String networkId, List<String> optimizers) throws OofNotFoundException {
log.debug("inside queryoof");
- ResponseEntity<String> response = null;
Configuration configuration = Configuration.getInstance();
+ UUID requestUuid = UUID.randomUUID();
+ String requestId = requestUuid.toString();
+ String callbackUrl = configuration.getCallbackUrl();
+ RequestInfo requestInfo = new RequestInfo();
+ requestInfo.setTransactionId(transactionId);
+ requestInfo.setRequestId(requestId);
+ requestInfo.setCallbackUrl(callbackUrl);
+ String sourceId = configuration.getSourceId();
+ requestInfo.setSourceId(sourceId);
+ requestInfo.setRequestType(requestType);
+ requestInfo.setNumSolutions(numSolutions);
+ requestInfo.setOptimizers(optimizers);
+ ConfigPolicy config = ConfigPolicy.getInstance();
+ int timeout = 60;
try {
- UUID requestUuid = UUID.randomUUID();
- String requestId = requestUuid.toString();
- String callbackUrl = configuration.getCallbackUrl();
- RequestInfo requestInfo = new RequestInfo();
- requestInfo.setTransactionId(transactionId);
- requestInfo.setRequestId(requestId);
- requestInfo.setCallbackUrl(callbackUrl);
- String sourceId = configuration.getSourceId();
- requestInfo.setSourceId(sourceId);
- requestInfo.setRequestType(requestType);
- requestInfo.setNumSolutions(numSolutions);
- requestInfo.setOptimizers(optimizers);
- ConfigPolicy config = ConfigPolicy.getInstance();
- int timeout = 60;
- try {
- timeout = (int) config.getConfig().get("PCI_NEIGHBOR_CHANGE_CLUSTER_TIMEOUT_IN_SECS");
- } catch (NullPointerException e) {
- log.debug("No config policy available. Using default timeout 60 sec");
- }
- requestInfo.setTimeout(timeout);
- CellInfo cellInfo = new CellInfo();
- cellInfo.setCellIdList(cellIdList);
- cellInfo.setNetworkId(networkId);
- OofRequestBody oofRequestBody = new OofRequestBody();
- oofRequestBody.setRequestInfo(requestInfo);
- oofRequestBody.setCellInfo(cellInfo);
-
- ObjectMapper mapper = new ObjectMapper();
- String requestBody = mapper.writeValueAsString(oofRequestBody);
- log.debug("requestBody{}", requestBody);
-
- String requestUrl = configuration.getOofService() + "/api/oof/v1/pci";
- log.debug("requestUrl {}", requestUrl);
-
- response = SonHandlerRestTemplate.sendPostRequestToOof(requestUrl, requestBody,new ParameterizedTypeReference<String>() {});
- if (response == null) {
- throw new OofNotFoundException("Request to oof failed");
- }
- log.debug("response {}", response);
+ timeout = (int) config.getConfig().get("PCI_NEIGHBOR_CHANGE_CLUSTER_TIMEOUT_IN_SECS");
+ } catch (NullPointerException e) {
+ log.debug("No config policy available. Using default timeout 60 sec");
+ }
+ requestInfo.setTimeout(timeout);
+ CellInfo cellInfo = new CellInfo();
+ cellInfo.setCellIdList(cellIdList);
+ cellInfo.setNetworkId(networkId);
+ OofRequestBody oofRequestBody = new OofRequestBody();
+ oofRequestBody.setRequestInfo(requestInfo);
+ oofRequestBody.setCellInfo(cellInfo);
- return response.getBody();
+ ObjectMapper mapper = new ObjectMapper();
+ String requestBody = "";
+ try {
+ requestBody = mapper.writeValueAsString(oofRequestBody);
} catch (JsonProcessingException e) {
- log.debug("exception{}", e);
+ log.error("Exception when forming JSON String {}", e);
+
+ }
+ log.debug("requestBody{}", requestBody);
+ String requestUrl = configuration.getOofService() + "/api/oof/v1/pci";
+ log.debug("requestUrl {}", requestUrl);
+ ResponseEntity<String> response = null;
+ response = SonHandlerRestTemplate.sendPostRequestToOof(requestUrl, requestBody,
+ new ParameterizedTypeReference<String>() {
+ });
+ if (response == null) {
+ throw new OofNotFoundException("Request to oof failed");
}
+ log.debug("response {}", response);
+
return response.getBody();
}
}
+++ /dev/null
-/*******************************************************************************
- * ============LICENSE_START=======================================================
- * son-handler
- * ================================================================================
- * Copyright (C) 2019 Wipro Limited.
- * ==============================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- *
- *******************************************************************************/
-
-package org.onap.dcaegen2.services.sonhms.restclient;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.onap.dcaegen2.services.sonhms.Configuration;
-import org.onap.dcaegen2.services.sonhms.utils.SonHandlerRestTemplate;
-
-import java.util.UUID;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.core.ParameterizedTypeReference;
-import org.springframework.http.ResponseEntity;
-
-public class PolicyRestClient {
- private static Logger log = LoggerFactory.getLogger(PolicyRestClient.class);
-
- private PolicyRestClient() {
-
- }
-
- /**
- * Fetches configuration from policy.
- */
- public static String fetchConfigFromPolicy() {
- log.debug("inside fetconfig from policy");
-
- Configuration configuration = Configuration.getInstance();
- ResponseEntity<String> response = null;
- String configName = configuration.getConfigName();
- String policyName = configuration.getPolicyName();
-
- try {
- PolicyRequestBody policyRequestBody = new PolicyRequestBody();
- policyRequestBody.setConfigName(configName);
- policyRequestBody.setPolicyName(policyName);
- UUID requestUuid = UUID.randomUUID();
- String requestId = requestUuid.toString();
- policyRequestBody.setRequestId(requestId);
- ObjectMapper mapper = new ObjectMapper();
- String requestBody;
- requestBody = mapper.writeValueAsString(policyRequestBody);
-
- log.debug("policyRequestBody{}", requestBody);
- String requestUrl = configuration.getPolicyService() + "/pdp/api/getConfig";
- response = SonHandlerRestTemplate.sendPostToPolicy(requestUrl, requestBody,new ParameterizedTypeReference<String>() {});
- log.debug("policy response{}", response);
-
- return response.getBody();
- } catch (JsonProcessingException e) {
- log.debug("exception", e);
- }
- return response.getBody();
-
- }
-
-}
package org.onap.dcaegen2.services.sonhms.restclient;
-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.SonHandlerRestTemplate;
-
import java.sql.Time;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import org.json.JSONArray;
import org.json.JSONObject;
+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.SonHandlerRestTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.ParameterizedTypeReference;
public static String getCellList(String networkId) throws ConfigDbNotFoundException {
Configuration configuration = Configuration.getInstance();
String ts = new SimpleDateFormat(DATETIMEFORMAT).format(new Time(System.currentTimeMillis()));
- String requestUrl = configuration.getSdnrService() + "/SDNCConfigDBAPI/getCellList" + "/" + networkId + "/"
+ String requestUrl = configuration.getConfigDbService() + "/SDNCConfigDBAPI/getCellList" + "/" + networkId + "/"
+ encode(ts);
return sendRequest(requestUrl);
}
public static List<CellPciPair> getNbrList(String cellId) throws ConfigDbNotFoundException {
Configuration configuration = Configuration.getInstance();
String ts = new SimpleDateFormat(DATETIMEFORMAT).format(new Time(System.currentTimeMillis()));
- String requestUrl = configuration.getSdnrService() + "/SDNCConfigDBAPI/getNbrList" + "/" + cellId + "/"
+ String requestUrl = configuration.getConfigDbService() + "/SDNCConfigDBAPI/getNbrList" + "/" + cellId + "/"
+ encode(ts);
log.debug("request url: {}", requestUrl);
String response = sendRequest(requestUrl);
public static int getPci(String cellId) throws ConfigDbNotFoundException {
Configuration configuration = Configuration.getInstance();
String ts = new SimpleDateFormat(DATETIMEFORMAT).format(new Time(System.currentTimeMillis()));
- String requestUrl = configuration.getSdnrService() + "/SDNCConfigDBAPI/getPCI" + "/" + cellId + "/"
+ String requestUrl = configuration.getConfigDbService() + "/SDNCConfigDBAPI/getPCI" + "/" + cellId + "/"
+ encode(ts);
String response = sendRequest(requestUrl);
JSONObject respObj = new JSONObject(response);
public static String getPnfName(String cellId) throws ConfigDbNotFoundException {
Configuration configuration = Configuration.getInstance();
String ts = new SimpleDateFormat(DATETIMEFORMAT).format(new Time(System.currentTimeMillis()));
- String requestUrl = configuration.getSdnrService() + "/SDNCConfigDBAPI/getPnfName" + "/" + cellId + "/"
+ String requestUrl = configuration.getConfigDbService() + "/SDNCConfigDBAPI/getPnfName" + "/" + cellId + "/"
+ encode(ts);
String response = sendRequest(requestUrl);
JSONObject responseObject = new JSONObject(response);
private static String sendRequest(String url) throws ConfigDbNotFoundException {
ResponseEntity<String> response = SonHandlerRestTemplate.sendGetRequest(url,
new ParameterizedTypeReference<String>() {});
- if (response.equals(null)) {
+ if (response == null) {
throw new ConfigDbNotFoundException("Cannot reach Config DB");
}
return response.getBody();
public class AppConfig {
+
/**
* Rest Template bean.
*/
private static ByteArrayHttpMessageConverter generateByteArrayHttpMessageConverter() {
ByteArrayHttpMessageConverter byteArrayHttpMessageConverter = new ByteArrayHttpMessageConverter();
- List<MediaType> supportedApplicationTypes = new ArrayList<MediaType>();
+ List<MediaType> supportedApplicationTypes = new ArrayList<>();
supportedApplicationTypes.add(new MediaType("application", "pdf"));
byteArrayHttpMessageConverter.setSupportedMediaTypes(supportedApplicationTypes);
return byteArrayHttpMessageConverter;
package org.onap.dcaegen2.services.sonhms.utils;
-import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Service;
private static ApplicationContext context;
@Override
- public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+ public void setApplicationContext(ApplicationContext applicationContext) {
context = applicationContext;
}
package org.onap.dcaegen2.services.sonhms.utils;
+import fj.data.Either;
+
+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 org.onap.dcaegen2.services.sonhms.ClusterDetailsComponent;
import org.onap.dcaegen2.services.sonhms.NotificationToClusterMapping;
import org.onap.dcaegen2.services.sonhms.child.Graph;
import org.onap.dcaegen2.services.sonhms.model.LteNeighborListInUseLteCell;
import org.onap.dcaegen2.services.sonhms.model.Notification;
import org.onap.dcaegen2.services.sonhms.restclient.SdnrRestClient;
-
-import fj.data.Either;
-
-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 org.slf4j.Logger;
import org.slf4j.LoggerFactory;
--- /dev/null
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.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;
+import com.att.nsa.cambria.client.CambriaClientBuilders.ConsumerBuilder;
+import com.att.nsa.cambria.client.CambriaClientBuilders.PublisherBuilder;
+import com.att.nsa.cambria.client.CambriaClientBuilders.TopicManagerBuilder;
+import com.att.nsa.cambria.client.CambriaConsumer;
+import com.att.nsa.cambria.client.CambriaTopicManager;
+
+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();
+ }
+
+}
}
}
- /**
- * Send Post Request1.
- */
-
- public static <T> ResponseEntity<T> sendPostRequest1(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(AUTH, "Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA==");
- 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 Post Request to oof.
*/
package org.onap.dcaegen2.services.sonhms.utils;
-import org.onap.dcaegen2.services.sonhms.EventHandler;
-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.ThreadId;
-
import java.util.List;
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.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.ThreadId;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
#
###############################################################################
-spring.datasource.url= jdbc:postgresql://pcims-db:5432/sonh_ms
-spring.datasource.username=postgres
+spring.datasource.initialization-mode=always
-spring.datasource.password=password
+spring.datasource.initialize=true
+
+spring.datasource.schema=classpath:/schema.sql
+
+spring.datasource.continue-on-error=true
spring.jpa.hibernate.ddl-auto=validate
<sift>
<appender name="file-${logFileName}" class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>/var/log/onap/pci-handler/${logFileName}.log</file>
+ <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>
-CREATE DATABASE sonh_ms;
-\c sonh_ms
CREATE TABLE DMAAP_NOTIFICATIONS(
notification TEXT PRIMARY KEY NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
transaction_id TEXT PRIMARY KEY,
child_thread_id BIGINT UNIQUE NOT NULL
);
-
+CREATE TABLE FAULT_NOTIFICATIONS(
+ notification TEXT PRIMARY KEY NOT NULL,
+ created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
+);
+
import java.util.ArrayList;
import java.util.List;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.ArrayList;
import java.util.List;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.Map;
import org.junit.Test;
-import org.onap.dcaegen2.services.sonhms.ConfigPolicy;
public class ConfigPolicyTest {
import java.util.List;
import org.junit.Test;
-import org.onap.dcaegen2.services.sonhms.Configuration;
public class ConfigurationTest {
public void configurationTest() {
configuration.setBufferTime(60);
configuration.setCallbackUrl("/callbackUrl");
- configuration.setConfigName("configName");
List<String> list = new ArrayList<String>();
list.add("server");
- configuration.setServers(list);
+ configuration.setDmaapServers(list);
configuration.setCg("cg");
configuration.setCid("cid");
- configuration.setManagerApiKey("managerApiKey");
- configuration.setManagerSecretKey("managerSecretKey");
+
configuration.setMaximumClusters(5);
configuration.setMinCollision(5);
configuration.setMinConfusion(5);
configuration.setNumSolutions(1);
configuration.setOofService("oofService");
configuration.setOptimizers(list);
- configuration.setPcimsApiKey("pcimsApiKey");
- configuration.setPcimsSecretKey("pcimsSecretKey");
- configuration.setPolicyName("policyName");
- configuration.setPolicyService("policyService");
- configuration.setPolicyTopic("policyTopic");
configuration.setPollingInterval(30);
configuration.setPollingTimeout(100);
- configuration.setSdnrService("sdnrService");
- configuration.setSdnrTopic("sdnrTopic");
+ configuration.setConfigDbService("sdnrService");
configuration.setSourceId("sourceId");
assertEquals(60, configuration.getBufferTime());
assertEquals("/callbackUrl", configuration.getCallbackUrl());
assertEquals("cg", configuration.getCg());
assertEquals("cid", configuration.getCid());
- assertEquals("managerApiKey", configuration.getManagerApiKey());
- assertEquals("managerSecretKey", configuration.getManagerSecretKey());
+
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("pcimsApiKey", configuration.getPcimsApiKey());
- assertEquals("pcimsSecretKey", configuration.getPcimsSecretKey());
- assertEquals("policyName", configuration.getPolicyName());
- assertEquals("policyService", configuration.getPolicyService());
- assertEquals("policyTopic", configuration.getPolicyTopic());
+
assertEquals(30, configuration.getPollingInterval());
assertEquals(100, configuration.getPollingTimeout());
- assertEquals("sdnrService", configuration.getSdnrService());
- assertEquals("sdnrTopic", configuration.getSdnrTopic());
- assertEquals(list, configuration.getServers());
+ assertEquals("sdnrService", configuration.getConfigDbService());
+ assertEquals(list, configuration.getDmaapServers());
assertEquals("sourceId", configuration.getSourceId());
}
}
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;
package org.onap.dcaegen2.services.sonhms;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import fj.data.Either;
+
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
+
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
-import org.springframework.boot.test.context.SpringBootTest;
-import com.fasterxml.jackson.databind.ObjectMapper;
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.utils.ClusterUtils;
import org.onap.dcaegen2.services.sonhms.utils.ClusterUtilsTest;
import org.onap.dcaegen2.services.sonhms.utils.ThreadUtils;
-
-import fj.data.Either;
+import org.springframework.boot.test.context.SpringBootTest;
@RunWith(MockitoJUnitRunner.class)
@SpringBootTest(classes = EventHandler.class)
import java.util.Map;
import org.junit.Test;
-import org.onap.dcaegen2.services.sonhms.child.Graph;
import org.onap.dcaegen2.services.sonhms.model.CellPciPair;
import org.slf4j.Logger;
package org.onap.dcaegen2.services.sonhms.child;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
import org.onap.dcaegen2.services.sonhms.ConfigPolicy;
import org.onap.dcaegen2.services.sonhms.model.CellPciPair;
import org.onap.dcaegen2.services.sonhms.model.PolicyNotification;
import java.util.Map;
import org.junit.Test;
-import org.onap.dcaegen2.services.sonhms.child.Detection;
-import org.onap.dcaegen2.services.sonhms.child.Graph;
import org.onap.dcaegen2.services.sonhms.model.CellPciPair;
import static org.junit.Assert.assertEquals;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
-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.slf4j.Logger;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
-
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.ObjectMapper;
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.restclient.Solution;
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.slf4j.Logger;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
@RunWith(PowerMockRunner.class)
@PowerMockRunnerDelegate(SpringRunner.class)
package org.onap.dcaegen2.services.sonhms.dmaap;
-import com.att.nsa.cambria.client.CambriaTopicManager;
-
import static org.mockito.Mockito.when;
+import com.att.nsa.cambria.client.CambriaTopicManager;
import java.io.IOException;
import java.util.ArrayList;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
-
-import org.onap.dcaegen2.services.sonhms.Configuration;
-import org.onap.dcaegen2.services.sonhms.NewNotification;
import org.mockito.MockitoAnnotations;
+import org.onap.dcaegen2.services.sonhms.Configuration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
MockitoAnnotations.initMocks(this);
}
- private Boolean newNotif;
-
@Test
public void getAllTopicsTest() {
Set<String> topics = new HashSet<String>();
Configuration configuration = Configuration.getInstance();
configuration.setBufferTime(60);
configuration.setCallbackUrl("/callbackUrl");
- configuration.setConfigName("configName");
List<String> list = new ArrayList<String>();
list.add("server");
- configuration.setServers(list);
+ configuration.setDmaapServers(list);
configuration.setCg("cg");
configuration.setCid("cid");
- configuration.setManagerApiKey("managerApiKey");
- configuration.setManagerSecretKey("managerSecretKey");
configuration.setMaximumClusters(5);
configuration.setMinCollision(5);
configuration.setMinConfusion(5);
configuration.setNumSolutions(1);
configuration.setOofService("oofService");
configuration.setOptimizers(list);
- configuration.setPcimsApiKey("pcimsApiKey");
- configuration.setPcimsSecretKey("pcimsSecretKey");
- configuration.setPolicyName("policyName");
- configuration.setPolicyService("policyService");
- configuration.setPolicyTopic("policyTopic");
configuration.setPollingInterval(30);
configuration.setPollingTimeout(100);
- configuration.setSdnrService("sdnrService");
- configuration.setSdnrTopic("sdnrTopic");
+ configuration.setConfigDbService("sdnrService");
configuration.setSourceId("sourceId");
- NewNotification newNotification = new NewNotification(newNotif);
try {
when(topicManager.getTopics()).thenReturn(topics);
client=Mockito.mock(DmaapClient.class);
- client.initClient(newNotification);
- Mockito.verify(client).initClient(newNotification);
+ client.initClient();
+ Mockito.verify(client).initClient();
// Mockito.verifycreateAndConfigureTopics();
} catch (IOException e) {
import static org.mockito.Mockito.when;
import com.att.nsa.cambria.client.CambriaBatchingPublisher;
+
import java.io.IOException;
-import java.security.GeneralSecurityException;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
@SpringBootTest(classes = NotificationProducerTest.class)
public class NotificationProducerTest {
-
@Mock
CambriaBatchingPublisher cambriaBatchingPublisher;
-
+
@InjectMocks
NotificationProducer notificationProducer;
-
+
@Test
public void notificationProducerTest() {
-
-
-
- try {
-
- when(cambriaBatchingPublisher.send(Mockito.anyString(), Mockito.anyString())).thenReturn(0);
- int result=notificationProducer.sendNotification("msg");
- assertEquals(0, result);
- } catch (GeneralSecurityException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
-
- }
-}
+ try {
+
+ when(cambriaBatchingPublisher.send(Mockito.anyString(), Mockito.anyString())).thenReturn(0);
+ int result = notificationProducer.sendNotification("msg");
+ assertEquals(0, result);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+}
*
*******************************************************************************/
-package org.onap.dcaegen2.services.sonhms;
+package org.onap.dcaegen2.services.sonhms.entity;
-public class MainThreadTest {
+import static org.junit.Assert.assertEquals;
+
+import java.sql.Timestamp;
+
+import org.junit.Test;
+
+public class FaultNotificationsTest {
+ private Timestamp createdAt;
+
+ @Test
+ public void faultNotififcationsTest() {
+ FaultNotifications faultNotifications = new FaultNotifications();
+ faultNotifications.setNotification("notification");
+ faultNotifications.setCreatedAt(createdAt);
+ assertEquals("notification", faultNotifications.getNotification());
+ assertEquals(createdAt, faultNotifications.getCreatedAt());
+ }
+
}
+
+
import java.util.ArrayList;
import org.junit.Test;
-import org.onap.dcaegen2.services.sonhms.model.FapServiceList;
-import org.onap.dcaegen2.services.sonhms.model.LteNeighborListInUseLteCell;
-import org.onap.dcaegen2.services.sonhms.model.NeighborListInUse;
-import org.onap.dcaegen2.services.sonhms.model.Notification;
-import org.onap.dcaegen2.services.sonhms.model.NotificationCellConfig;
-import org.onap.dcaegen2.services.sonhms.model.NotificationLte;
-import org.onap.dcaegen2.services.sonhms.model.NotificationPayload;
-import org.onap.dcaegen2.services.sonhms.model.NotificationRan;
-import org.onap.dcaegen2.services.sonhms.model.RadioAccess;
-import org.onap.dcaegen2.services.sonhms.model.X0005b9Lte;
public class NotificationTest {
import java.util.ArrayList;
import org.junit.Test;
-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.Lte;
-import org.onap.dcaegen2.services.sonhms.model.Payload;
-import org.onap.dcaegen2.services.sonhms.model.Ran;
-import org.onap.dcaegen2.services.sonhms.model.X0005b9Lte;
import static org.junit.Assert.assertEquals;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import org.junit.Assert;
import org.junit.Test;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
import org.onap.dcaegen2.services.sonhms.utils.ClusterUtilsTest;
public class PolicyNotificationTest {
}
Assert.assertEquals(policyNotification1.hashCode(), policyNotification2.hashCode());
+ Assert.assertEquals(policyNotification1, policyNotification2);
+ Assert.assertTrue(policyNotification1.equals(policyNotification2));
+ Assert.assertFalse(policyNotification1.equals(null));
Assert.assertNotEquals(policyNotification1.hashCode(), policyNotification3.hashCode());
}
import java.util.List;
import org.junit.Test;
-import org.onap.dcaegen2.services.sonhms.restclient.AsyncResponseBody;
-import org.onap.dcaegen2.services.sonhms.restclient.Solution;
-import org.onap.dcaegen2.services.sonhms.restclient.SonSolution;
import java.util.ArrayList;
import java.util.List;
+
import org.junit.Test;
-import org.onap.dcaegen2.services.sonhms.restclient.CellInfo;
public class CellInfoTest {
import java.util.ArrayList;
import java.util.List;
+
import org.junit.Test;
-import org.onap.dcaegen2.services.sonhms.restclient.CellInfo;
-import org.onap.dcaegen2.services.sonhms.restclient.OofRequestBody;
-import org.onap.dcaegen2.services.sonhms.restclient.RequestInfo;
import java.util.ArrayList;
import java.util.List;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
public void queryOofTest() {
configuration.setBufferTime(60);
configuration.setCallbackUrl("/callbackUrl");
- configuration.setConfigName("configName");
List<String> list = new ArrayList<String>();
list.add("server");
- configuration.setServers(list);
+ configuration.setDmaapServers(list);
configuration.setCg("cg");
configuration.setCid("cid");
- configuration.setManagerApiKey("managerApiKey");
- configuration.setManagerSecretKey("managerSecretKey");
configuration.setMaximumClusters(5);
configuration.setMinCollision(5);
configuration.setMinConfusion(5);
configuration.setNumSolutions(1);
configuration.setOofService("oofService");
configuration.setOptimizers(list);
- configuration.setPcimsApiKey("pcimsApiKey");
- configuration.setPcimsSecretKey("pcimsSecretKey");
- configuration.setPolicyName("policyName");
- configuration.setPolicyService("policyService");
- configuration.setPolicyTopic("policyTopic");
configuration.setPollingInterval(30);
configuration.setPollingTimeout(100);
- configuration.setSdnrService("sdnrService");
- configuration.setSdnrTopic("sdnrTopic");
+ configuration.setConfigDbService("sdnrService");
configuration.setSourceId("sourceId");
String responseBody="{\n" +
" \"transactionId\": \"xxx-xxx-xxxx\",\n" +
import static org.junit.Assert.assertEquals;
import org.junit.Test;
-import org.onap.dcaegen2.services.sonhms.restclient.SonSolution;
public class PciSolutionsTest {
import static org.junit.Assert.assertEquals;
import org.junit.Test;
-import org.onap.dcaegen2.services.sonhms.restclient.PolicyRequestBody;
public class PolicyRequestBodyTest {
+++ /dev/null
-/*******************************************************************************
- * ============LICENSE_START=======================================================
- * son-handler
- * ================================================================================
- * Copyright (C) 2019 Wipro Limited.
- * ==============================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- *
- *******************************************************************************/
-
-package org.onap.dcaegen2.services.sonhms.restclient;
-
-import static org.junit.Assert.assertEquals;
-import java.util.ArrayList;
-import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Matchers;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-import org.onap.dcaegen2.services.sonhms.Configuration;
-import org.onap.dcaegen2.services.sonhms.restclient.PolicyRestClient;
-import org.onap.dcaegen2.services.sonhms.utils.SonHandlerRestTemplate;
-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.core.ParameterizedTypeReference;
-import org.springframework.http.ResponseEntity;
-import org.springframework.test.context.junit4.SpringRunner;
-
-@RunWith(PowerMockRunner.class)
-@PowerMockRunnerDelegate(SpringRunner.class)
-@PrepareForTest({ SonHandlerRestTemplate.class, Configuration.class })
-@SpringBootTest(classes = PolicyRestClientTest.class)
-public class PolicyRestClientTest {
-
- Configuration configuration = Configuration.getInstance();
-
- @Before
- public void setup() {
- MockitoAnnotations.initMocks(this);
- }
-
- @Test
- public void fetchConfigFromPolicyTest() {
-
- configuration.setBufferTime(60);
- configuration.setCallbackUrl("/callbackUrl");
- configuration.setConfigName("configName");
- List<String> list = new ArrayList<String>();
- list.add("server");
- configuration.setServers(list);
- configuration.setCg("cg");
- configuration.setCid("cid");
- configuration.setManagerApiKey("managerApiKey");
- configuration.setManagerSecretKey("managerSecretKey");
- configuration.setMaximumClusters(5);
- configuration.setMinCollision(5);
- configuration.setMinConfusion(5);
- configuration.setNumSolutions(1);
- configuration.setOofService("oofService");
- configuration.setOptimizers(list);
- configuration.setPcimsApiKey("pcimsApiKey");
- configuration.setPcimsSecretKey("pcimsSecretKey");
- configuration.setPolicyName("policyName");
- configuration.setPolicyService("policyService");
- configuration.setPolicyTopic("policyTopic");
- configuration.setPollingInterval(30);
- configuration.setPollingTimeout(100);
- configuration.setSdnrService("sdnrService");
- configuration.setSdnrTopic("sdnrTopic");
- configuration.setSourceId("sourceId");
- String responseBody="{\n" +
- "\"policyName\": \"com.Config_PCIMS_CONFIG_POLICY\",\n" +
- "\"policyVersion\": \"1\",\n" +
- "\"configBody\": \"{ \\\"PCI_NEIGHBOR_CHANGE_CLUSTER_TIMEOUT_IN_SECS\\\":60,\n" +
- "\\\"PCI_MODCONFIG_POLICY_NAME\\\":\\\"ControlLoop-vPCI-fb41f388-a5f2-11e8-98d0-\n" +
- "529269fb1459\\\", \\\"PCI_OPTMIZATION_ALGO_CATEGORY_IN_OOF\\\":\\\"OOF-PCI-\n" +
- "OPTIMIZATION\\\", \\\"PCI_SDNR_TARGET_NAME\\\":\\\"SDNR\\\" }\",\n" +
- "\"policyClass\": \"Config\",\n" +
- "\"policyConfigType\": \"Base\",\n" +
- "\"ttlDate\": \"2018-08-29T06:28:16.830Z\",\n" +
- "\"onapName\": \"DCAE\",\n" +
- "\"configName\": \"PCIMS_CONFIG_POLICY\",\n" +
- "\"configBodyType\": \"JSON\"\n" +
- "}\n" +
- "";
- PowerMockito.mockStatic(SonHandlerRestTemplate.class);
- PowerMockito.mockStatic(Configuration.class);
- PowerMockito.when(Configuration.getInstance()).thenReturn(configuration);
-
- PowerMockito.when(SonHandlerRestTemplate.sendPostToPolicy(Mockito.anyString(),Mockito.anyString() ,Matchers.<ParameterizedTypeReference<String>>any()))
- .thenReturn(ResponseEntity.ok(responseBody));
- String result=PolicyRestClient.fetchConfigFromPolicy();
- assertEquals(ResponseEntity.ok(responseBody).getBody(), result);
-
-
-
-
-
- }
-
-}
import java.util.List;
import org.junit.Test;
-import org.onap.dcaegen2.services.sonhms.restclient.RequestInfo;
public class RequestInfoTest {
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.modules.junit4.PowerMockRunnerDelegate;
+import org.slf4j.Logger;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.junit4.SpringRunner;
-import org.slf4j.Logger;
@RunWith(PowerMockRunner.class)
@PowerMockRunnerDelegate(SpringRunner.class)
import java.util.ArrayList;
import java.util.List;
+
import org.junit.Test;
-import org.onap.dcaegen2.services.sonhms.restclient.Solution;
-import org.onap.dcaegen2.services.sonhms.restclient.SonSolution;
package org.onap.dcaegen2.services.sonhms.utils;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import fj.data.Either;
+
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import java.util.UUID;
-import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-import fj.data.Either;
-
@RunWith(PowerMockRunner.class)
@PowerMockRunnerDelegate(SpringRunner.class)
@PrepareForTest({ SdnrRestClient.class, BeanUtil.class })