aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/docker/postgres_scripts/Dockerfile7
-rw-r--r--src/main/docker/postgres_scripts/init_db.sh23
-rw-r--r--src/main/docker/son-handler/Dockerfile17
-rw-r--r--src/main/docker/son-handler/config.json48
-rw-r--r--src/main/docker/son-handler/entrypoint.sh35
-rw-r--r--src/main/docker/son-handler/policy.crt27
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/Application.java110
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/BufferNotificationComponent.java5
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/ClusterDetailsComponent.java4
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java243
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/ConfigurationFetcher.java72
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/DmaapNotificationsComponent.java7
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/EventHandler.java23
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/MainThread.java7
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/MainThreadComponent.java9
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/NewNotification.java7
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/NotificationToClusterMapping.java4
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/SonController.java1
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/SonRequestsComponent.java1
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThread.java16
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.java6
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/child/ClusterFormation.java15
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/child/Detection.java3
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/child/Graph.java5
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/child/PnfUtils.java12
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/child/StateOof.java17
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/controller/ConfigFetchFromCbs.java109
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/controller/HealthCheck.java8
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/dao/BufferedNotificationsRepository.java3
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/dao/CellInfoRepository.java1
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/dao/ClusterDetailsRepository.java3
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/dao/DmaapNotificationsRepository.java1
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/dao/FaultNotificationsRepository.java43
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/dao/SonRequestsRepository.java1
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/DmaapClient.java255
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationConsumer.java2
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationProducer.java10
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyDmaapClient.java46
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/entity/FaultNotifications.java69
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/model/NeighborListInUse.java1
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/model/Payload.java1
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/model/PolicyNotification.java10
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/model/RadioAccess.java1
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/restclient/OofRestClient.java100
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/restclient/PolicyRestClient.java77
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/restclient/SdnrRestClient.java19
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/utils/AppConfig.java3
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/utils/BeanUtil.java3
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtils.java21
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/utils/DmaapUtils.java133
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/utils/SonHandlerRestTemplate.java19
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/utils/ThreadUtils.java11
-rw-r--r--src/main/resources/application.properties9
-rw-r--r--src/main/resources/logback.xml2
-rw-r--r--src/main/resources/schema.sql (renamed from src/main/docker/postgres_scripts/createdb.sql)8
55 files changed, 792 insertions, 901 deletions
diff --git a/src/main/docker/postgres_scripts/Dockerfile b/src/main/docker/postgres_scripts/Dockerfile
deleted file mode 100644
index 9ccb016..0000000
--- a/src/main/docker/postgres_scripts/Dockerfile
+++ /dev/null
@@ -1,7 +0,0 @@
-from busybox
-
-RUN mkdir /docker-entrypoint-initdb.d
-
-ADD createdb.sql /tmp
-
-
diff --git a/src/main/docker/postgres_scripts/init_db.sh b/src/main/docker/postgres_scripts/init_db.sh
deleted file mode 100644
index f01eea6..0000000
--- a/src/main/docker/postgres_scripts/init_db.sh
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/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=========================================================
-#
-#*******************************************************************************
-
-psql -U postgres -tc "SELECT 1 FROM pg_database WHERE datname = 'pci_ms'" | grep -q 1 || psql -U postgres -c "CREATE DATABASE pci_ms"
diff --git a/src/main/docker/son-handler/Dockerfile b/src/main/docker/son-handler/Dockerfile
deleted file mode 100644
index 6e50fb1..0000000
--- a/src/main/docker/son-handler/Dockerfile
+++ /dev/null
@@ -1,17 +0,0 @@
-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"]
diff --git a/src/main/docker/son-handler/config.json b/src/main/docker/son-handler/config.json
deleted file mode 100644
index 6cdf863..0000000
--- a/src/main/docker/son-handler/config.json
+++ /dev/null
@@ -1,48 +0,0 @@
-{
- "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"
-}
diff --git a/src/main/docker/son-handler/entrypoint.sh b/src/main/docker/son-handler/entrypoint.sh
deleted file mode 100644
index 36e3178..0000000
--- a/src/main/docker/son-handler/entrypoint.sh
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/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
-
diff --git a/src/main/docker/son-handler/policy.crt b/src/main/docker/son-handler/policy.crt
deleted file mode 100644
index e017bf4..0000000
--- a/src/main/docker/son-handler/policy.crt
+++ /dev/null
@@ -1,27 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIEkzCCA3ugAwIBAgIIaG5i2/yYcycwDQYJKoZIhvcNAQELBQAwRzELMAkGA1UE
-BhMCVVMxDTALBgNVBAoMBE9OQVAxDjAMBgNVBAsMBU9TQUFGMRkwFwYDVQQDDBBp
-bnRlcm1lZGlhdGVDQV85MB4XDTE4MTAxMTIyMDkwNVoXDTE5MDQxMTIyMDkwNVow
-bzEPMA0GA1UEAwwGcG9saWN5MQ8wDQYJKoZIhvcNAQkBFgAxHzAdBgNVBAsMFnBv
-bGljeUBwb2xpY3kub25hcC5vcmcxDjAMBgNVBAsMBU9TQUFGMQ0wCwYDVQQKDARP
-TkFQMQswCQYDVQQGEwJVUzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
-ALdwMkNAqr43X9eBdGV9xT+Gi2usZC8GdOvAuEJ0srqdLY1baSMrGDY6sN4o5o/X
-fD+wwoaTYtnrrESC13BEoXRo7vIuqxKnNjqkljHcgk09m8BaBB5zQQQULoeEEVIV
-7c9+agrE+Jg3BPsilyWnJco6zLPpjSuTlqEvCtUjk6aQ+dS8ItHN26c/W42AuyLn
-iofaWY2HZdhOZJg6UetyITOywQ5o3vl09tE+zPzk7cixsxVUJy2aunUuDcrFiyKf
-tSX3XBAxaspgVtnNrUheudwkWc5pdBFNYSJS8NSCc7yDuAz0AfrCS7Tcd4IZG7Lw
-zJjMoIj0fOsinFViPkiyAA8CAwEAAaOCAVkwggFVMAkGA1UdEwQCMAAwDgYDVR0P
-AQH/BAQDAgXgMCAGA1UdJQEB/wQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjBUBgNV
-HSMETTBLgBSB95lbELnIjN7zUl7qTmmgQz6s3aEwpC4wLDEOMAwGA1UECwwFT1NB
-QUYxDTALBgNVBAoMBE9OQVAxCzAJBgNVBAYTAlVTggEHMB0GA1UdDgQWBBTO1RjR
-xvjgraJ+1nZUENDKSngpITCBoAYDVR0RBIGYMIGVggZwb2xpY3mCBSoucGRwghwq
-LnBkcC5vbmFwLnN2Yy5jbHVzdGVyLmxvY2FsggZicm1zZ3eCC2JybXNndy5vbmFw
-ggZkcm9vbHOCC2Ryb29scy5vbmFwggNwYXCCCHBhcC5vbmFwggNwZHCCCHBkcC5v
-bmFwgh5wb2xpY3kuYXBpLnNpbXBsZWRlbW8ub25hcC5vcmcwDQYJKoZIhvcNAQEL
-BQADggEBAHuhhuTD5zcrBaPGU7NT9V82BwrCPfEH2UTxracU/P/3YRQ4yBcnnyX4
-FznNAHJOrNnwdz7kht0XLV2Td5iI+Gs0X5AVlQE2paSgiJRXPkwU7un5xk7a6cbN
-7lnx5RcAxVBi6Nf078cSPu0I+E344MUoYwKb4haBKTB2lN48W7HxzePdnWZiPhrR
-iTIKwUa1WvKPG9KpbOZDbukCfStPeMb2i0G3rk4T/Vr1cDRLyG8u1nnJEHeAoU+t
-SWAq9bKpspFW0rRd2m8jOcql9ja7OUSgU0Qt10xoUQrkogS3Y8P8ib0Nf/kuyTnJ
-aAchKp0OSx2z8HceBCQPEJsR5Cj1h2M=
------END CERTIFICATE-----
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 7eb9e62..22d58d9 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/Application.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/Application.java
@@ -21,33 +21,19 @@
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);
@@ -55,75 +41,35 @@ public class Application {
* 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();
}
+
}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/BufferNotificationComponent.java b/src/main/java/org/onap/dcaegen2/services/sonhms/BufferNotificationComponent.java
index 50dec11..d1297b4 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/BufferNotificationComponent.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/BufferNotificationComponent.java
@@ -21,10 +21,11 @@
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 {
@@ -45,7 +46,7 @@ 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);
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/ClusterDetailsComponent.java b/src/main/java/org/onap/dcaegen2/services/sonhms/ClusterDetailsComponent.java
index 8e4b357..81d76ef 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/ClusterDetailsComponent.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/ClusterDetailsComponent.java
@@ -21,12 +21,12 @@
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 {
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 a90a0b9..1126102 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java
@@ -22,64 +22,86 @@
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;
}
@@ -101,46 +123,6 @@ public class Configuration {
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;
}
@@ -189,22 +171,6 @@ public class Configuration {
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;
}
@@ -221,23 +187,7 @@ public class Configuration {
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;
}
@@ -269,41 +219,70 @@ public class Configuration {
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 + "]";
+ }
+
+
+
+
}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/ConfigurationFetcher.java b/src/main/java/org/onap/dcaegen2/services/sonhms/ConfigurationFetcher.java
deleted file mode 100644
index 4a55393..0000000
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/ConfigurationFetcher.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START=======================================================
- * son-handler
- * ================================================================================
- * Copyright (C) 2019 Wipro Limited.
- * ==============================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- *
- *******************************************************************************/
-
-package org.onap.dcaegen2.services.sonhms;
-
-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
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/DmaapNotificationsComponent.java b/src/main/java/org/onap/dcaegen2/services/sonhms/DmaapNotificationsComponent.java
index f28de63..f2c444c 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/DmaapNotificationsComponent.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/DmaapNotificationsComponent.java
@@ -22,13 +22,14 @@
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;
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/EventHandler.java b/src/main/java/org/onap/dcaegen2/services/sonhms/EventHandler.java
index 312ca60..df24aa8 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/EventHandler.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/EventHandler.java
@@ -22,16 +22,9 @@ package org.onap.dcaegen2.services.sonhms;
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;
@@ -41,6 +34,15 @@ import java.util.Map.Entry;
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;
@@ -82,11 +84,10 @@ public class EventHandler {
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);
}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/MainThread.java b/src/main/java/org/onap/dcaegen2/services/sonhms/MainThread.java
index 2026500..84775ad 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/MainThread.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/MainThread.java
@@ -21,10 +21,6 @@
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;
@@ -33,6 +29,9 @@ import java.util.concurrent.BlockingQueue;
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;
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/MainThreadComponent.java b/src/main/java/org/onap/dcaegen2/services/sonhms/MainThreadComponent.java
index f83541a..1b4ff26 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/MainThreadComponent.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/MainThreadComponent.java
@@ -21,8 +21,11 @@
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
@@ -30,12 +33,14 @@ public class MainThreadComponent {
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();
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/NewNotification.java b/src/main/java/org/onap/dcaegen2/services/sonhms/NewNotification.java
index 9f6e57f..703204b 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/NewNotification.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/NewNotification.java
@@ -21,6 +21,9 @@
package org.onap.dcaegen2.services.sonhms;
+import org.springframework.stereotype.Component;
+
+@Component
public class NewNotification {
private Boolean newNotif;
@@ -37,5 +40,9 @@ public class NewNotification {
super();
this.newNotif = newNotif;
}
+
+ public NewNotification() {
+
+ }
}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/NotificationToClusterMapping.java b/src/main/java/org/onap/dcaegen2/services/sonhms/NotificationToClusterMapping.java
index 14961e5..d507f0c 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/NotificationToClusterMapping.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/NotificationToClusterMapping.java
@@ -21,11 +21,11 @@
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 {
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/SonController.java b/src/main/java/org/onap/dcaegen2/services/sonhms/SonController.java
index 15aa907..3c7d6ac 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/SonController.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/SonController.java
@@ -23,7 +23,6 @@ package org.onap.dcaegen2.services.sonhms;
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;
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/SonRequestsComponent.java b/src/main/java/org/onap/dcaegen2/services/sonhms/SonRequestsComponent.java
index 51607fa..a0851ce 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/SonRequestsComponent.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/SonRequestsComponent.java
@@ -22,7 +22,6 @@
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;
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThread.java b/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThread.java
index eff7a84..d12092b 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThread.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThread.java
@@ -21,14 +21,6 @@
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;
@@ -37,6 +29,14 @@ import java.util.Map;
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;
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.java b/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.java
index d7ff57a..89cafd6 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.java
@@ -24,6 +24,10 @@ package org.onap.dcaegen2.services.sonhms.child;
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;
@@ -36,8 +40,6 @@ import org.onap.dcaegen2.services.sonhms.model.Payload;
import org.onap.dcaegen2.services.sonhms.model.PolicyNotification;
import org.onap.dcaegen2.services.sonhms.model.Ran;
import org.onap.dcaegen2.services.sonhms.model.X0005b9Lte;
-import java.util.ArrayList;
-import java.util.List;
import org.slf4j.Logger;
public class ChildThreadUtils {
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/child/ClusterFormation.java b/src/main/java/org/onap/dcaegen2/services/sonhms/child/ClusterFormation.java
index 9a594a1..e248a59 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/child/ClusterFormation.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/child/ClusterFormation.java
@@ -21,14 +21,6 @@
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;
@@ -36,6 +28,13 @@ import java.util.Properties;
import java.util.UUID;
import java.util.concurrent.BlockingQueue;
+import org.onap.dcaegen2.services.sonhms.ConfigPolicy;
+import org.onap.dcaegen2.services.sonhms.Configuration;
+import org.onap.dcaegen2.services.sonhms.dao.ClusterDetailsRepository;
+import org.onap.dcaegen2.services.sonhms.entity.ClusterDetails;
+import org.onap.dcaegen2.services.sonhms.model.FapServiceList;
+import org.onap.dcaegen2.services.sonhms.utils.BeanUtil;
+import org.onap.dcaegen2.services.sonhms.utils.ClusterUtils;
import org.slf4j.Logger;
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/child/Detection.java b/src/main/java/org/onap/dcaegen2/services/sonhms/child/Detection.java
index 847e2d5..2634d9a 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/child/Detection.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/child/Detection.java
@@ -21,12 +21,11 @@
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;
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/child/Graph.java b/src/main/java/org/onap/dcaegen2/services/sonhms/child/Graph.java
index eedbd94..a76d0dd 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/child/Graph.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/child/Graph.java
@@ -24,8 +24,6 @@ package org.onap.dcaegen2.services.sonhms.child;
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;
@@ -34,12 +32,13 @@ import java.util.List;
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 {
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/child/PnfUtils.java b/src/main/java/org/onap/dcaegen2/services/sonhms/child/PnfUtils.java
index 560fd52..30fd0b9 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/child/PnfUtils.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/child/PnfUtils.java
@@ -21,6 +21,12 @@
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;
@@ -30,12 +36,6 @@ import org.onap.dcaegen2.services.sonhms.restclient.Solution;
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 {
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/child/StateOof.java b/src/main/java/org/onap/dcaegen2/services/sonhms/child/StateOof.java
index d731725..ae40dbf 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/child/StateOof.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/child/StateOof.java
@@ -21,6 +21,14 @@
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;
@@ -33,15 +41,6 @@ import org.onap.dcaegen2.services.sonhms.restclient.AsyncResponseBody;
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 {
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
new file mode 100644
index 0000000..ab6d40d
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/controller/ConfigFetchFromCbs.java
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * ============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);
+ });
+
+ }
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/controller/HealthCheck.java b/src/main/java/org/onap/dcaegen2/services/sonhms/controller/HealthCheck.java
index d0d9321..322c113 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/controller/HealthCheck.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/controller/HealthCheck.java
@@ -29,8 +29,8 @@ import org.springframework.web.bind.annotation.RestController;
@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);
+ }
}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dao/BufferedNotificationsRepository.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dao/BufferedNotificationsRepository.java
index 43bb1f3..470f50d 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/dao/BufferedNotificationsRepository.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dao/BufferedNotificationsRepository.java
@@ -21,10 +21,9 @@
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;
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dao/CellInfoRepository.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dao/CellInfoRepository.java
index 80066ad..fcafca9 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/dao/CellInfoRepository.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dao/CellInfoRepository.java
@@ -22,7 +22,6 @@
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;
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dao/ClusterDetailsRepository.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dao/ClusterDetailsRepository.java
index babef00..9bb54af 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/dao/ClusterDetailsRepository.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dao/ClusterDetailsRepository.java
@@ -21,10 +21,9 @@
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;
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dao/DmaapNotificationsRepository.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dao/DmaapNotificationsRepository.java
index 356dca6..7d41728 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/dao/DmaapNotificationsRepository.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dao/DmaapNotificationsRepository.java
@@ -22,7 +22,6 @@
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;
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dao/FaultNotificationsRepository.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dao/FaultNotificationsRepository.java
new file mode 100644
index 0000000..31b9b98
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dao/FaultNotificationsRepository.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.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();
+
+}
+
+
+
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dao/SonRequestsRepository.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dao/SonRequestsRepository.java
index b54661b..4bf9dd6 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/dao/SonRequestsRepository.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dao/SonRequestsRepository.java
@@ -22,7 +22,6 @@
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;
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/DmaapClient.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/DmaapClient.java
index 002f835..91e7117 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/DmaapClient.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/DmaapClient.java
@@ -21,25 +21,16 @@
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;
@@ -52,164 +43,82 @@ import org.springframework.stereotype.Component;
@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);
+
+ }
+
}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationConsumer.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationConsumer.java
index ba6b83d..78294a3 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationConsumer.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationConsumer.java
@@ -22,10 +22,10 @@
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;
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationProducer.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationProducer.java
index e1db372..7ecb1d9 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationProducer.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationProducer.java
@@ -22,8 +22,8 @@
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 {
@@ -31,7 +31,7 @@ public class NotificationProducer {
/**
- * Parameterised constructor.
+ * Parameterized constructor.
*/
public NotificationProducer(CambriaBatchingPublisher cambriaBatchingPublisher) {
super();
@@ -41,11 +41,9 @@ public class NotificationProducer {
/**
* 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);
}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyDmaapClient.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyDmaapClient.java
index 4d5d23b..68cb788 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyDmaapClient.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyDmaapClient.java
@@ -22,31 +22,37 @@
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;
+ }
}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/entity/FaultNotifications.java b/src/main/java/org/onap/dcaegen2/services/sonhms/entity/FaultNotifications.java
new file mode 100644
index 0000000..f1d4c5d
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/entity/FaultNotifications.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.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;
+ }
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/NeighborListInUse.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/NeighborListInUse.java
index 50df1d8..b88cb5a 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/model/NeighborListInUse.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/NeighborListInUse.java
@@ -22,6 +22,7 @@
package org.onap.dcaegen2.services.sonhms.model;
import com.fasterxml.jackson.annotation.JsonProperty;
+
import java.util.List;
public class NeighborListInUse {
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/Payload.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Payload.java
index dd10a1f..8883992 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/model/Payload.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Payload.java
@@ -22,6 +22,7 @@
package org.onap.dcaegen2.services.sonhms.model;
import com.fasterxml.jackson.annotation.JsonProperty;
+
import java.util.List;
public class Payload {
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/PolicyNotification.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/PolicyNotification.java
index 076c7b5..35480cf 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/model/PolicyNotification.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/PolicyNotification.java
@@ -203,4 +203,14 @@ public class PolicyNotification {
return result;
}
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ return (this.hashCode() == obj.hashCode());
+ }
+
+
+
}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/RadioAccess.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/RadioAccess.java
index 775c14d..21e5c43 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/model/RadioAccess.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/RadioAccess.java
@@ -22,6 +22,7 @@
package org.onap.dcaegen2.services.sonhms.model;
import com.fasterxml.jackson.annotation.JsonProperty;
+
import java.util.List;
public class RadioAccess {
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/OofRestClient.java b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/OofRestClient.java
index a9ce305..083341b 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/OofRestClient.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/OofRestClient.java
@@ -23,13 +23,14 @@ package org.onap.dcaegen2.services.sonhms.restclient;
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;
@@ -44,61 +45,64 @@ public class OofRestClient {
/**
* 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();
}
}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/PolicyRestClient.java b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/PolicyRestClient.java
deleted file mode 100644
index 7334df2..0000000
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/PolicyRestClient.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START=======================================================
- * son-handler
- * ================================================================================
- * Copyright (C) 2019 Wipro Limited.
- * ==============================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- *
- *******************************************************************************/
-
-package org.onap.dcaegen2.services.sonhms.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();
-
- }
-
-}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/SdnrRestClient.java b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/SdnrRestClient.java
index 0894146..996e553 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/SdnrRestClient.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/SdnrRestClient.java
@@ -21,11 +21,6 @@
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;
@@ -33,6 +28,10 @@ import java.util.List;
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;
@@ -58,7 +57,7 @@ public class SdnrRestClient {
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);
}
@@ -72,7 +71,7 @@ public class SdnrRestClient {
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);
@@ -96,7 +95,7 @@ public class SdnrRestClient {
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);
@@ -112,7 +111,7 @@ public class SdnrRestClient {
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);
@@ -132,7 +131,7 @@ public class SdnrRestClient {
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();
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/utils/AppConfig.java b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/AppConfig.java
index a30288a..b5c63e8 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/utils/AppConfig.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/AppConfig.java
@@ -39,6 +39,7 @@ import org.springframework.web.client.RestTemplate;
public class AppConfig {
+
/**
* Rest Template bean.
*/
@@ -60,7 +61,7 @@ public class AppConfig {
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;
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/utils/BeanUtil.java b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/BeanUtil.java
index 63a738c..b7e3123 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/utils/BeanUtil.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/BeanUtil.java
@@ -21,7 +21,6 @@
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;
@@ -31,7 +30,7 @@ public class BeanUtil implements ApplicationContextAware {
private static ApplicationContext context;
@Override
- public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+ public void setApplicationContext(ApplicationContext applicationContext) {
context = applicationContext;
}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtils.java b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtils.java
index 79d0c61..5b4ca55 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtils.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtils.java
@@ -21,6 +21,16 @@
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;
@@ -32,17 +42,6 @@ import org.onap.dcaegen2.services.sonhms.model.FapServiceList;
import org.onap.dcaegen2.services.sonhms.model.LteNeighborListInUseLteCell;
import org.onap.dcaegen2.services.sonhms.model.Notification;
import org.onap.dcaegen2.services.sonhms.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;
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/utils/DmaapUtils.java b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/DmaapUtils.java
new file mode 100644
index 0000000..ad6c385
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/DmaapUtils.java
@@ -0,0 +1,133 @@
+/*******************************************************************************
+ * ============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();
+ }
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/utils/SonHandlerRestTemplate.java b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/SonHandlerRestTemplate.java
index 7745117..2fe478e 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/utils/SonHandlerRestTemplate.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/SonHandlerRestTemplate.java
@@ -122,25 +122,6 @@ public class SonHandlerRestTemplate {
}
/**
- * 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.
*/
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/utils/ThreadUtils.java b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/ThreadUtils.java
index 07e7219..78722ba 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/utils/ThreadUtils.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/ThreadUtils.java
@@ -20,18 +20,17 @@
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;
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index 5905adf..c8bf90c 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -19,11 +19,14 @@
#
###############################################################################
-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
diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml
index 160ff9c..b7baa6f 100644
--- a/src/main/resources/logback.xml
+++ b/src/main/resources/logback.xml
@@ -28,7 +28,7 @@
<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>
diff --git a/src/main/docker/postgres_scripts/createdb.sql b/src/main/resources/schema.sql
index dc843e7..88b64d5 100644
--- a/src/main/docker/postgres_scripts/createdb.sql
+++ b/src/main/resources/schema.sql
@@ -1,5 +1,3 @@
-CREATE DATABASE sonh_ms;
-\c sonh_ms
CREATE TABLE DMAAP_NOTIFICATIONS(
notification TEXT PRIMARY KEY NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
@@ -22,4 +20,8 @@ CREATE TABLE PCI_REQUESTS(
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
+);
+