aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrishna <krishna.moorthy6@wipro.com>2020-02-08 14:11:41 +0530
committerkrishna <krishna.moorthy6@wipro.com>2020-02-12 11:59:24 +0530
commitcee68e2e64d35019b7b66570062bd6e8e7981dc5 (patch)
tree3fc3b5301caec66cf2f5787b1a204a552e78e2d1
parente05d755dfb068c5d88a0b6d5cf44b3db60afe573 (diff)
Update microservice to run as standalone MS
Issue-ID: DCAEGEN2-2066 Signed-off-by: krishna <krishna.moorthy6@wipro.com> Change-Id: I3305d6df039ba2c3a9283bf6cd4c50ca073d12c8
-rw-r--r--.gitignore4
-rw-r--r--README.md11
-rw-r--r--dpo/blueprints/k8s-sonhms-inputs.yaml70
-rw-r--r--dpo/blueprints/k8s-sonhms.yaml305
-rwxr-xr-xsrc/main/docker/config/dmaap/MsgRtrApi.properties171
-rw-r--r--src/main/docker/config/sonhms/config_all.json131
-rw-r--r--src/main/docker/docker-compose.yaml91
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/Application.java71
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java92
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/controller/ConfigFetchFromCbs.java100
10 files changed, 559 insertions, 487 deletions
diff --git a/.gitignore b/.gitignore
index 14ef475..2ed32a8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,7 @@ target/
*.jar
/bin/
.checkstyle
+
+#intellij files
+.idea
+son-handler.iml
diff --git a/README.md b/README.md
index 721274c..9db9705 100644
--- a/README.md
+++ b/README.md
@@ -7,6 +7,7 @@ This project is organized as a mvn project and has "org.onap.dcaegen2" as parent
```
git clone https://gerrit.onap.org/r/dcaegen2/services/son-handler
mvn clean install
+mvn clean install docker:build
```
@@ -44,3 +45,13 @@ To uninstall:
cfy blueprints delete sonhms
+### Standalone deployment
+son handler can be deployed standalone using docker-compose.
+
+Navigate to src/main/docker directory. docker-compose.yaml can be found there.
+
+To install :
+ docker-compose up
+
+To uninstall :
+ docker-compose down \ No newline at end of file
diff --git a/dpo/blueprints/k8s-sonhms-inputs.yaml b/dpo/blueprints/k8s-sonhms-inputs.yaml
deleted file mode 100644
index 4dd46f9..0000000
--- a/dpo/blueprints/k8s-sonhms-inputs.yaml
+++ /dev/null
@@ -1,70 +0,0 @@
-# ============LICENSE_START=======================================================
-# son-handler
-# ================================================================================
-# Copyright (C) 2019 Wipro Limited.
-# ==============================================================================
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-# ============LICENSE_END=========================================================
-
-pgaas_cluster_name: dcae-pg-primary.onap
-database_name: sonhms
-tag_version: nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.son-handler:1.1.1
-replicas: 1
-aaf_username:
-aaf_password:
-polling_interval: 20
-polling_timeout: 60
-cbs_polling_interval: 60
-num_solutions: 5
-min_collision: 5
-min_confusion: 5
-max_clusters: 5
-bad_threshold: 50
-poor_threshold: 70
-namespace: onap
-dmaap: message-router.onap
-buffer_time: 60
-cg: sonhms-cg
-cid: sonhms-cid
-config_db: http://sdnc.onap:8181
-oof: http://oof-osdf.onap:8699
-oof_endpoint: /api/oof/v1/pci
-pci_optimizer: pci
-pci_anr_optimizer: pci_anr
-log_path: /dockerdata-nfs/son-handler
-poorCountThreshold: 3
-badCountThreshold: 3
-oofTriggerCountTimer: 30
-oofTriggerCountThreshold: 5
-policyRespTimer: 10
-policy_id: com.Config_PCIMS_CONFIG_POLICY.1.xml
-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
-topic04_location: onap
-topic04_client_role: son-subscriber
-topic04_client_id: sdnr-son-1
-topic04_url: https://message-router.onap.svc.cluster.local:3905/events/DCAE_CL_RSP
diff --git a/dpo/blueprints/k8s-sonhms.yaml b/dpo/blueprints/k8s-sonhms.yaml
deleted file mode 100644
index aefe959..0000000
--- a/dpo/blueprints/k8s-sonhms.yaml
+++ /dev/null
@@ -1,305 +0,0 @@
- #============LICENSE_START=======================================================
- # son-handler
- # ================================================================================
- # Copyright (C) 2019 Wipro Limited.
- # ==============================================================================
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- # ============LICENSE_END=========================================================
-
-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
- - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/dcaepolicyplugin/2.3.0/dcaepolicyplugin_types.yaml
-inputs:
- replicas:
- type: integer
- description: 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:1.1.0"
- 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
- cbs_polling_interval:
- type: integer
- description: cbs polling interval
- default: 60
- 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
- bad_threshold:
- type: integer
- description: threshold for bad neighbors
- default: 50
- poor_threshold:
- type: integer
- description: threshold for poor neighbors
- default: 70
- namespace:
- type: string
- description: namespace
- default: onap
- 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
- oof_endpoint:
- type: string
- description: oof endpoint
- default: /api/oof/v1/pci
- pci_optimizer:
- type: string
- description: pci optimizer name in oof
- default: pci
- pci_anr_optimizer:
- type: string
- description: pci and anr optimizer name in oof
- default: pci_anr
- log_path:
- type: string
- description: log location in host
- default: /dockerdata-nfs/son-handler
- poorCountThreshold:
- type: integer
- description: poor neighbor count threshold
- default: 3
- badCountThreshold:
- type: integer
- description: bad neighbor count threshold
- default: 3
- oofTriggerCountTimer:
- type: integer
- description: timer for oof triggered count in minutes
- default: 30
- oofTriggerCountThreshold:
- type: integer
- description: Threshold for oof trigger count
- default: 5
- policyRespTimer:
- type: integer
- description: policy response wait timer in seconds
- default: 10
- policy_id:
- type: string
- description: policy id for config policy
- topic00_location:
- topic01_location:
- topic02_location:
- topic03_location:
- topic04_location:
- topic00_client_role:
- topic01_client_role:
- topic02_client_role:
- topic03_client_role:
- topic04_client_role:
- topic00_client_id:
- topic01_client_id:
- topic02_client_id:
- topic03_client_id:
- topic04_client_id:
- topic00_url:
- topic01_url:
- topic02_url:
- topic03_url:
- topic04_url:
-
-
-node_templates:
- pgaasvm:
- 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: /home/sonhms/logs
- 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
- dcae_cl_response_topic:
- aaf_username: { get_input: aaf_username }
- aaf_password: { get_input: aaf_password }
- dmaap_info:
- location: { get_input: topic04_location }
- client_role: { get_input: topic04_client_role }
- client_id: { get_input: topic04_client_id }
- topic_url: { get_input: topic04_url }
- type: message-router
- streams_publishes:
- CL_topic:
- aaf_username: { get_input: aaf_username }
- 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 }
- cbsPollingInterval: { get_input: cbs_polling_interval }
- 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.badThreshold: { get_input: bad_threshold }
- sonhandler.poorThreshold: { get_input: poor_threshold }
- sonhandler.namespace: { get_input: namespace }
- sonhandler.sourceId: SONHMS
- sonhandler.dmaap.server:
- - { get_input: dmaap }
- 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.oof.endpoint: { get_input: oof_endpoint }
- sonhandler.pciOptimizer: { get_input: pci_optimizer }
- sonhandler.pciAnrOptimizer: { get_input: pci_anr_optimizer }
- sonhandler.poorCountThreshold: { get_input: poorCountThreshold}
- sonhandler.badCountThreshold: { get_input: badCountThreshold}
- sonhandler.oofTriggerCountTimer: { get_input: oofTriggerCountTimer}
- sonhandler.oofTriggerCountThreshold: { get_input: oofTriggerCountThreshold}
- sonhandler.policyRespTimer: { get_input: policyRespTimer}
- service_calls:
- sdnr-getpnfname: []
- sdnr-getpci: []
- sdnr-getnbrlist: []
- sdnr-getcelllist: []
- oof-req: []
- policy-req: []
- relationships:
- - type: cloudify.relationships.depends_on
- target: pgaasvm
- - type: cloudify.relationships.depends_on
- target: son_policy
-
- son_policy:
- type: dcae.nodes.policy
- properties:
- policy_id:
- get_input: policy_id
-
-
-
-
diff --git a/src/main/docker/config/dmaap/MsgRtrApi.properties b/src/main/docker/config/dmaap/MsgRtrApi.properties
new file mode 100755
index 0000000..61f3f03
--- /dev/null
+++ b/src/main/docker/config/dmaap/MsgRtrApi.properties
@@ -0,0 +1,171 @@
+# LICENSE_START=======================================================
+# org.onap.dmaap
+# ================================================================================
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# Copyright (C) 2020 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=========================================================
+#
+# ECOMP is a trademark and service mark of AT&T Intellectual Property.
+#
+###############################################################################
+###############################################################################
+##
+## Cambria API Server config
+##
+## - Default values are shown as commented settings.
+##
+
+###############################################################################
+##
+## HTTP service
+##
+## - 3904 is standard as of 7/29/14.
+#
+## Zookeeper Connection
+##
+## Both Cambria and Kafka make use of Zookeeper.
+##
+#config.zk.servers=172.18.1.1
+config.zk.servers=zookeeper:2181
+#config.zk.root=/fe3c/cambria/config
+
+
+###############################################################################
+##
+## Kafka Connection
+##
+## Items below are passed through to Kafka's producer and consumer
+## configurations (after removing "kafka.")
+## if you want to change request.required.acks it can take this one value
+#kafka.metadata.broker.list=localhost:9092,localhost:9093
+kafka.metadata.broker.list=kafka:9092
+##kafka.request.required.acks=-1
+#kafka.client.zookeeper=${config.zk.servers}
+consumer.timeout.ms=100
+zookeeper.connection.timeout.ms=6000
+zookeeper.session.timeout.ms=20000
+zookeeper.sync.time.ms=2000
+auto.commit.interval.ms=1000
+fetch.message.max.bytes =1000000
+auto.commit.enable=false
+
+#(backoff*retries > zksessiontimeout)
+kafka.rebalance.backoff.ms=10000
+kafka.rebalance.max.retries=6
+
+
+###############################################################################
+##
+## Secured Config
+##
+## Some data stored in the config system is sensitive -- API keys and secrets,
+## for example. to protect it, we use an encryption layer for this section
+## of the config.
+##
+## The key is a base64 encode AES key. This must be created/configured for
+## each installation.
+#cambria.secureConfig.key=
+##
+## The initialization vector is a 16 byte value specific to the secured store.
+## This must be created/configured for each installation.
+#cambria.secureConfig.iv=
+
+## Southfield Sandbox
+cambria.secureConfig.key=b/7ouTn9FfEw2PQwL0ov/Q==
+cambria.secureConfig.iv=wR9xP5k5vbz/xD0LmtqQLw==
+authentication.adminSecret=fe3cCompound
+#cambria.secureConfig.key[pc569h]=YT3XPyxEmKCTLI2NK+Sjbw==
+#cambria.secureConfig.iv[pc569h]=rMm2jhR3yVnU+u2V9Ugu3Q==
+
+
+###############################################################################
+##
+## Consumer Caching
+##
+## Kafka expects live connections from the consumer to the broker, which
+## obviously doesn't work over connectionless HTTP requests. The Cambria
+## server proxies HTTP requests into Kafka consumer sessions that are kept
+## around for later re-use. Not doing so is costly for setup per request,
+## which would substantially impact a high volume consumer's performance.
+##
+## This complicates Cambria server failover, because we often need server
+## A to close its connection before server B brings up the replacement.
+##
+
+## The consumer cache is normally enabled.
+#cambria.consumer.cache.enabled=true
+
+## Cached consumers are cleaned up after a period of disuse. The server inspects
+## consumers every sweepFreqSeconds and will clean up any connections that are
+## dormant for touchFreqMs.
+#cambria.consumer.cache.sweepFreqSeconds=15
+cambria.consumer.cache.touchFreqMs=120000
+##stickforallconsumerrequests=false
+## The cache is managed through ZK. The default value for the ZK connection
+## string is the same as config.zk.servers.
+#cambria.consumer.cache.zkConnect=${config.zk.servers}
+
+##
+## Shared cache information is associated with this node's name. The default
+## name is the hostname plus the HTTP service port this host runs on. (The
+## hostname is determined via InetAddress.getLocalHost ().getCanonicalHostName(),
+## which is not always adequate.) You can set this value explicitly here.
+##
+#cambria.api.node.identifier=<use-something-unique-to-this-instance>
+
+#cambria.rateLimit.maxEmptyPollsPerMinute=30
+#cambria.rateLimitActual.delay.ms=10
+
+###############################################################################
+##
+## Metrics Reporting
+##
+## This server can report its metrics periodically on a topic.
+##
+#metrics.send.cambria.enabled=true
+#metrics.send.cambria.topic=cambria.apinode.metrics #msgrtr.apinode.metrics.dmaap
+#metrics.send.cambria.sendEverySeconds=60
+
+cambria.consumer.cache.zkBasePath=/fe3c/cambria/consumerCache
+consumer.timeout=17
+default.partitions=3
+default.replicas=3
+##############################################################################
+#100mb
+maxcontentlength=10000
+
+
+##############################################################################
+#AAF Properties
+msgRtr.namespace.aaf=org.onap.dmaap.mr.topic
+msgRtr.topicfactory.aaf=org.onap.dmaap.mr.topicFactory|:org.onap.dmaap.mr.topic:
+enforced.topic.name.AAF=org.onap
+forceAAF=false
+transidUEBtopicreqd=false
+defaultNSforUEB=org.onap.dmaap.mr
+##############################################################################
+#Mirror Maker Agent
+msgRtr.mirrormakeradmin.aaf=com.onap.dmaap.mr.dev.mirrormaker|*|admin
+msgRtr.mirrormakeruser.aaf=com.onap.dmaap.mr.dev.mirrormaker|*|user
+msgRtr.mirrormakeruser.aaf.create=com.onap.dmaap.mr.dev.topicFactory|:com.onap.dmaap.mr.dev.topic:
+msgRtr.mirrormaker.timeout=15000
+msgRtr.mirrormaker.topic=com.onap.dmaap.mr.prod.mm.agent
+msgRtr.mirrormaker.consumergroup=mmagentserver
+msgRtr.mirrormaker.consumerid=1
+
+kafka.max.poll.interval.ms=300000
+kafka.heartbeat.interval.ms=60000
+kafka.session.timeout.ms=240000
+kafka.max.poll.records=1000
+
diff --git a/src/main/docker/config/sonhms/config_all.json b/src/main/docker/config/sonhms/config_all.json
new file mode 100644
index 0000000..cbb2384
--- /dev/null
+++ b/src/main/docker/config/sonhms/config_all.json
@@ -0,0 +1,131 @@
+{
+ "config": {
+ "sonhandler.badCountThreshold": 3,
+ "streams_subscribes": {
+ "performance_management_topic": {
+ "aaf_password": null,
+ "type": "message-router",
+ "dmaap_info": {
+ "topic_url": "https://message-router.onap.svc.cluster.local:3905/events/unauthenticated.VES_MEASUREMENT_OUTPUT",
+ "client_role": "son-subscriber",
+ "location": "onap",
+ "client_id": "sdnr-son-1"
+ },
+ "aaf_username": null
+ },
+ "fault_management_topic": {
+ "aaf_password": null,
+ "type": "message-router",
+ "dmaap_info": {
+ "topic_url": "https://message-router.onap.svc.cluster.local:3905/events/unauthenticated.SEC_FAULT_OUTPUT",
+ "client_role": "son-subscriber",
+ "location": "onap",
+ "client_id": "sdnr-son-1"
+ },
+ "aaf_username": null
+ },
+ "nbr_list_change_topic": {
+ "aaf_password": null,
+ "type": "message-router",
+ "dmaap_info": {
+ "topic_url": "https://message-router.onap.svc.cluster.local:3905/events/PCI-NOTIF-TOPIC-NGHBR-LIST-CHANGE-INFO",
+ "client_role": "son-subscriber",
+ "location": "onap",
+ "client_id": "sdnr-son-1"
+ },
+ "aaf_username": null
+ },
+ "dcae_cl_response_topic": {
+ "aaf_password": null,
+ "type": "message-router",
+ "dmaap_info": {
+ "topic_url": "https://message-router.onap.svc.cluster.local:3905/events/DCAE_CL_RSP",
+ "client_role": "son-subscriber",
+ "location": "onap",
+ "client_id": "sdnr-son-1"
+ },
+ "aaf_username": null
+ }
+ },
+ "postgres.port": "5432",
+ "sonhandler.pciOptimizer": "pci",
+ "sonhandler.maximumClusters": 5,
+ "sonhandler.numSolutions": 5,
+ "sonhandler.poorCountThreshold": 3,
+ "sonhandler.minCollision": 5,
+ "streams_publishes": {
+ "CL_topic": {
+ "aaf_password": null,
+ "type": "message-router",
+ "dmaap_info": {
+ "topic_url": "https://message-router.onap.svc.cluster.local:3905/events/unauthenticated.DCAE_CL_OUTPUT",
+ "client_role": "son-subscriber",
+ "location": "onap",
+ "client_id": "sdnr-son-1"
+ },
+ "aaf_username": null
+ }
+ },
+ "sonhandler.namespace": "onap",
+ "sonhandler.oof.endpoint": "/api/oof/v1/pci",
+ "postgres.password": "postgres",
+ "sonhandler.minConfusion": 5,
+ "sonhandler.sourceId": "SONHMS",
+ "postgres.username": "sonhms_admin",
+ "postgres.host": "postgres",
+ "sonhandler.policyRespTimer": 10,
+ "sonhandler.dmaap.server": [
+ "dmaap"
+ ],
+ "sonhandler.poorThreshold": 70,
+ "sonhandler.oofTriggerCountTimer": 30,
+ "cbsPollingInterval": 60,
+ "sonhandler.cg": "sonhms-cg",
+ "sonhandler.pollingInterval": 20,
+ "sonhandler.badThreshold": 50,
+ "sonhandler.bufferTime": 60,
+ "sonhandler.cid": "sonhms-cid",
+ "sonhandler.configDb.service": "http://sdnc.onap:8181",
+ "sonhandler.oofTriggerCountThreshold": 5,
+ "sonhandler.oof.service": "http://oof-osdf.onap:8699",
+ "sonhandler.pciAnrOptimizer": "pci_anr",
+ "sonhandler.pollingTimeout": 60,
+ "service_calls": {
+ "sdnr-getpnfname": [],
+ "sdnr-getpci": [],
+ "sdnr-getnbrlist": [],
+ "sdnr-getcelllist": [],
+ "oof-req": [],
+ "policy-req": []
+ }
+ },
+ "policies": {
+ "event": {
+ "action": "gathered",
+ "timestamp": "2019-09-18T14:57:55.320Z",
+ "update_id": "dbb88da8-8df1-489d-b51d-8d5cbbfbcd99",
+ "policies_count": 1
+ },
+ "items": [
+ {
+ "policyName": "com.Config_PCIMS_CONFIG_POLICY.1.xml",
+ "name": "com.Config_PCIMS_CONFIG_POLICY",
+ "config": {
+ "PCI_SDNR_TARGET_NAME": "SDNR",
+ "PCI_OPTMIZATION_ALGO_CATEGORY_IN_OOF": "OOF-PCI-OPTIMIZATION",
+ "PCI_NEIGHBOR_CHANGE_CLUSTER_TIMEOUT_IN_SECS": 60,
+ "PCI_MODCONFIGANR_POLICY_NAME": "ControlLoop-vSONH-7d4baf04-8875-4d1f-946d-06b874048b61",
+ "PCI_MODCONFIG_POLICY_NAME": "ControlLoop-vPCI-fb41f388-a5f2-11e8-98d0-529269fb1459"
+ },
+ "type_version": "1.0.0",
+ "version": "1.0.0",
+ "policyVersion": "1",
+ "type": "onap.policies.monitoring.docker.sonhandler.app",
+ "metadata": {
+ "policy-id": "com.Config_PCIMS_CONFIG_POLICY",
+ "policy-version": "1"
+ }
+ }
+ ]
+ }
+} \ No newline at end of file
diff --git a/src/main/docker/docker-compose.yaml b/src/main/docker/docker-compose.yaml
new file mode 100644
index 0000000..49d516e
--- /dev/null
+++ b/src/main/docker/docker-compose.yaml
@@ -0,0 +1,91 @@
+# ============LICENSE_START=======================================================
+# son-handler
+# ================================================================================
+# Copyright (C) 2020 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=========================================================
+
+version: '2.4'
+networks:
+ sonhms-default:
+ driver: bridge
+ driver_opts:
+ com.docker.network.driver.mtu: 1400
+services:
+ zookeeper:
+ image: wurstmeister/zookeeper
+ ports:
+ - "2181:2181"
+ networks:
+ - sonhms-default
+ kafka:
+ image: wurstmeister/kafka
+ ports:
+ - "9092:9092"
+ environment:
+ KAFKA_ADVERTISED_HOST_NAME: "kafka"
+ KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'true'
+ KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181"
+ KAFKA_ADVERTISED_LISTENERS: "PLAINTEXT://kafka:9092"
+ volumes:
+ - /var/run/docker.sock:/var/run/docker.sock
+ depends_on:
+ - zookeeper
+ networks:
+ - sonhms-default
+ dmaap:
+ image: nexus3.onap.org:10001/onap/dmaap/dmaap-mr:1.1.8
+ ports:
+ - "3904:3904"
+ - "3905:3905"
+ volumes:
+ - ./config/dmaap/MsgRtrApi.properties:/appl/dmaapMR1/bundleconfig/etc/appprops/MsgRtrApi.properties
+ depends_on:
+ - zookeeper
+ - kafka
+ networks:
+ - sonhms-default
+ postgres:
+ image: 'postgres:12-alpine'
+ container_name: sonhms-postgres
+ hostname: postgres
+ environment:
+ - POSTGRES_USER=sonhms_admin
+ - POSTGRES_PASSWORD=postgres
+ - POSTGRES_DB=sonhms
+ ports:
+ - 5432
+ healthcheck:
+ test: ["CMD", "nc", "-z", "localhost", "5432"]
+ interval: 30s
+ timeout: 10s
+ retries: 5
+ networks:
+ - sonhms-default
+ sonhms:
+ image: "nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.son-handler:latest"
+ container_name: sonhms
+ hostname: sonhms
+ environment:
+ - STANDALONE=true
+ - CONFIG_FILE=/etc/config_all.json
+ ports:
+ - "8080:8080"
+ volumes:
+ - ./config/sonhms/config_all.json:/etc/config_all.json
+ depends_on:
+ - postgres
+ networks:
+ - sonhms-default
+
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/Application.java b/src/main/java/org/onap/dcaegen2/services/sonhms/Application.java
index 9919bed..3e65c8c 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/Application.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/Application.java
@@ -2,26 +2,34 @@
* ============LICENSE_START=======================================================
* son-handler
* ================================================================================
- * Copyright (C) 2019 Wipro Limited.
+ * Copyright (C) 2019-2020 Wipro Limited.
* ==============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
+ *
*******************************************************************************/
package org.onap.dcaegen2.services.sonhms;
+import com.google.gson.Gson;
+import com.google.gson.JsonObject;
+import com.google.gson.reflect.TypeToken;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.lang.reflect.Type;
import java.time.Duration;
+import java.util.Map;
import javax.sql.DataSource;
@@ -33,6 +41,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
+
@SpringBootApplication
public class Application {
@@ -42,6 +51,40 @@ public class Application {
* Main method where the pci context is initially set.
*/
public static void main(String[] args) {
+ getConfig();
+ log.info("Starting spring boot application");
+ SpringApplication.run(Application.class);
+
+ }
+
+ private static void getConfig() {
+
+ Boolean standalone = Boolean.parseBoolean(System.getenv("STANDALONE"));
+
+ if (standalone) {
+ log.info("Running in standalone mode");
+
+ String configFile = System.getenv("CONFIG_FILE");
+ String configAllJson = readFromFile(configFile);
+
+ JsonObject configAll = new Gson().fromJson(configAllJson, JsonObject.class);
+
+ JsonObject config = configAll.getAsJsonObject("config");
+
+ Configuration.getInstance().updateConfigurationFromJsonObject(config);
+
+ ConfigPolicy configPolicy = ConfigPolicy.getInstance();
+ Type mapType = new TypeToken<Map<String, Object>>() {
+ }.getType();
+ if (configAll.getAsJsonObject("policies") != null) {
+ JsonObject policyJson = configAll.getAsJsonObject("policies").getAsJsonArray("items").get(0)
+ .getAsJsonObject().getAsJsonObject("config");
+ Map<String, Object> policy = new Gson().fromJson(policyJson, mapType);
+ configPolicy.setConfig(policy);
+ log.info("Config policy {}", configPolicy);
+ }
+ return;
+ }
ConfigFetchFromCbs configFetchFromCbs = new ConfigFetchFromCbs(Duration.ofSeconds(60));
Thread configFetchThread = new Thread(configFetchFromCbs);
@@ -52,9 +95,6 @@ public class Application {
log.debug("InterruptedException : {}", e);
}
log.info("after 10s sleep");
- log.info("Starting spring boot application");
- SpringApplication.run(Application.class);
-
}
/**
@@ -70,4 +110,19 @@ public class Application {
.password(configuration.getPgPassword()).build();
}
-}
+ private static String readFromFile(String file) {
+ String content = "";
+ try (BufferedReader bufferedReader = new BufferedReader(new FileReader(file))) {
+ content = bufferedReader.readLine();
+ String temp;
+ while ((temp = bufferedReader.readLine()) != null) {
+ content = content.concat(temp);
+ }
+ content = content.trim();
+ } catch (Exception e) {
+ content = null;
+ }
+ return content;
+ }
+
+} \ No newline at end of file
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java b/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java
index faa1b4e..d3d9d39 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java
@@ -2,30 +2,42 @@
* ============LICENSE_START=======================================================
* son-handler
* ================================================================================
- * Copyright (C) 2019 Wipro Limited.
+ * Copyright (C) 2019-2020 Wipro Limited.
* ==============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
+ *
*******************************************************************************/
package org.onap.dcaegen2.services.sonhms;
+import com.google.gson.Gson;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
+import com.google.gson.reflect.TypeToken;
+
+import java.lang.reflect.Type;
import java.util.List;
import java.util.Map;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
public class Configuration {
+ private static Logger log = LoggerFactory.getLogger(Configuration.class);
+
private static Configuration instance = null;
private String pgHost;
private int pgPort;
@@ -59,8 +71,8 @@ public class Configuration {
private int oofTriggerCountTimer;
private int oofTriggerCountThreshold;
private int policyRespTimer;
-
-
+
+
public int getPoorCountThreshold() {
return poorCountThreshold;
}
@@ -122,7 +134,7 @@ public class Configuration {
*/
public boolean isSecured() {
return (aafUsername != null);
-
+
}
public String getAafUsername() {
@@ -355,7 +367,67 @@ public class Configuration {
+ oofTriggerCountTimer + ", oofTriggerCountThreshold=" + oofTriggerCountThreshold + ", policyRespTimer="
+ policyRespTimer + "]";
}
-
-
-}
+ /**
+ * updates application configuration.
+ */
+ public void updateConfigurationFromJsonObject(JsonObject jsonObject) {
+
+ log.info("Updating configuration from CBS");
+
+ Type mapType = new TypeToken<Map<String, Object>>() {
+ }.getType();
+
+ JsonObject subscribes = jsonObject.getAsJsonObject("streams_subscribes");
+ streamsSubscribes = new Gson().fromJson(subscribes, mapType);
+
+ JsonObject publishes = jsonObject.getAsJsonObject("streams_publishes");
+ streamsPublishes = new Gson().fromJson(publishes, mapType);
+
+ pgPort = jsonObject.get("postgres.port").getAsInt();
+ pollingInterval = jsonObject.get("sonhandler.pollingInterval").getAsInt();
+ pgPassword = jsonObject.get("postgres.password").getAsString();
+ numSolutions = jsonObject.get("sonhandler.numSolutions").getAsInt();
+ minConfusion = jsonObject.get("sonhandler.minConfusion").getAsInt();
+ maximumClusters = jsonObject.get("sonhandler.maximumClusters").getAsInt();
+ minCollision = jsonObject.get("sonhandler.minCollision").getAsInt();
+ sourceId = jsonObject.get("sonhandler.sourceId").getAsString();
+ pgUsername = jsonObject.get("postgres.username").getAsString();
+ pgHost = jsonObject.get("postgres.host").getAsString();
+
+ JsonArray servers = jsonObject.getAsJsonArray("sonhandler.dmaap.server");
+ Type listType = new TypeToken<List<String>>() {
+ }.getType();
+ dmaapServers = new Gson().fromJson(servers, listType);
+
+ cg = jsonObject.get("sonhandler.cg").getAsString();
+ bufferTime = jsonObject.get("sonhandler.bufferTime").getAsInt();
+ cid = jsonObject.get("sonhandler.cid").getAsString();
+ configDbService = jsonObject.get("sonhandler.configDb.service").getAsString();
+ String namespace = jsonObject.get("sonhandler.namespace").getAsString();
+ callbackUrl = "http://" + System.getenv("HOSTNAME") + "." + namespace + ":8080/callbackUrl";
+
+ pciOptimizer = jsonObject.get("sonhandler.pciOptimizer").getAsString();
+ pciAnrOptimizer = jsonObject.get("sonhandler.pciAnrOptimizer").getAsString();
+
+ oofService = jsonObject.get("sonhandler.oof.service").getAsString();
+ oofEndpoint = jsonObject.get("sonhandler.oof.endpoint").getAsString();
+ pollingTimeout = jsonObject.get("sonhandler.pollingTimeout").getAsInt();
+
+ badThreshold = jsonObject.get("sonhandler.badThreshold").getAsInt();
+ poorThreshold = jsonObject.get("sonhandler.poorThreshold").getAsInt();
+
+ poorCountThreshold = jsonObject.get("sonhandler.poorCountThreshold").getAsInt();
+ badCountThreshold = jsonObject.get("sonhandler.badCountThreshold").getAsInt();
+ oofTriggerCountTimer = jsonObject.get("sonhandler.oofTriggerCountTimer").getAsInt();
+ oofTriggerCountThreshold = jsonObject.get("sonhandler.oofTriggerCountThreshold").getAsInt();
+ policyRespTimer = jsonObject.get("sonhandler.policyRespTimer").getAsInt();
+
+
+ log.info("configuration from CBS {}", this);
+
+ }
+
+
+
+} \ No newline at end of file
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/controller/ConfigFetchFromCbs.java b/src/main/java/org/onap/dcaegen2/services/sonhms/controller/ConfigFetchFromCbs.java
index afa26d8..448ac27 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/controller/ConfigFetchFromCbs.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/controller/ConfigFetchFromCbs.java
@@ -2,33 +2,31 @@
* ============LICENSE_START=======================================================
* son-handler
* ================================================================================
- * Copyright (C) 2019 Wipro Limited.
+ * Copyright (C) 2019-2020 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 com.google.gson.Gson;
-import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
import java.time.Duration;
-import java.util.List;
import java.util.Map;
import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api.CbsClientFactory;
@@ -89,7 +87,7 @@ public class ConfigFetchFromCbs implements Runnable {
}
}
- updateConfigurationFromJsonObject(config);
+ Configuration.getInstance().updateConfigurationFromJsonObject(config);
Type mapType = new TypeToken<Map<String, Object>>() {
}.getType();
@@ -103,93 +101,7 @@ public class ConfigFetchFromCbs implements Runnable {
}, throwable -> log.warn("Ooops", throwable));
}
- private void updateConfigurationFromJsonObject(JsonObject jsonObject) {
-
- log.info("Updating configuration from CBS");
- Configuration configuration = Configuration.getInstance();
-
- Type mapType = new TypeToken<Map<String, Object>>() {
- }.getType();
-
- JsonObject subscribes = jsonObject.getAsJsonObject("streams_subscribes");
- Map<String, Object> streamsSubscribes = new Gson().fromJson(subscribes, mapType);
-
- JsonObject publishes = jsonObject.getAsJsonObject("streams_publishes");
- Map<String, Object> streamsPublishes = new Gson().fromJson(publishes, mapType);
-
- int pgPort = jsonObject.get("postgres.port").getAsInt();
- int pollingInterval = jsonObject.get("sonhandler.pollingInterval").getAsInt();
- String pgPassword = jsonObject.get("postgres.password").getAsString();
- int numSolutions = jsonObject.get("sonhandler.numSolutions").getAsInt();
- int minConfusion = jsonObject.get("sonhandler.minConfusion").getAsInt();
- int maximumClusters = jsonObject.get("sonhandler.maximumClusters").getAsInt();
- int minCollision = jsonObject.get("sonhandler.minCollision").getAsInt();
- String sourceId = jsonObject.get("sonhandler.sourceId").getAsString();
- String pgUsername = jsonObject.get("postgres.username").getAsString();
- String pgHost = jsonObject.get("postgres.host").getAsString();
-
- JsonArray servers = jsonObject.getAsJsonArray("sonhandler.dmaap.server");
- Type listType = new TypeToken<List<String>>() {
- }.getType();
- List<String> dmaapServers = new Gson().fromJson(servers, listType);
-
- String cg = jsonObject.get("sonhandler.cg").getAsString();
- int bufferTime = jsonObject.get("sonhandler.bufferTime").getAsInt();
- String cid = jsonObject.get("sonhandler.cid").getAsString();
- String configDbService = jsonObject.get("sonhandler.configDb.service").getAsString();
- String namespace = jsonObject.get("sonhandler.namespace").getAsString();
- String callbackUrl = "http://" + System.getenv("HOSTNAME") + "." + namespace + ":8080/callbackUrl";
-
- String pciOptimizer = jsonObject.get("sonhandler.pciOptimizer").getAsString();
- String pciAnrOptimizer = jsonObject.get("sonhandler.pciAnrOptimizer").getAsString();
-
- String oofService = jsonObject.get("sonhandler.oof.service").getAsString();
- String oofEndpoint = jsonObject.get("sonhandler.oof.endpoint").getAsString();
- int pollingTimeout = jsonObject.get("sonhandler.pollingTimeout").getAsInt();
-
- int badThreshold = jsonObject.get("sonhandler.badThreshold").getAsInt();
- int poorThreshold = jsonObject.get("sonhandler.poorThreshold").getAsInt();
-
- int poorCountThreshold = jsonObject.get("sonhandler.poorCountThreshold").getAsInt();
- int badCountThreshold = jsonObject.get("sonhandler.badCountThreshold").getAsInt();
- int oofTriggerCountTimer = jsonObject.get("sonhandler.oofTriggerCountTimer").getAsInt();
- int oofTriggerCountThreshold = jsonObject.get("sonhandler.oofTriggerCountThreshold").getAsInt();
- int policyRespTimer = jsonObject.get("sonhandler.policyRespTimer").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.setPciOptimizer(pciOptimizer);
- configuration.setPciAnrOptimizer(pciAnrOptimizer);
- configuration.setOofService(oofService);
- configuration.setOofEndpoint(oofEndpoint);
- configuration.setPollingTimeout(pollingTimeout);
- configuration.setBadThreshold(badThreshold);
- configuration.setPoorThreshold(poorThreshold);
- configuration.setPoorCountThreshold(poorCountThreshold);
- configuration.setBadCountThreshold(badCountThreshold);
- configuration.setOofTriggerCountTimer(oofTriggerCountTimer);
- configuration.setOofTriggerCountThreshold(oofTriggerCountThreshold);
- configuration.setPolicyRespTimer(policyRespTimer);
-
- log.info("configuration from CBS {}", configuration);
- }
@Override
public void run() {
@@ -208,4 +120,4 @@ public class ConfigFetchFromCbs implements Runnable {
}
}
-}
+} \ No newline at end of file