summaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authorramya <ramya.ravichandran5@wipro.com>2019-03-11 17:34:41 +0530
committerramya <ramya.ravichandran5@wipro.com>2019-03-11 17:37:12 +0530
commit3cd4023832810e8b65f85a9db807c8bafec38d82 (patch)
tree13175e409ca3b29eccffacd75538ded25cfdb518 /src/main/java/org
parent79f9e63b3e531ae7ca4eaa7224ab8a740ad578cb (diff)
code coverage for M3
Change-Id: Ib421ce2ac9357a3210d99293497f9e304f8cd2f5 Issue-ID: DCAEGEN2-1259 Signed-off-by: Ramya Ravichandran<ramya.ravichandran5@wipro.com>
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/Application.java129
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/BufferNotificationComponent.java63
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/ClusterDetailsComponent.java59
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/ConfigPolicy.java58
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java309
-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.java58
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/EventHandler.java252
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/MainThread.java98
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/MainThreadComponent.java43
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/NewNotification.java41
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/NotificationToClusterMapping.java93
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/SonController.java59
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/SonRequestsComponent.java41
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/Topic.java73
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThread.java245
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.java94
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/child/ClusterFormation.java146
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/child/Detection.java88
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/child/Graph.java242
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/child/PnfUtils.java78
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/child/StateOof.java193
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/controller/HealthCheck.java36
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/dao/BufferedNotificationsRepository.java44
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/dao/CellInfoRepository.java35
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/dao/ClusterDetailsRepository.java60
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/dao/DmaapNotificationsRepository.java41
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/dao/SonRequestsRepository.java44
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/DmaapClient.java215
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationConsumer.java60
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationProducer.java52
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyDmaapClient.java52
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/entity/BufferedNotifications.java85
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/entity/CellInfo.java70
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/entity/ClusterDetails.java87
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/entity/DmaapNotifications.java70
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/entity/PciRequests.java69
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/exceptions/ConfigDbNotFoundException.java34
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/exceptions/OofNotFoundException.java34
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/model/CellConfig.java48
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/model/CellNeighbourList.java70
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/model/CellPciPair.java99
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/model/Common.java48
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/model/Configurations.java55
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/model/Data.java48
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/model/FapService.java75
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/model/FapServiceList.java81
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/model/Lte.java48
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/model/LteNeighborListInUseLteCell.java136
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/model/NeighborListInUse.java65
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/model/Notification.java120
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/model/NotificationCellConfig.java52
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/model/NotificationLte.java52
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/model/NotificationPayload.java52
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/model/NotificationRan.java64
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/model/Payload.java55
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/model/PolicyNotification.java206
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/model/RadioAccess.java65
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/model/Ran.java51
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/model/Response.java49
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/model/SdnrResponse.java38
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/model/ThreadId.java36
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/model/X0005b9Lte.java64
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/restclient/AsyncResponseBody.java80
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/restclient/CellInfo.java49
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/restclient/OofRequestBody.java45
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/restclient/OofRestClient.java104
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/restclient/PolicyRequestBody.java54
-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/RequestInfo.java101
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/restclient/SdnrRestClient.java141
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/restclient/Solution.java75
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/restclient/SonSolution.java45
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/utils/AppConfig.java68
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/utils/BeanUtil.java41
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtils.java344
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/utils/FileIo.java51
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/utils/SonHandlerRestTemplate.java162
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/utils/ThreadUtils.java84
79 files changed, 6820 insertions, 0 deletions
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/Application.java b/src/main/java/org/onap/dcaegen2/services/sonhms/Application.java
new file mode 100644
index 0000000..7eb9e62
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/Application.java
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import 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 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;
+
+@SpringBootApplication
+public class Application {
+
+ @Autowired
+ DmaapClient dmaapClient;
+
+ @Autowired
+ MainThreadComponent mainThreadComponent;
+
+ private static Logger log = LoggerFactory.getLogger(Application.class);
+
+ /**
+ * Main method where the pci context is initially set.
+ */
+ public static void main(String[] args) {
+ 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.
+ *
+ */
+ private void getConfig() {
+ log.debug("getting initial config");
+ String configJson = FileIo.readFromFile("/etc/config.json");
+ ObjectMapper mapper = new ObjectMapper();
+ 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);
+ }
+ }
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/BufferNotificationComponent.java b/src/main/java/org/onap/dcaegen2/services/sonhms/BufferNotificationComponent.java
new file mode 100644
index 0000000..50dec11
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/BufferNotificationComponent.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms;
+
+import 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 {
+
+ /**
+ * Buffers notification along with cluster id in the database.
+ */
+ public void bufferNotification(String notification, String clusterId) {
+ BufferedNotifications bufferedNotifications = new BufferedNotifications();
+ bufferedNotifications.setNotification(notification);
+ bufferedNotifications.setClusterId(clusterId);
+ BufferedNotificationsRepository bufferedNotificationsRepository = BeanUtil
+ .getBean(BufferedNotificationsRepository.class);
+ bufferedNotificationsRepository.save(bufferedNotifications);
+
+ }
+
+ /**
+ * Retrieves buffered notification from the database.
+ */
+ public List<String> getBufferedNotification(String clusterId) {
+ BufferedNotificationsRepository bufferedNotificationsRepository = BeanUtil
+ .getBean(BufferedNotificationsRepository.class);
+ return bufferedNotificationsRepository.getNotificationsFromQueue(clusterId);
+
+ }
+
+ /**
+ * Retrieves clusterid from the database.
+ */
+ public String getClusterId(String notification) {
+ BufferedNotificationsRepository bufferedNotificationsRepository = BeanUtil
+ .getBean(BufferedNotificationsRepository.class);
+ return bufferedNotificationsRepository.getClusterIdForNotification(notification);
+ }
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/ClusterDetailsComponent.java b/src/main/java/org/onap/dcaegen2/services/sonhms/ClusterDetailsComponent.java
new file mode 100644
index 0000000..8e4b357
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/ClusterDetailsComponent.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * ============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.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 {
+
+ /**
+ * get cluster details.
+ */
+ public List<ClusterDetails> getClusterDetails() {
+ ClusterDetailsRepository clusterDetailsRepository = BeanUtil.getBean(ClusterDetailsRepository.class);
+ return clusterDetailsRepository.getAllClusterDetails();
+ }
+
+ /**
+ * get child thread.
+ */
+ public long getChildThread(String clusterId) {
+ ClusterDetailsRepository clusterDetailsRepository = BeanUtil.getBean(ClusterDetailsRepository.class);
+ return clusterDetailsRepository.getChildThreadForCluster(clusterId);
+
+ }
+
+ /**
+ * get cluster id.
+ */
+ public String getClusterId(long childThreadId) {
+ ClusterDetailsRepository clusterDetailsRepository = BeanUtil.getBean(ClusterDetailsRepository.class);
+ return clusterDetailsRepository.getClusterIdForChildThread(childThreadId);
+
+ }
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/ConfigPolicy.java b/src/main/java/org/onap/dcaegen2/services/sonhms/ConfigPolicy.java
new file mode 100644
index 0000000..7c065ac
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/ConfigPolicy.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms;
+
+import java.util.Map;
+
+public class ConfigPolicy {
+
+ private static ConfigPolicy instance = null;
+ private Map<String, Object> config;
+
+ protected ConfigPolicy() {
+
+ }
+
+ /**
+ * Get instance of class.
+ */
+ public static ConfigPolicy getInstance() {
+ if (instance == null) {
+ instance = new ConfigPolicy();
+ }
+ return instance;
+ }
+
+ public Map<String, Object> getConfig() {
+ return config;
+ }
+
+ public void setConfig(Map<String, Object> config) {
+ this.config = config;
+ }
+
+ @Override
+ public String toString() {
+ return "ConfigPolicy [config=" + config + "]";
+ }
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java b/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java
new file mode 100644
index 0000000..a90a0b9
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java
@@ -0,0 +1,309 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms;
+
+import java.util.List;
+
+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 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;
+
+ public String getConsulHost() {
+ return consulHost;
+ }
+
+ public void setConsulHost(String consulHost) {
+ this.consulHost = consulHost;
+ }
+
+ public String getHostName() {
+ return hostName;
+ }
+
+ public void setHostName(String hostName) {
+ this.hostName = hostName;
+ }
+
+ public String getConfigBindingService() {
+ return configBindingService;
+ }
+
+ public void setConfigBindingService(String configBindingService) {
+ this.configBindingService = configBindingService;
+ }
+
+ public int getMaximumClusters() {
+ return maximumClusters;
+ }
+
+ public void setMaximumClusters(int maximumClusters) {
+ this.maximumClusters = maximumClusters;
+ }
+
+ protected Configuration() {
+
+ }
+
+ /**
+ * Get instance of class.
+ */
+ public static Configuration getInstance() {
+ if (instance == null) {
+ instance = new 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;
+ }
+
+ public void setCg(String cg) {
+ this.cg = cg;
+ }
+
+ public String getCid() {
+ return cid;
+ }
+
+ public void setCid(String cid) {
+ this.cid = cid;
+ }
+
+ public int getPollingInterval() {
+ return pollingInterval;
+ }
+
+ public void setPollingInterval(int pollingInterval) {
+ this.pollingInterval = pollingInterval;
+ }
+
+ public int getPollingTimeout() {
+ return pollingTimeout;
+ }
+
+ public void setPollingTimeout(int pollingTimeout) {
+ this.pollingTimeout = pollingTimeout;
+ }
+
+ public int getMinCollision() {
+ return minCollision;
+ }
+
+ public void setMinCollision(int minCollision) {
+ this.minCollision = minCollision;
+ }
+
+ public int getMinConfusion() {
+ return minConfusion;
+ }
+
+ public void setMinConfusion(int minConfusion) {
+ 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;
+ }
+
+ public void setOofService(String oofService) {
+ this.oofService = oofService;
+ }
+
+ public String getSourceId() {
+ return sourceId;
+ }
+
+ public void setSourceId(String sourceId) {
+ 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() {
+ return callbackUrl;
+ }
+
+ public void setCallbackUrl(String callbackUrl) {
+ this.callbackUrl = callbackUrl;
+ }
+
+ public List<String> getOptimizers() {
+ return optimizers;
+ }
+
+ public void setOptimizers(List<String> optimizers) {
+ this.optimizers = optimizers;
+ }
+
+ public int getNumSolutions() {
+ return numSolutions;
+ }
+
+ public void setNumSolutions(int numSolutions) {
+ this.numSolutions = numSolutions;
+ }
+
+ public int getBufferTime() {
+ return bufferTime;
+ }
+
+ public void setBufferTime(int bufferTime) {
+ this.bufferTime = bufferTime;
+ }
+
+ public List<Topic> getTopics() {
+ return topics;
+ }
+
+ public void setTopics(List<Topic> topics) {
+ this.topics = topics;
+ }
+
+ public String getSdnrTopic() {
+ return sdnrTopic;
+ }
+
+ public void setSdnrTopic(String sdnrTopic) {
+ this.sdnrTopic = sdnrTopic;
+ }
+
+ public String getPolicyTopic() {
+ return policyTopic;
+ }
+
+ public void setPolicyTopic(String policyTopic) {
+ this.policyTopic = policyTopic;
+ }
+
+ @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 + "]";
+ }
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/ConfigurationFetcher.java b/src/main/java/org/onap/dcaegen2/services/sonhms/ConfigurationFetcher.java
new file mode 100644
index 0000000..4a55393
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/ConfigurationFetcher.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms;
+
+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
new file mode 100644
index 0000000..f28de63
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/DmaapNotificationsComponent.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms;
+
+import 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.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DmaapNotificationsComponent {
+
+ private static Logger log = LoggerFactory.getLogger(DmaapNotificationsComponent.class);
+
+ /**
+ * Get dmaap notifications.
+ */
+ public Either<Notification, Integer> getDmaapNotifications() {
+ DmaapNotificationsRepository dmaapNotificationsRepository = BeanUtil
+ .getBean(DmaapNotificationsRepository.class);
+ String notificationString = dmaapNotificationsRepository.getNotificationFromQueue();
+ ObjectMapper mapper = new ObjectMapper();
+
+ Notification notification = new Notification();
+ try {
+ notification = mapper.readValue(notificationString, Notification.class);
+ return Either.left(notification);
+ } catch (IOException e) {
+ log.error("Exception in parsing notification", notificationString, e);
+ return Either.right(400);
+ }
+ }
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/EventHandler.java b/src/main/java/org/onap/dcaegen2/services/sonhms/EventHandler.java
new file mode 100644
index 0000000..312ca60
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/EventHandler.java
@@ -0,0 +1,252 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * pcims
+ * ================================================================================
+ * Copyright (C) 2018 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ ******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.onap.dcaegen2.services.sonhms.child.ChildThread;
+import org.onap.dcaegen2.services.sonhms.child.Graph;
+import org.onap.dcaegen2.services.sonhms.entity.ClusterDetails;
+import org.onap.dcaegen2.services.sonhms.exceptions.ConfigDbNotFoundException;
+import org.onap.dcaegen2.services.sonhms.model.FapServiceList;
+import org.onap.dcaegen2.services.sonhms.model.Notification;
+import org.onap.dcaegen2.services.sonhms.utils.ClusterUtils;
+import org.onap.dcaegen2.services.sonhms.utils.ThreadUtils;
+
+import fj.data.Either;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ExecutorService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class EventHandler {
+
+ private static Logger log = LoggerFactory.getLogger(EventHandler.class);
+
+ private static Map<Long, ChildThread> childThreadMap = new HashMap<>();
+
+ private BlockingQueue<List<String>> childStatusQueue;
+
+ private Map<Long, String> childStatus;
+
+ private ExecutorService pool;
+
+ private ClusterUtils clusterUtils;
+
+ private ThreadUtils threadUtils;
+
+ /**
+ * Constructor.
+ */
+ public EventHandler(BlockingQueue<List<String>> childStatusQueue, ExecutorService pool,
+ Map<Long, String> childStatus, ClusterUtils clusterUtils, ThreadUtils threadUtils) {
+
+ this.childStatusQueue = childStatusQueue;
+ this.childStatus = childStatus;
+ this.pool = pool;
+ this.clusterUtils = clusterUtils;
+ this.threadUtils = threadUtils;
+ }
+
+ /**
+ * handle sdnr notification.
+ */
+ public Boolean handleSdnrNotification(Notification notification) {
+ // Check if notification matches with a cluster
+
+ try {
+ List<ClusterDetails> clusterDetails = clusterUtils.getAllClusters();
+
+ NotificationToClusterMapping mapping = new NotificationToClusterMapping();
+ mapping = clusterUtils.getClustersForNotification(notification, clusterDetails);
+
+ // Matching cells
+ System.out.println(mapping);
+ if (mapping.getCellsinCluster() != null) {
+ handleMatchingCells(mapping.getCellsinCluster(), clusterDetails);
+ }
+
+ // unmatched cells
+ if (mapping.getNewCells() != null) {
+ handleUnMatchingCells(mapping.getNewCells());
+ }
+ } catch (Exception e) {
+ log.error("Exception in sdnr notification handling {}", e);
+ return false;
+ }
+
+ return true;
+
+ }
+
+ private void handleUnMatchingCells(List<FapServiceList> newCells) {
+ List<Graph> newClusters = new ArrayList<>();
+
+ for (FapServiceList fapService : newCells) {
+
+ Either<Graph, Integer> existingCluster = clusterUtils.getClusterForCell(fapService, newClusters);
+ if (existingCluster.isRight()) {
+ try {
+ Graph cluster = clusterUtils.createCluster(fapService);
+ newClusters.add(cluster);
+ } catch (ConfigDbNotFoundException e) {
+ log.error("Error connecting with configDB {}", e);
+ }
+ }
+
+ else {
+ Graph cluster = existingCluster.left().value();
+
+ Graph modifiedCluster = clusterUtils.modifyCluster(cluster, fapService);
+ newClusters.remove(cluster);
+ newClusters.add(modifiedCluster);
+ }
+
+ }
+
+ // create new child thread
+
+ threadUtils.createNewThread(newClusters, childStatusQueue, pool, this);
+
+ }
+
+ private void handleMatchingCells(Map<FapServiceList, String> cellsInCluster, List<ClusterDetails> clusterDetails) {
+ for (Entry<FapServiceList, String> entry : cellsInCluster.entrySet()) {
+
+ FapServiceList fapService = entry.getKey();
+ String clusterId = entry.getValue();
+ Either<ClusterDetails, Integer> clusterDetail = clusterUtils.getClusterDetailsFromClusterId(clusterId,
+ clusterDetails);
+
+ if (clusterDetail.isRight()) {
+ log.error("Cannot find the cluster for Cluster ID");
+ return;
+ } else {
+ long threadId = clusterDetail.left().value().getChildThreadId();
+
+ if (childStatus.get(threadId).equals("triggeredOof")) {
+ log.info("OOF triggered for the cluster, buffering notification");
+ bufferNotification(fapService, clusterId);
+ } else {
+ childThreadMap.get(threadId).putInQueue(fapService);
+ }
+ }
+ }
+ }
+
+ private void bufferNotification(FapServiceList fapService, String clusterId) {
+ ObjectMapper mapper = new ObjectMapper();
+ BufferNotificationComponent bufferNotifComponent = new BufferNotificationComponent();
+ String serviceListString = "";
+ try {
+ serviceListString = mapper.writeValueAsString(fapService);
+ } catch (JsonProcessingException e) {
+ log.debug("JSON processing exception: {}", e);
+ }
+ bufferNotifComponent.bufferNotification(serviceListString, clusterId);
+
+ }
+
+ /**
+ * handle child status update.
+ */
+ public void handleChildStatusUpdate(List<String> childStatus) {
+
+ // update Child status in data structure
+ Long childThreadId = Long.parseLong(childStatus.get(0));
+ addChildStatus(childThreadId, childStatus.get(1));
+
+ // if child status is OOF result success, handle buffered notifications
+ if (childStatus.get(1).equals("success")) {
+ BufferNotificationComponent bufferNotificationComponent = new BufferNotificationComponent();
+ ClusterDetailsComponent clusterDetailsComponent = new ClusterDetailsComponent();
+ String clusterId = clusterDetailsComponent.getClusterId(childThreadId);
+ List<String> bufferedNotifications = bufferNotificationComponent.getBufferedNotification(clusterId);
+
+ if (bufferedNotifications == null || bufferedNotifications.isEmpty()) {
+ log.info("No buffered notification for this thread");
+
+ Set<Thread> setOfThread = Thread.getAllStackTraces().keySet();
+ for (Thread thread : setOfThread) {
+ if (thread.getId() == childThreadId) {
+ deleteChildStatus(childThreadId);
+ thread.interrupt();
+ }
+ }
+ } else {
+ handleBufferedNotifications(childThreadId, bufferedNotifications);
+ }
+ }
+ // else kill the child thread
+
+ }
+
+ private void handleBufferedNotifications(Long childThreadId, List<String> bufferedNotifications) {
+
+ ObjectMapper mapper = new ObjectMapper();
+ for (String notification : bufferedNotifications) {
+ FapServiceList fapServiceList;
+ try {
+ fapServiceList = mapper.readValue(notification, FapServiceList.class);
+ log.debug("fapServiceList{}", fapServiceList);
+
+ childThreadMap.get(childThreadId).putInQueueWithNotify(fapServiceList);
+
+ } catch (IOException e) {
+ log.error("Error parsing the buffered notification, skipping {}", e);
+ }
+ }
+ }
+
+ public static void addChildThreadMap(Long childThreadId, ChildThread child) {
+ childThreadMap.put(childThreadId, child);
+ }
+
+ public static Map<Long, ChildThread> getChildThreadMap() {
+ return childThreadMap;
+ }
+
+ public void addChildStatus(Long threadId, String status) {
+ this.childStatus.put(threadId, status);
+ }
+
+ public String getChildStatus(Long threadId) {
+ return childStatus.get(threadId);
+
+ }
+
+ public void deleteChildStatus(Long childThreadId) {
+ this.childStatus.remove(childThreadId);
+
+ }
+
+ public ExecutorService getPool() {
+ return pool;
+ }
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/MainThread.java b/src/main/java/org/onap/dcaegen2/services/sonhms/MainThread.java
new file mode 100644
index 0000000..2026500
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/MainThread.java
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * ============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.model.Notification;
+import org.onap.dcaegen2.services.sonhms.utils.ClusterUtils;
+import org.onap.dcaegen2.services.sonhms.utils.ThreadUtils;
+
+import fj.data.Either;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.Executors;
+import java.util.concurrent.LinkedBlockingQueue;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class MainThread implements Runnable {
+ private static Logger log = LoggerFactory.getLogger(MainThread.class);
+
+ private NewNotification newNotification;
+
+ private BlockingQueue<List<String>> childStatusQueue;
+
+ private DmaapNotificationsComponent dmaapNotificationsComponent;
+
+ private EventHandler eventHandler;
+
+ /**
+ * parameterized constructor.
+ */
+ public MainThread(NewNotification newNotification) {
+ super();
+ this.newNotification = newNotification;
+ childStatusQueue = new LinkedBlockingQueue<>();
+ dmaapNotificationsComponent = new DmaapNotificationsComponent();
+ eventHandler = new EventHandler(childStatusQueue,
+ Executors.newFixedThreadPool(Configuration.getInstance().getMaximumClusters()),
+ new HashMap<>(), new ClusterUtils(), new ThreadUtils());
+ }
+
+ @Override
+ public void run() {
+ log.info("Starting Main Thread");
+
+ // Check for Notifications from Dmaap and Child thread
+ Boolean done = false;
+
+ while (!done) {
+ try {
+ if (!childStatusQueue.isEmpty()) {
+ List<String> childState = childStatusQueue.poll();
+ if (childState != null) {
+ eventHandler.handleChildStatusUpdate(childState);
+ }
+ }
+
+ if (newNotification.getNewNotif()) {
+ Either<Notification, Integer> notification = dmaapNotificationsComponent.getDmaapNotifications();
+ if (notification.isRight()) {
+ log.error("Error parsing the notification from SDNR");
+ } else if (notification.isLeft()) {
+ Boolean result = eventHandler.handleSdnrNotification(notification.left().value());
+ log.debug("SDNR notification handling {}", result);
+ }
+
+ }
+
+ } catch (Exception e) {
+ log.error("Exception in main Thread", e);
+ done = true;
+ }
+
+ }
+
+ }
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/MainThreadComponent.java b/src/main/java/org/onap/dcaegen2/services/sonhms/MainThreadComponent.java
new file mode 100644
index 0000000..f83541a
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/MainThreadComponent.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;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+@Component
+public class MainThreadComponent {
+
+ private static Logger log = LoggerFactory.getLogger(MainThreadComponent.class);
+
+
+
+ /**
+ * main thread initialization.
+ */
+ public void init(NewNotification newNotification) {
+ 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
new file mode 100644
index 0000000..9f6e57f
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/NewNotification.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms;
+
+public class NewNotification {
+
+ private Boolean newNotif;
+
+ public Boolean getNewNotif() {
+ return newNotif;
+ }
+
+ public void setNewNotif(Boolean newNotif) {
+ this.newNotif = newNotif;
+ }
+
+ public NewNotification(Boolean newNotif) {
+ super();
+ this.newNotif = newNotif;
+ }
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/NotificationToClusterMapping.java b/src/main/java/org/onap/dcaegen2/services/sonhms/NotificationToClusterMapping.java
new file mode 100644
index 0000000..14961e5
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/NotificationToClusterMapping.java
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * ============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.model.FapServiceList;
+
+import java.util.List;
+import java.util.Map;
+
+
+public class NotificationToClusterMapping {
+
+ private Map<FapServiceList, String> cellsinCluster;
+
+ private List<FapServiceList> newCells;
+
+ public Map<FapServiceList, String> getCellsinCluster() {
+ return cellsinCluster;
+ }
+
+ public void setCellsinCluster(Map<FapServiceList, String> cellsinCluster) {
+ this.cellsinCluster = cellsinCluster;
+ }
+
+ public List<FapServiceList> getNewCells() {
+ return newCells;
+ }
+
+ public void setNewCells(List<FapServiceList> newCells) {
+ this.newCells = newCells;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((cellsinCluster == null) ? 0 : cellsinCluster.hashCode());
+ result = prime * result + ((newCells == null) ? 0 : newCells.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ NotificationToClusterMapping other = (NotificationToClusterMapping) obj;
+ if (cellsinCluster == null) {
+ if (other.cellsinCluster != null) {
+ return false;
+ }
+ } else if (!cellsinCluster.equals(other.cellsinCluster)) {
+ return false;
+ }
+ if (newCells == null) {
+ if (other.newCells != null) {
+ return false;
+ }
+ } else if (!newCells.equals(other.newCells)) {
+ return false;
+ }
+ return true;
+ }
+
+
+
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/SonController.java b/src/main/java/org/onap/dcaegen2/services/sonhms/SonController.java
new file mode 100644
index 0000000..15aa907
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/SonController.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * ============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.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;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+
+@RestController
+public class SonController {
+ private static final Logger log = org.slf4j.LoggerFactory.getLogger(SonController.class);
+
+ @Autowired
+ SonRequestsComponent pciRequestsComponent;
+
+ @RequestMapping(value = "/callbackUrl", method = RequestMethod.POST)
+ String callBackUrl(@RequestBody AsyncResponseBody callback) {
+ log.debug("received request to callback url");
+ String async = callback.toString();
+ log.debug("AsyncResponseBody{}", async);
+
+ String transactionId = callback.getTransactionId();
+ log.debug("transaction id {}", transactionId);
+
+ long childThreadId = pciRequestsComponent.getChildThread(transactionId);
+ log.debug("childThreadId {}", childThreadId);
+
+ ChildThread.putResponse(childThreadId, callback);
+ return "Forwarded to child thread";
+
+ }
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/SonRequestsComponent.java b/src/main/java/org/onap/dcaegen2/services/sonhms/SonRequestsComponent.java
new file mode 100644
index 0000000..51607fa
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/SonRequestsComponent.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * ============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.dao.SonRequestsRepository;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+
+@Component
+public class SonRequestsComponent {
+
+ @Autowired
+ private SonRequestsRepository sonRequestsRepository;
+
+ public long getChildThread(String transactionId) {
+ return sonRequestsRepository.getChildThreadMapping(transactionId);
+ }
+
+}
+
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/Topic.java b/src/main/java/org/onap/dcaegen2/services/sonhms/Topic.java
new file mode 100644
index 0000000..616d389
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/Topic.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms;
+
+public class Topic {
+
+ private String name;
+ private String producer;
+ private String consumer;
+
+ public Topic() {
+
+ }
+
+ /**
+ * Parameterized constructor.
+ */
+ public Topic(String name, String producer, String consumer) {
+ super();
+ this.name = name;
+ this.producer = producer;
+ this.consumer = consumer;
+ }
+
+ @Override
+ public String toString() {
+ return "topic [name=" + name + ", producer=" + producer + ", consumer=" + consumer + "]";
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getProducer() {
+ return producer;
+ }
+
+ public void setProducer(String producer) {
+ this.producer = producer;
+ }
+
+ public String getConsumer() {
+ return consumer;
+ }
+
+ public void setConsumer(String consumer) {
+ this.consumer = consumer;
+ }
+
+}
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
new file mode 100644
index 0000000..eff7a84
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThread.java
@@ -0,0 +1,245 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.child;
+
+import org.onap.dcaegen2.services.sonhms.Configuration;
+import org.onap.dcaegen2.services.sonhms.dao.ClusterDetailsRepository;
+import org.onap.dcaegen2.services.sonhms.model.FapServiceList;
+import org.onap.dcaegen2.services.sonhms.model.ThreadId;
+import org.onap.dcaegen2.services.sonhms.restclient.AsyncResponseBody;
+import org.onap.dcaegen2.services.sonhms.utils.BeanUtil;
+import org.onap.dcaegen2.services.sonhms.utils.ClusterUtils;
+
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+import org.slf4j.Logger;
+import org.slf4j.MDC;
+
+
+public class ChildThread implements Runnable {
+
+ private BlockingQueue<List<String>> childStatusUpdate;
+ private BlockingQueue<FapServiceList> queue = new LinkedBlockingQueue<>();
+
+ private static Map<Long, AsyncResponseBody> responseMap = new HashMap<>();
+ private Graph cluster;
+ private ThreadId threadId;
+ FapServiceList fapServiceList = new FapServiceList();
+ private static final Logger log = org.slf4j.LoggerFactory.getLogger(ChildThread.class);
+
+ /**
+ * Constructor with parameters.
+ */
+ public ChildThread(BlockingQueue<List<String>> childStatusUpdate, Graph cluster,
+ BlockingQueue<FapServiceList> queue, ThreadId threadId) {
+ super();
+ this.childStatusUpdate = childStatusUpdate;
+ this.queue = queue;
+ this.threadId = threadId;
+ this.cluster = cluster;
+ }
+
+ /**
+ * Puts notification in queue.
+ */
+ public void putInQueue(FapServiceList fapserviceList) {
+ try {
+ queue.put(fapserviceList);
+ } catch (InterruptedException e) {
+ log.error(" The Thread is Interrupted", e);
+ Thread.currentThread().interrupt();
+ }
+ }
+
+ /**
+ * Puts notification in queue with notify.
+ */
+ public void putInQueueWithNotify(FapServiceList fapserviceList) {
+ synchronized (queue) {
+ try {
+ queue.put(fapserviceList);
+ queue.notifyAll();
+ } catch (InterruptedException e) {
+ log.error(" The Thread is Interrupted", e);
+ Thread.currentThread().interrupt();
+ }
+
+ }
+
+ }
+
+ /**
+ * Puts response in queue.
+ */
+ public static void putResponse(Long threadId, AsyncResponseBody obj) {
+ synchronized (responseMap) {
+ responseMap.put(threadId, obj);
+ }
+
+ }
+
+ public static Map<Long, AsyncResponseBody> getResponseMap() {
+ return responseMap;
+ }
+
+ @Override
+ public void run() {
+
+ threadId.setChildThreadId(Thread.currentThread().getId());
+ synchronized (threadId) {
+ threadId.notifyAll();
+ }
+
+ MDC.put("logFileName", Thread.currentThread().getName());
+ log.debug("Starting child thread");
+
+ try {
+ fapServiceList = queue.take();
+ if (log.isDebugEnabled()) {
+ log.debug("fapServicelist: {}", fapServiceList);
+ }
+ } catch (InterruptedException e1) {
+ log.error("InterruptedException is {}", e1);
+ Thread.currentThread().interrupt();
+ }
+
+ ClusterFormation clusterFormation = new ClusterFormation(queue);
+ StateOof oof = new StateOof(childStatusUpdate);
+ ClusterUtils clusterUtils = new ClusterUtils();
+ Detection detect = new Detection();
+
+ try {
+ String networkId = fapServiceList.getCellConfig().getLte().getRan().getNeighborListInUse()
+ .getLteNeighborListInUseLteCell().get(0).getPlmnid();
+
+ Boolean done = false;
+
+ while (!done) {
+
+ Map<String, ArrayList<Integer>> collisionConfusionResult = detect.detectCollisionConfusion(cluster);
+ Boolean trigger = clusterFormation.triggerOrWait(collisionConfusionResult);
+
+ if (!trigger) {
+ collisionConfusionResult = clusterFormation.waitForNotification(collisionConfusionResult, cluster);
+ }
+ oof.triggerOof(collisionConfusionResult, networkId);
+
+ if (isNotificationsBuffered()) {
+ List<FapServiceList> fapServiceLists = bufferNotification();
+ for (FapServiceList fapService : fapServiceLists) {
+ cluster = clusterUtils.modifyCluster(cluster, fapService);
+ }
+ String cellPciNeighbourString = cluster.getPciNeighbourJson();
+ UUID clusterId = cluster.getGraphId();
+ ClusterDetailsRepository clusterDetailsRepository = BeanUtil
+ .getBean(ClusterDetailsRepository.class);
+ clusterDetailsRepository.updateCluster(cellPciNeighbourString, clusterId.toString());
+
+ } else {
+ done = true;
+ }
+
+ }
+
+ } catch (Exception e) {
+ log.error("{}", e);
+ }
+
+ cleanup();
+ }
+
+ private boolean isNotificationsBuffered() {
+ synchronized (queue) {
+
+ try {
+ while (queue.isEmpty()) {
+ queue.wait();
+ }
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * cleanup resources.
+ */
+ private void cleanup() {
+ log.debug("cleaning up database and killing child thread");
+ ClusterDetailsRepository clusterDetailsRepository = BeanUtil.getBean(ClusterDetailsRepository.class);
+ clusterDetailsRepository.deleteByChildThreadId(threadId.getChildThreadId());
+ log.debug("Child thread :{} {}", Thread.currentThread().getId(), "completed");
+ MDC.remove("logFileName");
+
+ }
+
+ /**
+ * Buffer Notification.
+ */
+ public List<FapServiceList> bufferNotification() {
+
+ // Processing Buffered notifications
+
+ List<FapServiceList> fapServiceLists = new ArrayList<>();
+
+ Configuration config = Configuration.getInstance();
+
+ int bufferTime = config.getBufferTime();
+
+ Timestamp currentTime = new Timestamp(System.currentTimeMillis());
+ log.debug("Current time {}", currentTime);
+
+ Timestamp laterTime = new Timestamp(System.currentTimeMillis());
+ log.debug("Later time {}", laterTime);
+
+ long difference = laterTime.getTime() - currentTime.getTime();
+ while (difference < bufferTime) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ log.error("InterruptedException {}", e);
+ Thread.currentThread().interrupt();
+
+ }
+ laterTime = new Timestamp(System.currentTimeMillis());
+ difference = laterTime.getTime() - currentTime.getTime();
+
+ log.debug("Timer has run for seconds {}", difference);
+
+ if (!queue.isEmpty()) {
+ FapServiceList fapService;
+ fapService = queue.poll();
+ fapServiceLists.add(fapService);
+ }
+ }
+ return fapServiceLists;
+ }
+
+}
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
new file mode 100644
index 0000000..d7ff57a
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.java
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.child;
+
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.onap.dcaegen2.services.sonhms.ConfigPolicy;
+import org.onap.dcaegen2.services.sonhms.model.CellConfig;
+import org.onap.dcaegen2.services.sonhms.model.CellPciPair;
+import org.onap.dcaegen2.services.sonhms.model.Common;
+import org.onap.dcaegen2.services.sonhms.model.Configurations;
+import org.onap.dcaegen2.services.sonhms.model.Data;
+import org.onap.dcaegen2.services.sonhms.model.FapService;
+import org.onap.dcaegen2.services.sonhms.model.Lte;
+import org.onap.dcaegen2.services.sonhms.model.Payload;
+import org.onap.dcaegen2.services.sonhms.model.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 {
+
+ private static final Logger log = org.slf4j.LoggerFactory.getLogger(ChildThreadUtils.class);
+ ConfigPolicy configPolicy;
+
+ public ChildThreadUtils(ConfigPolicy configPolicy) {
+ this.configPolicy = configPolicy;
+ }
+
+
+ /**
+ * get policy notification string from oof result.
+ *
+ */
+ public String getNotificationString(String pnfName, List<CellPciPair> cellPciPairs, String requestId,
+ Long alarmStartTime) {
+ ArrayList<Configurations> configurations = new ArrayList<>();
+ for (CellPciPair cellPciPair : cellPciPairs) {
+ String cellId = cellPciPair.getCellId();
+ int pci = cellPciPair.getPhysicalCellId();
+ Configurations configuration = new Configurations(new Data(new FapService(cellId,
+ new X0005b9Lte(pci, pnfName), new CellConfig(new Lte(new Ran(new Common(cellId)))))));
+ configurations.add(configuration);
+ }
+
+ Payload payload = new Payload(configurations);
+ ObjectMapper mapper = new ObjectMapper();
+ String payloadString = "";
+ try {
+ payloadString = mapper.writeValueAsString(payload);
+ } catch (JsonProcessingException e) {
+ log.debug("JSON processing exception: {}", e);
+ }
+
+ String closedLoopControlName = (String) configPolicy.getConfig().get("PCI_MODCONFIG_POLICY_NAME");
+ PolicyNotification policyNotification = new PolicyNotification(closedLoopControlName,
+ requestId, alarmStartTime, pnfName);
+
+ policyNotification.setClosedLoopControlName(closedLoopControlName);
+ policyNotification.setPayload(payloadString);
+
+ mapper.setSerializationInclusion(Include.NON_NULL);
+ String notification = "";
+ try {
+ notification = mapper.writeValueAsString(policyNotification);
+ } catch (JsonProcessingException e1) {
+ log.debug("JSON processing exception: {}", e1);
+ }
+ return notification;
+ }
+
+}
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
new file mode 100644
index 0000000..9a594a1
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/child/ClusterFormation.java
@@ -0,0 +1,146 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.child;
+
+import org.onap.dcaegen2.services.sonhms.ConfigPolicy;
+import org.onap.dcaegen2.services.sonhms.Configuration;
+import org.onap.dcaegen2.services.sonhms.dao.ClusterDetailsRepository;
+import org.onap.dcaegen2.services.sonhms.entity.ClusterDetails;
+import org.onap.dcaegen2.services.sonhms.model.FapServiceList;
+import org.onap.dcaegen2.services.sonhms.utils.BeanUtil;
+import org.onap.dcaegen2.services.sonhms.utils.ClusterUtils;
+
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.Properties;
+import java.util.UUID;
+import java.util.concurrent.BlockingQueue;
+
+import org.slf4j.Logger;
+
+
+public class ClusterFormation {
+
+ private static final Logger log = org.slf4j.LoggerFactory.getLogger(ClusterFormation.class);
+ private BlockingQueue<FapServiceList> queue;
+ private ClusterUtils clusterUtils;
+ private Detection detect;
+ Properties confProp;
+ ClusterDetails details = new ClusterDetails();
+
+ public ClusterFormation() {
+ this.detect = new Detection();
+ }
+
+ /**
+ * parameterized constructor.
+ *
+ */
+ public ClusterFormation(BlockingQueue<FapServiceList> queue) {
+ super();
+ this.queue = queue;
+ this.detect = new Detection();
+ this.clusterUtils = new ClusterUtils();
+ }
+
+ /**
+ * Determines whether to trigger Oof or wait for notifications.
+ */
+ public Boolean triggerOrWait(Map<String, ArrayList<Integer>> collisionConfusionResult) {
+ // determine collision or confusion
+
+ Configuration configuration = Configuration.getInstance();
+ int collisionSum = 0;
+ int confusionSum = 0;
+
+ for (Map.Entry<String, ArrayList<Integer>> entry : collisionConfusionResult.entrySet()) {
+
+ ArrayList<Integer> arr;
+ arr = entry.getValue();
+ // check for 0 collision and confusion
+ if (!arr.isEmpty()) {
+ collisionSum = collisionSum + arr.get(0);
+ confusionSum = confusionSum + arr.get(1);
+ }
+ }
+ return ((collisionSum >= configuration.getMinCollision()) && (confusionSum >= configuration.getMinConfusion()));
+
+ }
+
+ /**
+ * Waits for notifications.
+ */
+ public Map<String, ArrayList<Integer>> waitForNotification(Map<String, ArrayList<Integer>> collisionConfusionResult,
+ Graph cluster) {
+
+ FapServiceList newNotification;
+ ConfigPolicy config = ConfigPolicy.getInstance();
+ int timer = 60;
+ try {
+ timer = (int) config.getConfig().get("PCI_NEIGHBOR_CHANGE_CLUSTER_TIMEOUT_IN_SECS");
+ } catch (NullPointerException e) {
+ log.debug("Policy config not available. Using default timeout - 60 seconds");
+ }
+
+ Timestamp currentTime = new Timestamp(System.currentTimeMillis());
+ log.debug("Current Time {}", currentTime);
+
+ Timestamp laterTime = new Timestamp(System.currentTimeMillis());
+ log.debug("LaterTime {}", laterTime);
+
+ long difference = laterTime.getTime() - currentTime.getTime();
+
+ int flag = 0;
+
+ while (difference < (timer * 1000)) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ log.error("Interrupted Exception is {}", e);
+ Thread.currentThread().interrupt();
+ }
+
+ laterTime = new Timestamp(System.currentTimeMillis());
+ difference = laterTime.getTime() - currentTime.getTime();
+
+ if ((difference < (timer * 1000)) && (!queue.isEmpty())) {
+ newNotification = queue.poll();
+ cluster = clusterUtils.modifyCluster(cluster, newNotification);
+
+ // update cluster in DB
+ String cellPciNeighbourString = cluster.getPciNeighbourJson();
+ UUID clusterId = cluster.getGraphId();
+ ClusterDetailsRepository clusterDetailsRepository = BeanUtil.getBean(ClusterDetailsRepository.class);
+ clusterDetailsRepository.updateCluster(cellPciNeighbourString, clusterId.toString());
+ flag++;
+
+ }
+ }
+ if (flag != 0) {
+ return detect.detectCollisionConfusion(cluster);
+
+ }
+ return collisionConfusionResult;
+ }
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/child/Detection.java b/src/main/java/org/onap/dcaegen2/services/sonhms/child/Detection.java
new file mode 100644
index 0000000..847e2d5
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/child/Detection.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.child;
+
+import org.onap.dcaegen2.services.sonhms.model.CellPciPair;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.slf4j.Logger;
+
+
+public class Detection {
+
+ private static final Logger log = org.slf4j.LoggerFactory.getLogger(Detection.class);
+
+ /**
+ * Returns a map with key as cellid and its value is a list of its collision and
+ * confusion.
+ */
+
+ public Map<String, ArrayList<Integer>> detectCollisionConfusion(Graph cluster) {
+
+ Map<CellPciPair, ArrayList<CellPciPair>> clusterMap = cluster.getCellPciNeighbourMap();
+ HashMap<String, ArrayList<Integer>> hash = new HashMap<>();
+
+ for (Map.Entry<CellPciPair, ArrayList<CellPciPair>> entry : clusterMap.entrySet()) {
+ int collisionCount = 0;
+ int confusionCount = 0;
+ CellPciPair val = entry.getKey();
+ String cellId = val.getCellId();
+ int pci = val.getPhysicalCellId();
+ ArrayList<CellPciPair> arr;
+ // getting colision and confusion count
+ ArrayList<Integer> counts = new ArrayList<>();
+ // gets the value for the key
+ arr = entry.getValue();
+ if (!arr.isEmpty()) {
+ for (int i = 0; i < arr.size(); i++) {
+ if (pci == arr.get(i).getPhysicalCellId()) {
+ collisionCount++;
+ }
+
+ }
+ counts.add(collisionCount);
+
+ for (int j = 0; j < arr.size(); j++) {
+ for (int k = j + 1; k < arr.size(); k++) {
+ if (arr.get(j).getPhysicalCellId() == arr.get(k).getPhysicalCellId()) {
+ confusionCount++;
+
+ }
+ }
+
+ }
+ counts.add(confusionCount);
+ log.debug("count {}", counts);
+
+ }
+ hash.put(cellId, counts);
+
+ }
+ log.debug("collison and confusion map {}", hash);
+
+ return hash;
+ }
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/child/Graph.java b/src/main/java/org/onap/dcaegen2/services/sonhms/child/Graph.java
new file mode 100644
index 0000000..eedbd94
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/child/Graph.java
@@ -0,0 +1,242 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.child;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.onap.dcaegen2.services.sonhms.model.CellNeighbourList;
+import org.onap.dcaegen2.services.sonhms.model.CellPciPair;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+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.slf4j.Logger;
+
+public class Graph {
+ private static final Logger log = org.slf4j.LoggerFactory.getLogger(Graph.class);
+
+ // symbol table: key = string vertex, value = set of neighboring vertices
+ private Map<CellPciPair, ArrayList<CellPciPair>> cellPciNeighbourMap;
+ private UUID graphId;
+
+ /**
+ * Parameterized constructor.
+ */
+ public Graph(String clusterInfo) {
+ JSONArray cells = new JSONArray(clusterInfo);
+
+ Map<CellPciPair, ArrayList<CellPciPair>> cellMap = new HashMap<>();
+ for (int i = 0; i < cells.length(); i++) {
+ JSONObject cell = (JSONObject) cells.get(i);
+ CellPciPair cellPciPair = new CellPciPair(cell.getString("cellId"), cell.getInt("physicalCellId"));
+ ObjectMapper mapper = new ObjectMapper();
+ ArrayList<CellPciPair> neighbours = new ArrayList<>();
+ try {
+ neighbours = mapper.readValue(cell.getString("neighbours"),
+ new TypeReference<ArrayList<CellPciPair>>() { });
+ } catch (JSONException | IOException e) {
+ log.debug("Error parsing json: {}", e);
+ }
+ cellMap.put(cellPciPair, neighbours);
+
+ }
+
+ this.cellPciNeighbourMap = cellMap;
+ }
+
+ public UUID getGraphId() {
+ return graphId;
+ }
+
+ public void setGraphId(UUID graphId) {
+ this.graphId = graphId;
+ }
+
+ public Map<CellPciPair, ArrayList<CellPciPair>> getCellPciNeighbourMap() {
+ return cellPciNeighbourMap;
+ }
+
+ public void setCellPciNeighbourMap(Map<CellPciPair, ArrayList<CellPciPair>> cellPciNeighbourMap) {
+ this.cellPciNeighbourMap = cellPciNeighbourMap;
+ }
+
+ /**
+ * Initializes an empty graph with no vertices or edges.
+ */
+ public Graph() {
+ this.cellPciNeighbourMap = new ConcurrentHashMap<>();
+ }
+
+ // throw an exception if v is not a vertex
+ private void validateVertex(CellPciPair start) {
+ if (!hasVertex(start)) {
+ throw new IllegalArgumentException(start + " is not a vertex");
+ }
+ }
+
+ /**
+ * Adds the edge v-w to this graph (if it is not already an edge).
+ */
+ public void addEdge(CellPciPair start, CellPciPair end) {
+ if (!hasVertex(start)) {
+ addVertex(start);
+ }
+ if (!hasVertex(end)) {
+ addVertex(end);
+ }
+ if (!hasEdge(start, end)) {
+ this.cellPciNeighbourMap.get(start).add(end);
+ }
+ }
+
+ /**
+ * Adds vertex v to this graph (if it is not already a vertex).
+ */
+ public void addVertex(CellPciPair start) {
+ if (!hasVertex(start)) {
+ this.cellPciNeighbourMap.put(start, new ArrayList<CellPciPair>());
+ }
+ }
+
+ /**
+ * Returns true if v is a vertex in this graph.
+ */
+ public boolean hasVertex(CellPciPair start) {
+ return this.cellPciNeighbourMap.containsKey(start);
+ }
+
+ /**
+ * Returns true if v-w is an edge in this graph.
+ */
+ public boolean hasEdge(CellPciPair start, CellPciPair end) {
+ validateVertex(start);
+ validateVertex(end);
+ return this.cellPciNeighbourMap.get(start).contains(end);
+ }
+
+ /**
+ * Updates Vertex.
+ */
+ public void updateVertex(CellPciPair oldPair, CellPciPair newPair) {
+ int oldPci = oldPair.getPhysicalCellId();
+ int newPci = newPair.getPhysicalCellId();
+
+ if (oldPci != newPci) {
+
+ this.cellPciNeighbourMap.put(newPair, this.cellPciNeighbourMap.get(oldPair));
+ this.cellPciNeighbourMap.remove(oldPair);
+
+ }
+ for (Map.Entry<CellPciPair, ArrayList<CellPciPair>> entry : this.cellPciNeighbourMap.entrySet()) {
+
+ ArrayList<CellPciPair> al = entry.getValue();
+ for (int i = 0; i < al.size(); i++) {
+ int pci = al.get(i).getPhysicalCellId();
+ if ((pci != newPci) && al.contains(oldPair)) {
+ al.remove(oldPair);
+ al.add(newPair);
+ }
+ }
+ }
+ log.debug("Final Map {}", cellPciNeighbourMap);
+
+ }
+
+ @Override
+ public String toString() {
+ return "Graph [cellPciNeighbourMap=" + cellPciNeighbourMap + ", graphId=" + graphId + "]";
+ }
+
+ /**
+ * Convert Graph into a json.
+ */
+ public String getPciNeighbourJson() {
+
+ List<CellNeighbourList> cells = new ArrayList<>();
+
+ for (Entry<CellPciPair, ArrayList<CellPciPair>> entry : cellPciNeighbourMap.entrySet()) {
+ CellPciPair key = entry.getKey();
+ JSONArray neighbours = new JSONArray(cellPciNeighbourMap.get(key));
+ CellNeighbourList cell = new CellNeighbourList(key.getCellId(), key.getPhysicalCellId(),
+ neighbours.toString());
+ cells.add(cell);
+ }
+ ObjectMapper mapper = new ObjectMapper();
+ String pciNeighbourJson = "";
+ try {
+ pciNeighbourJson = mapper.writeValueAsString(cells);
+ } catch (JsonProcessingException e) {
+ log.debug("Error while processing json: {}", e);
+ }
+ return pciNeighbourJson;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((cellPciNeighbourMap == null) ? 0 : cellPciNeighbourMap.hashCode());
+ result = prime * result + ((graphId == null) ? 0 : graphId.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ Graph other = (Graph) obj;
+ if (cellPciNeighbourMap == null) {
+ if (other.cellPciNeighbourMap != null) {
+ return false;
+ }
+ } else if (!cellPciNeighbourMap.equals(other.cellPciNeighbourMap)) {
+ return false;
+ }
+ if (graphId == null) {
+ if (other.graphId != null) {
+ return false;
+ }
+ } else if (!graphId.equals(other.graphId)) {
+ return false;
+ }
+ return true;
+ }
+
+}
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
new file mode 100644
index 0000000..560fd52
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/child/PnfUtils.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.child;
+
+import org.onap.dcaegen2.services.sonhms.dao.CellInfoRepository;
+import org.onap.dcaegen2.services.sonhms.entity.CellInfo;
+import org.onap.dcaegen2.services.sonhms.exceptions.ConfigDbNotFoundException;
+import org.onap.dcaegen2.services.sonhms.model.CellPciPair;
+import org.onap.dcaegen2.services.sonhms.restclient.SdnrRestClient;
+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 {
+
+ /**
+ * get pnfs.
+ *
+ */
+ public Map<String, List<CellPciPair>> getPnfs(List<Solution> solutions) throws ConfigDbNotFoundException {
+
+ Map<String, List<CellPciPair>> pnfs = new HashMap<>();
+
+ for (Solution solution : solutions) {
+ List<SonSolution> pciSolutions = solution.getPciSolutions();
+ for (SonSolution pciSolution : pciSolutions) {
+ String cellId = pciSolution.getCellId();
+ int pci = pciSolution.getPci();
+
+ String pnfName = "";
+ CellInfoRepository cellInfoRepository = BeanUtil.getBean(CellInfoRepository.class);
+ Optional<CellInfo> cellInfo = cellInfoRepository.findById(cellId);
+ if (cellInfo.isPresent()) {
+ pnfName = cellInfo.get().getPnfName();
+ } else {
+ pnfName = SdnrRestClient.getPnfName(cellId);
+ cellInfoRepository.save(new CellInfo(cellId, pnfName));
+ }
+ if (pnfs.containsKey(pnfName)) {
+ pnfs.get(pnfName).add(new CellPciPair(cellId, pci));
+ } else {
+ List<CellPciPair> cellPciPairs = new ArrayList<>();
+ cellPciPairs.add(new CellPciPair(cellId, pci));
+ pnfs.put(pnfName, cellPciPairs);
+ }
+ }
+
+ }
+ return pnfs;
+ }
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/child/StateOof.java b/src/main/java/org/onap/dcaegen2/services/sonhms/child/StateOof.java
new file mode 100644
index 0000000..d731725
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/child/StateOof.java
@@ -0,0 +1,193 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.child;
+
+import org.onap.dcaegen2.services.sonhms.ConfigPolicy;
+import org.onap.dcaegen2.services.sonhms.Configuration;
+import org.onap.dcaegen2.services.sonhms.dao.SonRequestsRepository;
+import org.onap.dcaegen2.services.sonhms.dmaap.PolicyDmaapClient;
+import org.onap.dcaegen2.services.sonhms.entity.PciRequests;
+import org.onap.dcaegen2.services.sonhms.exceptions.ConfigDbNotFoundException;
+import org.onap.dcaegen2.services.sonhms.exceptions.OofNotFoundException;
+import org.onap.dcaegen2.services.sonhms.model.CellPciPair;
+import org.onap.dcaegen2.services.sonhms.restclient.AsyncResponseBody;
+import org.onap.dcaegen2.services.sonhms.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 {
+ private static final Logger log = org.slf4j.LoggerFactory.getLogger(StateOof.class);
+ private BlockingQueue<List<String>> childStatusUpdate;
+
+ public StateOof() {
+
+ }
+
+ /**
+ * Parameterized Constructor.
+ *
+ */
+ public StateOof(BlockingQueue<List<String>> childStatusUpdate) {
+ super();
+ this.childStatusUpdate = childStatusUpdate;
+ }
+
+ /**
+ * Triggers OOF.
+ * @throws OofNotFoundException when trigger oof fails
+ */
+ public void triggerOof(Map<String, ArrayList<Integer>> result,
+ String networkId) throws OofNotFoundException, InterruptedException {
+ // check for 0 collision and 0 confusion
+ ArrayList<String> cellidList = new ArrayList<>();
+ ArrayList<String> cellIds = new ArrayList<>();
+
+ for (Map.Entry<String, ArrayList<Integer>> entry : result.entrySet()) {
+ String key = entry.getKey();
+ ArrayList<Integer> arr;
+ arr = entry.getValue();
+ if (!arr.isEmpty()) {
+ Set<Integer> set = new HashSet<>(arr);
+ if (((set.size() == 1) && !set.contains(0)) || (set.size() != 1)) {
+ cellIds.add(key);
+
+ }
+ }
+
+ }
+
+ for (String cell : cellIds) {
+ log.debug("cellidList entries: {}", cell);
+ cellidList.add(cell);
+ }
+ log.debug("the cells triggering the oof are {}", cellidList);
+
+ UUID transactionId = UUID.randomUUID();
+
+ Configuration config = Configuration.getInstance();
+ int numSolutions = config.getNumSolutions();
+ List<String> optimizers = config.getOptimizers();
+
+ String oofResponse = OofRestClient.queryOof(numSolutions, transactionId.toString(), "create", cellidList,
+ networkId, optimizers);
+ log.debug("Synchronous Response {}", oofResponse);
+
+ List<String> childStatus = new ArrayList<>();
+ childStatus.add(Long.toString(Thread.currentThread().getId()));
+ childStatus.add("triggeredOof");
+ try {
+ childStatusUpdate.put(childStatus);
+ } catch (InterruptedException e1) {
+ log.debug("Interrupted execption {}", e1);
+ Thread.currentThread().interrupt();
+
+ }
+
+ // Store Request details in Database
+
+ PciRequests pciRequest = new PciRequests();
+
+ long childThreadId = Thread.currentThread().getId();
+ pciRequest.setTransactionId(transactionId.toString());
+ pciRequest.setChildThreadId(childThreadId);
+ SonRequestsRepository pciRequestsRepository = BeanUtil.getBean(SonRequestsRepository.class);
+ pciRequestsRepository.save(pciRequest);
+
+ while (!ChildThread.getResponseMap().containsKey(childThreadId)) {
+ Thread.sleep(100);
+ }
+
+ AsyncResponseBody asynResponseBody = ChildThread.getResponseMap().get(childThreadId);
+
+ try {
+ sendToPolicy(asynResponseBody);
+ } catch (ConfigDbNotFoundException e1) {
+ log.debug("Config DB is unreachable: {}", e1);
+ }
+
+ pciRequestsRepository = BeanUtil.getBean(SonRequestsRepository.class);
+ pciRequestsRepository.deleteByChildThreadId(childThreadId);
+
+ childStatus = new ArrayList<>();
+ childStatus.add(Long.toString(Thread.currentThread().getId()));
+ childStatus.add("success");
+ try {
+ childStatusUpdate.put(childStatus);
+ } catch (InterruptedException e) {
+ log.debug("InterruptedException {}", e);
+ Thread.currentThread().interrupt();
+
+ }
+
+ }
+
+ /**
+ * Sends Dmaap notification to Policy.
+ *
+ * @throws ConfigDbNotFoundException
+ * when config db is unreachable
+ */
+ private void sendToPolicy(AsyncResponseBody async) throws ConfigDbNotFoundException {
+
+ if (log.isDebugEnabled()) {
+ log.debug(async.toString());
+ }
+
+ List<Solution> solutions;
+ solutions = async.getSolutions();
+
+ PnfUtils pnfUtils = new PnfUtils();
+ Map<String, List<CellPciPair>> pnfs = pnfUtils.getPnfs(solutions);
+
+ for (Map.Entry<String, List<CellPciPair>> entry : pnfs.entrySet()) {
+ String pnfName = entry.getKey();
+ List<CellPciPair> cellPciPairs = entry.getValue();
+
+ ChildThreadUtils childThreadUtils = new ChildThreadUtils(ConfigPolicy.getInstance());
+ String notification = childThreadUtils.getNotificationString(pnfName, cellPciPairs,
+ UUID.randomUUID().toString(), System.currentTimeMillis());
+ log.debug("Policy Notification: {}", notification);
+ PolicyDmaapClient policy = new PolicyDmaapClient();
+ boolean status = policy.sendNotificationToPolicy(notification);
+ log.debug("sent Message: {}", status);
+ if (status) {
+ log.debug("Message sent to policy");
+ } else {
+ log.debug("Sending notification to policy failed");
+ }
+
+ }
+ }
+
+
+
+}
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
new file mode 100644
index 0000000..d0d9321
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/controller/HealthCheck.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * ============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 org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+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);
+ }
+}
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
new file mode 100644
index 0000000..43bb1f3
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dao/BufferedNotificationsRepository.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.dao;
+
+import org.onap.dcaegen2.services.sonhms.entity.BufferedNotifications;
+
+import java.util.List;
+
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.CrudRepository;
+import org.springframework.stereotype.Repository;
+
+
+@Repository
+public interface BufferedNotificationsRepository extends CrudRepository<BufferedNotifications, String> {
+
+ @Query(nativeQuery = true, value = "SELECT cluster_id FROM buffered_notifications WHERE notification=?1")
+ public String getClusterIdForNotification(String notification);
+
+ @Query(nativeQuery = true,
+ value = "DELETE FROM buffered_notifications " + "WHERE notification = ( SELECT notification "
+ + "FROM buffered_notifications WHERE cluster_id=?1) RETURNING notification;")
+ public List<String> getNotificationsFromQueue(String clusterId);
+
+}
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
new file mode 100644
index 0000000..80066ad
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dao/CellInfoRepository.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * ============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.CellInfo;
+
+import org.springframework.data.repository.CrudRepository;
+import org.springframework.stereotype.Repository;
+
+
+@Repository
+public interface CellInfoRepository extends CrudRepository<CellInfo, String> {
+
+ // public void
+
+}
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
new file mode 100644
index 0000000..babef00
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dao/ClusterDetailsRepository.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.dao;
+
+import org.onap.dcaegen2.services.sonhms.entity.ClusterDetails;
+
+import java.util.List;
+
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.CrudRepository;
+import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.Transactional;
+
+
+@Repository
+@Transactional
+public interface ClusterDetailsRepository extends CrudRepository<ClusterDetails, String> {
+
+ @Modifying
+ @Query(nativeQuery = true, value = "UPDATE CLUSTER_DETAILS SET cluster_info=?1 WHERE cluster_id = ?2")
+ public void updateCluster(String clusterInfo, String clusterId);
+
+ @Query(nativeQuery = true, value = "SELECT * FROM cluster_details")
+ public List<ClusterDetails> getAllClusterDetails();
+
+ @Query(nativeQuery = true, value = "SELECT child_thread_id FROM cluster_details WHERE cluster_id = ?1")
+ public long getChildThreadForCluster(String clusterId);
+
+ @Query(nativeQuery = true, value = "SELECT cluster_id FROM cluster_details WHERE child_thread_id = ?1")
+ public String getClusterIdForChildThread(long childThreadId);
+
+ @Modifying
+ @Query(nativeQuery = true, value = "DELETE FROM cluster_details WHERE child_thread_id = ?1")
+ public void deleteByChildThreadId(Long threadId);
+
+ @Modifying
+ @Query(nativeQuery = true, value = "UPDATE cluster_details SET child_thread_id = ?2 WHERE cluster_id = ?1")
+ public void updateThreadId(String clusterId, Long threadId);
+
+}
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
new file mode 100644
index 0000000..356dca6
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dao/DmaapNotificationsRepository.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * ============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.DmaapNotifications;
+
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.CrudRepository;
+import org.springframework.stereotype.Repository;
+
+
+@Repository
+public interface DmaapNotificationsRepository extends CrudRepository<DmaapNotifications, String> {
+
+ @Query(nativeQuery = true,
+ value = "DELETE FROM dmaap_notifications "
+ + "WHERE notification = ( SELECT notification FROM dmaap_notifications ORDER BY "
+ + "created_at FOR UPDATE SKIP LOCKED LIMIT 1 ) RETURNING notification;")
+
+ public String getNotificationFromQueue();
+
+}
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
new file mode 100644
index 0000000..b54661b
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dao/SonRequestsRepository.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.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;
+import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.Transactional;
+
+
+@Repository
+@Transactional
+public interface SonRequestsRepository extends CrudRepository<PciRequests, String> {
+
+ @Query(nativeQuery = true, value = "SELECT child_thread_id FROM pci_requests WHERE transaction_id = ?1")
+ public long getChildThreadMapping(String transactionId);
+
+ @Modifying
+ @Query(nativeQuery = true, value = "DELETE FROM pci_requests WHERE child_thread_id = ?1")
+ public void deleteByChildThreadId(Long threadId);
+
+}
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
new file mode 100644
index 0000000..002f835
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/DmaapClient.java
@@ -0,0 +1,215 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.dmaap;
+
+import 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 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.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class DmaapClient {
+
+ @Autowired
+ private DmaapNotificationsRepository dmaapNotificationsRepository;
+ private Configuration configuration;
+ private static Logger log = LoggerFactory.getLogger(DmaapClient.class);
+ 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();
+ }
+
+}
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
new file mode 100644
index 0000000..ba6b83d
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationConsumer.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.dmaap;
+
+import com.att.nsa.cambria.client.CambriaConsumer;
+import org.onap.dcaegen2.services.sonhms.dmaap.DmaapClient.NotificationCallback;
+
+import java.io.IOException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NotificationConsumer implements Runnable {
+
+ private static Logger log = LoggerFactory.getLogger(NotificationConsumer.class);
+ private CambriaConsumer cambriaConsumer;
+ private NotificationCallback notificationCallback;
+
+ /**
+ * Parameterized Constructor.
+ */
+ public NotificationConsumer(CambriaConsumer cambriaConsumer, NotificationCallback notificationCallback) {
+ super();
+ this.cambriaConsumer = cambriaConsumer;
+ this.notificationCallback = notificationCallback;
+ }
+
+ @Override
+ public void run() {
+ try {
+ Iterable<String> msgs = cambriaConsumer.fetch();
+ for (String msg : msgs) {
+ log.debug(msg);
+ notificationCallback.activateCallBack(msg);
+ }
+ } catch (IOException e) {
+ log.debug("exception when fetching msgs from dmaap", e);
+ }
+
+ }
+}
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
new file mode 100644
index 0000000..e1db372
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationProducer.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.dmaap;
+
+import com.att.nsa.cambria.client.CambriaBatchingPublisher;
+import java.io.IOException;
+import java.security.GeneralSecurityException;
+
+public class NotificationProducer {
+
+ private CambriaBatchingPublisher cambriaBatchingPublisher;
+
+
+ /**
+ * Parameterised constructor.
+ */
+ public NotificationProducer(CambriaBatchingPublisher cambriaBatchingPublisher) {
+ super();
+ this.cambriaBatchingPublisher = cambriaBatchingPublisher;
+ }
+
+ /**
+ * sends notification to dmaap.
+ */
+ public int sendNotification(String msg) throws GeneralSecurityException, IOException {
+
+ int result = cambriaBatchingPublisher.send("", msg);
+ System.out.println(result);
+ return result;
+
+ }
+
+}
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
new file mode 100644
index 0000000..4d5d23b
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyDmaapClient.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.dmaap;
+
+import com.att.nsa.cambria.client.CambriaBatchingPublisher;
+import com.att.nsa.cambria.client.CambriaClientBuilders.PublisherBuilder;
+import org.onap.dcaegen2.services.sonhms.Configuration;
+
+import java.io.IOException;
+import java.security.GeneralSecurityException;
+
+public class PolicyDmaapClient {
+
+
+ /**
+ * 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;
+ }
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/entity/BufferedNotifications.java b/src/main/java/org/onap/dcaegen2/services/sonhms/entity/BufferedNotifications.java
new file mode 100644
index 0000000..34cce77
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/entity/BufferedNotifications.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.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 = "BUFFERED_NOTIFICATIONS")
+public class BufferedNotifications {
+
+ @Id
+ @Column(name = "notification", columnDefinition = "text")
+ private String notification;
+
+ @Column(name = "cluster_id", columnDefinition = "text")
+ private String clusterId;
+
+ @CreationTimestamp
+ @Column(name = "created_at", columnDefinition = "timestamp")
+ private Timestamp createdAt;
+
+ public BufferedNotifications() {
+
+ }
+
+ /**
+ * Parameterised constructor.
+ */
+ public BufferedNotifications(String notification, Timestamp createdAt, String clusterId) {
+ this.notification = notification;
+ this.createdAt = createdAt;
+ this.clusterId = clusterId;
+ }
+
+ public String getNotification() {
+ return notification;
+ }
+
+ public void setNotification(String notification) {
+ this.notification = notification;
+ }
+
+ public String getClusterId() {
+ return clusterId;
+ }
+
+ public void setClusterId(String clusterId) {
+ this.clusterId = clusterId;
+ }
+
+ public Timestamp getCreatedAt() {
+ return createdAt;
+ }
+
+ public void setCreatedAt(Timestamp createdAt) {
+ this.createdAt = createdAt;
+ }
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/entity/CellInfo.java b/src/main/java/org/onap/dcaegen2/services/sonhms/entity/CellInfo.java
new file mode 100644
index 0000000..0c546d6
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/entity/CellInfo.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.entity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "CELL_INFO")
+public class CellInfo {
+
+ @Id
+ @Column(name = "CELL_ID")
+ private String cellId;
+
+ @Column(name = "PNF_NAME")
+ private String pnfName;
+
+ public CellInfo() {
+
+ }
+
+ /**
+ * CellIdPnf Constructor.
+ */
+
+ public CellInfo(String cellId, String pnfName) {
+ super();
+ this.cellId = cellId;
+ this.pnfName = pnfName;
+ }
+
+ public String getCellId() {
+ return cellId;
+ }
+
+ public void setCellId(String cellId) {
+ this.cellId = cellId;
+ }
+
+ public String getPnfName() {
+ return pnfName;
+ }
+
+ public void setPnfName(String pnfName) {
+ this.pnfName = pnfName;
+ }
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/entity/ClusterDetails.java b/src/main/java/org/onap/dcaegen2/services/sonhms/entity/ClusterDetails.java
new file mode 100644
index 0000000..37dc5bd
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/entity/ClusterDetails.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.entity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "CLUSTER_DETAILS")
+public class ClusterDetails {
+
+ @Id
+ @Column(name = "CLUSTER_ID")
+ private String clusterId;
+
+ @Column(name = "CLUSTER_INFO")
+ private String clusterInfo;
+
+ @Column(name = "CHILD_THREAD_ID")
+ private long childThreadId;
+
+ public ClusterDetails() {
+
+ }
+
+ /**
+ * Parameterised constructor.
+ */
+ public ClusterDetails(String clusterId, String clusterInfo, long childThreadId) {
+ super();
+ this.clusterId = clusterId;
+ this.clusterInfo = clusterInfo;
+ this.childThreadId = childThreadId;
+ }
+
+ public long getChildThreadId() {
+ return childThreadId;
+ }
+
+ public void setChildThreadId(long childThreadId) {
+ this.childThreadId = childThreadId;
+ }
+
+ public String getClusterId() {
+ return clusterId;
+ }
+
+ public void setClusterId(String clusterId) {
+ this.clusterId = clusterId;
+ }
+
+ public String getClusterInfo() {
+ return clusterInfo;
+ }
+
+ public void setClusterInfo(String clusterInfo) {
+ this.clusterInfo = clusterInfo;
+ }
+
+ @Override
+ public String toString() {
+ return "ClusterDetails [clusterId=" + clusterId + ", clusterInfo=" + clusterInfo + ", childThreadId="
+ + childThreadId + "]";
+ }
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/entity/DmaapNotifications.java b/src/main/java/org/onap/dcaegen2/services/sonhms/entity/DmaapNotifications.java
new file mode 100644
index 0000000..2e30efc
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/entity/DmaapNotifications.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.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 = "DMAAP_NOTIFICATIONS")
+public class DmaapNotifications {
+
+ @Id
+ @Column(name = "notification", columnDefinition = "text")
+ private String notification;
+
+ @CreationTimestamp
+ @Column(name = "created_at", columnDefinition = "timestamp")
+ private Timestamp createdAt;
+
+ public DmaapNotifications() {
+
+ }
+
+ public DmaapNotifications(String notification, Timestamp createdAt) {
+ this.notification = notification;
+ this.createdAt = createdAt;
+ }
+
+ public String getNotification() {
+ return notification;
+ }
+
+ public void setNotification(String notification) {
+ this.notification = notification;
+ }
+
+ public Timestamp getCreatedAt() {
+ return createdAt;
+ }
+
+ public void setCreatedAt(Timestamp createdAt) {
+ this.createdAt = createdAt;
+ }
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/entity/PciRequests.java b/src/main/java/org/onap/dcaegen2/services/sonhms/entity/PciRequests.java
new file mode 100644
index 0000000..79120ee
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/entity/PciRequests.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 javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "PCI_REQUESTS")
+public class PciRequests {
+
+ @Id
+ @Column(name = "TRANSACTION_ID")
+ private String transactionId;
+
+ @Column(name = "CHILD_THREAD_ID")
+ private long childThreadId;
+
+ public PciRequests() {
+
+ }
+
+ /**
+ * Parameterised constructor.
+ */
+ public PciRequests(String transactionId, long childThreadId) {
+ super();
+ this.transactionId = transactionId;
+ this.childThreadId = childThreadId;
+ }
+
+ public String getTransactionId() {
+ return transactionId;
+ }
+
+ public void setTransactionId(String transactionId) {
+ this.transactionId = transactionId;
+ }
+
+ public long getChildThreadId() {
+ return childThreadId;
+ }
+
+ public void setChildThreadId(long childThreadId) {
+ this.childThreadId = childThreadId;
+ }
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/exceptions/ConfigDbNotFoundException.java b/src/main/java/org/onap/dcaegen2/services/sonhms/exceptions/ConfigDbNotFoundException.java
new file mode 100644
index 0000000..e1f040b
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/exceptions/ConfigDbNotFoundException.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * ============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.exceptions;
+
+public class ConfigDbNotFoundException extends Exception {
+
+ /**
+ * serial version.
+ */
+ private static final long serialVersionUID = 1L;
+
+ public ConfigDbNotFoundException(String message) {
+ super(message);
+ }
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/exceptions/OofNotFoundException.java b/src/main/java/org/onap/dcaegen2/services/sonhms/exceptions/OofNotFoundException.java
new file mode 100644
index 0000000..0bbeff3
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/exceptions/OofNotFoundException.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * ============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.exceptions;
+
+public class OofNotFoundException extends Exception {
+ /**
+ * serial version.
+ */
+ private static final long serialVersionUID = 1L;
+
+ public OofNotFoundException(String message) {
+ super(message);
+ }
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/CellConfig.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/CellConfig.java
new file mode 100644
index 0000000..1f4f62e
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/CellConfig.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class CellConfig {
+
+ @JsonProperty(value = "LTE")
+ private Lte lte;
+
+ public CellConfig() {
+
+ }
+
+ public CellConfig(Lte lte) {
+ super();
+ this.lte = lte;
+ }
+
+ public Lte getLte() {
+ return lte;
+ }
+
+ public void setLte(Lte lte) {
+ this.lte = lte;
+ }
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/CellNeighbourList.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/CellNeighbourList.java
new file mode 100644
index 0000000..18fdac4
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/CellNeighbourList.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.model;
+
+public class CellNeighbourList {
+
+ private String cellId;
+ private int physicalCellId;
+ private String neighbours;
+
+ public String getCellId() {
+ return cellId;
+ }
+
+ public void setCellId(String cellId) {
+ this.cellId = cellId;
+ }
+
+ public int getPhysicalCellId() {
+ return physicalCellId;
+ }
+
+ public void setPhysicalCellId(int physicalCellId) {
+ this.physicalCellId = physicalCellId;
+ }
+
+ public String getNeighbours() {
+ return neighbours;
+ }
+
+ public void setNeighbours(String neighbours) {
+ this.neighbours = neighbours;
+ }
+
+ /**
+ * constructor.
+ */
+ public CellNeighbourList() {
+
+ }
+
+ /**
+ * Parameterized constructor.
+ */
+ public CellNeighbourList(String cellId, int physicalCellId, String neighbours) {
+ super();
+ this.cellId = cellId;
+ this.physicalCellId = physicalCellId;
+ this.neighbours = neighbours;
+ }
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/CellPciPair.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/CellPciPair.java
new file mode 100644
index 0000000..866c51e
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/CellPciPair.java
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class CellPciPair {
+ @JsonProperty("cellId")
+ private String cellId;
+
+ @JsonProperty("physicalCellId")
+ private int physicalCellId;
+
+ @Override
+ public String toString() {
+ return "CellPciPair [cellId=" + cellId + ", physicalCellId=" + physicalCellId + "]";
+ }
+
+ public CellPciPair() {
+
+ }
+
+ /**
+ * Parameterized constructor.
+ */
+ public CellPciPair(String cellId, int physicalCellId) {
+ super();
+ this.cellId = cellId;
+ this.physicalCellId = physicalCellId;
+ }
+
+ public String getCellId() {
+ return cellId;
+ }
+
+ public void setCellId(String cellId) {
+ this.cellId = cellId;
+ }
+
+ public int getPhysicalCellId() {
+ return physicalCellId;
+ }
+
+ public void setPhysicalCellId(int physicalCellId) {
+ this.physicalCellId = physicalCellId;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = (prime * result) + ((cellId == null) ? 0 : cellId.hashCode());
+ result = (prime * result) + physicalCellId;
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ CellPciPair other = (CellPciPair) obj;
+ if (cellId == null) {
+ if (other.cellId != null) {
+ return false;
+ }
+ } else if (!cellId.equals(other.cellId)) {
+ return false;
+ }
+ return (physicalCellId == other.physicalCellId);
+ }
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/Common.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Common.java
new file mode 100644
index 0000000..8a54f76
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Common.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class Common {
+
+ @JsonProperty(value = "CellIdentity")
+ private String cellIdentity;
+
+ public Common() {
+
+ }
+
+ public Common(String cellIdentity) {
+ super();
+ this.cellIdentity = cellIdentity;
+ }
+
+ public String getCellIdentity() {
+ return cellIdentity;
+ }
+
+ public void setCellIdentity(String cellIdentity) {
+ this.cellIdentity = cellIdentity;
+ }
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/Configurations.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Configurations.java
new file mode 100644
index 0000000..e043aaf
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Configurations.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class Configurations {
+ @JsonProperty("data")
+ private Data data;
+
+ /**
+ * constructor.
+ *
+ */
+ public Configurations() {
+
+ }
+
+ /**
+ * Parameterized constructor.
+ *
+ */
+ public Configurations(Data data) {
+ super();
+ this.data = data;
+ }
+
+ public Data getData() {
+ return data;
+ }
+
+ public void setData(Data data) {
+ this.data = data;
+ }
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/Data.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Data.java
new file mode 100644
index 0000000..43b6204
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Data.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class Data {
+
+ @JsonProperty("FAPService")
+ private FapService fapservice;
+
+ public Data() {
+
+ }
+
+ public Data(FapService fapservice) {
+ super();
+ this.fapservice = fapservice;
+ }
+
+ public FapService getFapservice() {
+ return fapservice;
+ }
+
+ public void setFapservice(FapService fapservice) {
+ this.fapservice = fapservice;
+ }
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/FapService.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/FapService.java
new file mode 100644
index 0000000..90b6f23
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/FapService.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class FapService {
+
+ @JsonProperty("alias")
+ private String alias;
+
+ @JsonProperty("X0005b9Lte")
+ private X0005b9Lte x0005b9Lte;
+
+ @JsonProperty("CellConfig")
+ private CellConfig cellConfig;
+
+ public FapService() {
+
+ }
+
+ /**
+ * Parameterized constructor.
+ */
+ public FapService(String alias, X0005b9Lte x0005b9Lte, CellConfig cellConfig) {
+ super();
+ this.alias = alias;
+ this.x0005b9Lte = x0005b9Lte;
+ this.cellConfig = cellConfig;
+ }
+
+ public String getAlias() {
+ return alias;
+ }
+
+ public void setAlias(String alias) {
+ this.alias = alias;
+ }
+
+ public CellConfig getCellConfig() {
+ return cellConfig;
+ }
+
+ public void setCellConfig(CellConfig cellConfig) {
+ this.cellConfig = cellConfig;
+ }
+
+ public X0005b9Lte getX0005b9Lte() {
+ return x0005b9Lte;
+ }
+
+ public void setX0005b9Lte(X0005b9Lte x0005b9Lte) {
+ this.x0005b9Lte = x0005b9Lte;
+ }
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/FapServiceList.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/FapServiceList.java
new file mode 100644
index 0000000..1e38927
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/FapServiceList.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class FapServiceList {
+
+ @Override
+ public String toString() {
+ return "FapServiceList [alias=" + alias + ", x0005b9Lte=" + x0005b9Lte + ", cellConfig=" + cellConfig + "]";
+ }
+
+ @JsonProperty("alias")
+ private String alias;
+
+ @JsonProperty("X0005b9Lte")
+ private X0005b9Lte x0005b9Lte;
+
+ @JsonProperty("CellConfig")
+ private NotificationCellConfig cellConfig;
+
+ public FapServiceList() {
+
+ }
+
+ /**
+ * Parameterized Constructor.
+ */
+
+ public FapServiceList(String alias, X0005b9Lte x0005b9Lte, NotificationCellConfig cellConfig) {
+ super();
+ this.alias = alias;
+ this.x0005b9Lte = x0005b9Lte;
+ this.cellConfig = cellConfig;
+ }
+
+ public String getAlias() {
+ return alias;
+ }
+
+ public void setAlias(String alias) {
+ this.alias = alias;
+ }
+
+ public X0005b9Lte getX0005b9Lte() {
+ return x0005b9Lte;
+ }
+
+ public void setX0005b9Lte(X0005b9Lte x0005b9Lte) {
+ this.x0005b9Lte = x0005b9Lte;
+ }
+
+ public NotificationCellConfig getCellConfig() {
+ return cellConfig;
+ }
+
+ public void setCellConfig(NotificationCellConfig cellConfig) {
+ this.cellConfig = cellConfig;
+ }
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/Lte.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Lte.java
new file mode 100644
index 0000000..4ba5537
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Lte.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class Lte {
+
+ @JsonProperty(value = "RAN")
+ private Ran ran;
+
+ public Lte() {
+
+ }
+
+ public Lte(Ran ran) {
+ super();
+ this.ran = ran;
+ }
+
+ public Ran getRan() {
+ return ran;
+ }
+
+ public void setRan(Ran ran) {
+ this.ran = ran;
+ }
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/LteNeighborListInUseLteCell.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/LteNeighborListInUseLteCell.java
new file mode 100644
index 0000000..961e5f0
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/LteNeighborListInUseLteCell.java
@@ -0,0 +1,136 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class LteNeighborListInUseLteCell {
+ @JsonProperty("pnfName")
+ private String pnfName;
+
+ @JsonProperty("enable")
+ private String enable;
+
+ @JsonProperty("alias")
+ private String alias;
+
+ @JsonProperty("mustInclude")
+ private String mustInclude;
+
+ @JsonProperty("plmnid")
+ private String plmnId;
+
+ @JsonProperty("cid")
+ private String cid;
+
+ @JsonProperty("phyCellId")
+ private int phyCellId;
+
+ @JsonProperty("blacklisted")
+ private String blacklisted;
+
+ public LteNeighborListInUseLteCell() {
+
+ }
+
+ /**
+ * Parameterized Constructor.
+ */
+
+ public LteNeighborListInUseLteCell(String pnfName, String enable, String alias, String mustInclude, String plmnId,
+ String cid, int phyCellId, String blacklisted) {
+ super();
+ this.pnfName = pnfName;
+ this.enable = enable;
+ this.alias = alias;
+ this.mustInclude = mustInclude;
+ this.plmnId = plmnId;
+ this.cid = cid;
+ this.phyCellId = phyCellId;
+ this.blacklisted = blacklisted;
+ }
+
+ public String getMustInclude() {
+ return mustInclude;
+ }
+
+ public void setMustInclude(String mustInclude) {
+ this.mustInclude = mustInclude;
+ }
+
+ public int getPhyCellId() {
+ return phyCellId;
+ }
+
+ public void setPhyCellId(int phyCellId) {
+ this.phyCellId = phyCellId;
+ }
+
+ public String getAlias() {
+ return alias;
+ }
+
+ public void setAlias(String alias) {
+ this.alias = alias;
+ }
+
+ public String getEnable() {
+ return enable;
+ }
+
+ public void setEnable(String enable) {
+ this.enable = enable;
+ }
+
+ public String getBlacklisted() {
+ return blacklisted;
+ }
+
+ public void setBlacklisted(String blacklisted) {
+ this.blacklisted = blacklisted;
+ }
+
+ public String getCid() {
+ return cid;
+ }
+
+ public void setCid(String cid) {
+ this.cid = cid;
+ }
+
+ public String getPnfName() {
+ return pnfName;
+ }
+
+ public void setPnfName(String pnfName) {
+ this.pnfName = pnfName;
+ }
+
+ public String getPlmnid() {
+ return plmnId;
+ }
+
+ public void setPlmnid(String plmnId) {
+ this.plmnId = plmnId;
+ }
+
+}
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
new file mode 100644
index 0000000..50df1d8
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/NeighborListInUse.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.List;
+
+public class NeighborListInUse {
+ @JsonProperty("LTENeighborListInUseLTECell")
+ private List<LteNeighborListInUseLteCell> lteNeighborListInUseLteCell;
+
+ @JsonProperty("LTECellNumberOfEntries")
+ private String lteCellNumberOfEntries;
+
+ public NeighborListInUse() {
+
+ }
+
+ /**
+ * Parameterized Constructor.
+ */
+
+ public NeighborListInUse(List<LteNeighborListInUseLteCell> lteNeighborListInUseLteCell,
+ String lteCellNumberOfEntries) {
+ super();
+ this.lteNeighborListInUseLteCell = lteNeighborListInUseLteCell;
+ this.lteCellNumberOfEntries = lteCellNumberOfEntries;
+ }
+
+ public List<LteNeighborListInUseLteCell> getLteNeighborListInUseLteCell() {
+ return lteNeighborListInUseLteCell;
+ }
+
+ public void setLteNeighborListInUseLteCell(List<LteNeighborListInUseLteCell> lteNeighborListInUseLteCell) {
+ this.lteNeighborListInUseLteCell = lteNeighborListInUseLteCell;
+ }
+
+ public String getLteCellNumberOfEntries() {
+ return lteCellNumberOfEntries;
+ }
+
+ public void setLteCellNumberOfEntries(String lteCellNumberOfEntries) {
+ this.lteCellNumberOfEntries = lteCellNumberOfEntries;
+ }
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/Notification.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Notification.java
new file mode 100644
index 0000000..f74896a
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Notification.java
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class Notification {
+
+ @JsonProperty("requestID")
+ private String requestId;
+
+ @JsonProperty("AAI")
+ private Object aai;
+
+ @JsonProperty("from")
+ private String from;
+
+ @JsonProperty("version")
+ private String version;
+
+ @JsonProperty("Action")
+ private String action;
+
+ @JsonProperty("Payload")
+ private NotificationPayload payload;
+
+ public Notification() {
+
+ }
+
+ /**
+ * Parameterized Constructor.
+ */
+
+ public Notification(String requestId, Object aai, String from, String version, String action,
+ NotificationPayload payload) {
+ super();
+ this.requestId = requestId;
+ this.aai = aai;
+ this.from = from;
+ this.version = version;
+ this.action = action;
+ this.payload = payload;
+ }
+
+ public NotificationPayload getPayload() {
+ return payload;
+ }
+
+ public void setPayload(NotificationPayload payload) {
+ this.payload = payload;
+ }
+
+ public String getAction() {
+ return action;
+ }
+
+ public void setAction(String action) {
+ this.action = action;
+ }
+
+ public String getRequestId() {
+ return requestId;
+ }
+
+ public void setRequestId(String requestId) {
+ this.requestId = requestId;
+ }
+
+ public String getFrom() {
+ return from;
+ }
+
+ public void setFrom(String from) {
+ this.from = from;
+ }
+
+ public Object getAai() {
+ return aai;
+ }
+
+ public void setAai(Object aai) {
+ this.aai = aai;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ @Override
+ public String toString() {
+ return "Notification [requestId=" + requestId + ", aai=" + aai + ", from=" + from + ", version=" + version
+ + ", action=" + action + ", payload=" + payload + "]";
+ }
+
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/NotificationCellConfig.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/NotificationCellConfig.java
new file mode 100644
index 0000000..aa771fe
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/NotificationCellConfig.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class NotificationCellConfig {
+
+ @JsonProperty("LTE")
+ private NotificationLte lte;
+
+ public NotificationCellConfig() {
+
+ }
+
+ /**
+ * Parameterized Constructor.
+ */
+
+ public NotificationCellConfig(NotificationLte lte) {
+ super();
+ this.lte = lte;
+ }
+
+ public NotificationLte getLte() {
+ return lte;
+ }
+
+ public void setLte(NotificationLte lte) {
+ this.lte = lte;
+ }
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/NotificationLte.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/NotificationLte.java
new file mode 100644
index 0000000..584db11
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/NotificationLte.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class NotificationLte {
+
+ @JsonProperty("RAN")
+ private NotificationRan ran;
+
+ public NotificationLte() {
+
+ }
+
+ /**
+ * Parameterized Constructor.
+ */
+
+ public NotificationLte(NotificationRan ran) {
+ super();
+ this.ran = ran;
+ }
+
+ public NotificationRan getRan() {
+ return ran;
+ }
+
+ public void setRan(NotificationRan ran) {
+ this.ran = ran;
+ }
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/NotificationPayload.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/NotificationPayload.java
new file mode 100644
index 0000000..9fed1e7
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/NotificationPayload.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class NotificationPayload {
+
+ @JsonProperty("RadioAccess")
+ private RadioAccess radioAccess;
+
+ public NotificationPayload() {
+
+ }
+
+ /**
+ * Parameterized Constructor.
+ */
+
+ public NotificationPayload(RadioAccess radioAccess) {
+ super();
+ this.radioAccess = radioAccess;
+ }
+
+ public RadioAccess getRadioAccess() {
+ return radioAccess;
+ }
+
+ public void setRadioAccess(RadioAccess radioAccess) {
+ this.radioAccess = radioAccess;
+ }
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/NotificationRan.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/NotificationRan.java
new file mode 100644
index 0000000..6215ebb
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/NotificationRan.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class NotificationRan {
+
+ @JsonProperty("NeighborListInUse")
+ private NeighborListInUse neighborListInUse;
+
+ @JsonProperty("CellIdentity")
+ private String cellIdentity;
+
+ public NotificationRan() {
+
+ }
+
+ /**
+ * Parameterized Constructor.
+ */
+
+ public NotificationRan(NeighborListInUse neighborListInUse, String cellIdentity) {
+ super();
+ this.neighborListInUse = neighborListInUse;
+ this.cellIdentity = cellIdentity;
+ }
+
+ public NeighborListInUse getNeighborListInUse() {
+ return neighborListInUse;
+ }
+
+ public void setNeighborListInUse(NeighborListInUse neighborListInUse) {
+ this.neighborListInUse = neighborListInUse;
+ }
+
+ public String getCellIdentity() {
+ return cellIdentity;
+ }
+
+ public void setCellIdentity(String cellIdentity) {
+ this.cellIdentity = cellIdentity;
+ }
+
+}
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
new file mode 100644
index 0000000..dd10a1f
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Payload.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.List;
+
+public class Payload {
+
+ @JsonProperty("Configurations")
+ private List<Configurations> configuration;
+
+ public Payload() {
+
+ }
+
+ public Payload(List<Configurations> configuration) {
+ super();
+ this.configuration = configuration;
+ }
+
+ public List<Configurations> getConfiguration() {
+ return configuration;
+ }
+
+ public void setConfiguration(List<Configurations> configuration) {
+ this.configuration = configuration;
+ }
+
+ @Override
+ public String toString() {
+ return "Payload [configuration=" + configuration + "]";
+
+ }
+
+}
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
new file mode 100644
index 0000000..076c7b5
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/PolicyNotification.java
@@ -0,0 +1,206 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class PolicyNotification {
+
+ private String closedLoopControlName;
+ private long closedLoopAlarmStart;
+ private String closedLoopEventClient;
+ private String closedLoopEventStatus;
+
+ @JsonProperty("target_type")
+ private String targetType;
+
+ private String target;
+
+ @JsonProperty("requestID")
+ private String requestId;
+
+ @JsonProperty("AAI")
+ private Map<String, String> aai;
+
+ private String from;
+ private String version;
+
+ @JsonProperty("Action")
+ private String action;
+ private String payload;
+
+ /**
+ * constructor.
+ */
+ public PolicyNotification() {
+
+ }
+
+ /**
+ * Constructor.
+ *
+ */
+ public PolicyNotification(String closedLoopControlName, String requestId, Long alarmStartTime, String pnfName) {
+ this.closedLoopControlName = closedLoopControlName;
+ this.requestId = requestId;
+ this.closedLoopEventClient = "microservice.PCI";
+ this.closedLoopEventStatus = "ONSET";
+ this.closedLoopAlarmStart = alarmStartTime;
+ this.from = "PCIMS";
+ this.version = "1.0.2";
+ this.action = "ModifyConfig";
+ this.target = "generic-vnf.vnf-id";
+ this.targetType = "VNF";
+ this.aai = new HashMap<>();
+ aai.put("generic-vnf.is-closed-loop-disabled", "false");
+ aai.put("generic-vnf.prov-status", "ACTIVE");
+ aai.put("generic-vnf.vnf-id", pnfName);
+ }
+
+ public long getClosedLoopAlarmStart() {
+ return closedLoopAlarmStart;
+ }
+
+ public void setClosedLoopAlarmStart(long closedLoopAlarmStart) {
+ this.closedLoopAlarmStart = closedLoopAlarmStart;
+ }
+
+ public String getClosedLoopEventClient() {
+ return closedLoopEventClient;
+ }
+
+ public void setClosedLoopEventClient(String closedLoopEventClient) {
+ this.closedLoopEventClient = closedLoopEventClient;
+ }
+
+ public String getClosedLoopEventStatus() {
+ return closedLoopEventStatus;
+ }
+
+ public void setClosedLoopEventStatus(String closedLoopEventStatus) {
+ this.closedLoopEventStatus = closedLoopEventStatus;
+ }
+
+ public String getRequestId() {
+ return requestId;
+ }
+
+ public void setRequestId(String requestId) {
+ this.requestId = requestId;
+ }
+
+ public String getFrom() {
+ return from;
+ }
+
+ public void setFrom(String from) {
+ this.from = from;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public String getAction() {
+ return action;
+ }
+
+ public void setAction(String action) {
+ this.action = action;
+ }
+
+ public String getClosedLoopControlName() {
+ return closedLoopControlName;
+ }
+
+ public void setClosedLoopControlName(String closedLoopControlName) {
+ this.closedLoopControlName = closedLoopControlName;
+ }
+
+ public String getPayload() {
+ return payload;
+ }
+
+ public void setPayload(String payload) {
+ this.payload = payload;
+ }
+
+ public String getTargetType() {
+ return targetType;
+ }
+
+ public void setTargetType(String targetType) {
+ this.targetType = targetType;
+ }
+
+ public String getTarget() {
+ return target;
+ }
+
+ public void setTarget(String target) {
+ this.target = target;
+ }
+
+ public Map<String, String> getAai() {
+ return aai;
+ }
+
+ public void setAai(Map<String, String> aai) {
+ this.aai = aai;
+ }
+
+ @Override
+ public String toString() {
+ return "PolicyNotification [closedLoopControlName=" + closedLoopControlName + ", closedLoopAlarmStart="
+ + closedLoopAlarmStart + ", closedLoopEventClient=" + closedLoopEventClient + ", closedLoopEventStatus="
+ + closedLoopEventStatus + ", targetType=" + targetType + ", target=" + target + ", requestId="
+ + requestId + ", aai=" + aai + ", from=" + from + ", version=" + version + ", action=" + action
+ + ", payload=" + payload + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((aai == null) ? 0 : aai.hashCode());
+ result = prime * result + ((action == null) ? 0 : action.hashCode());
+ result = prime * result + (int) (closedLoopAlarmStart ^ (closedLoopAlarmStart >>> 32));
+ result = prime * result + ((closedLoopControlName == null) ? 0 : closedLoopControlName.hashCode());
+ result = prime * result + ((closedLoopEventClient == null) ? 0 : closedLoopEventClient.hashCode());
+ result = prime * result + ((closedLoopEventStatus == null) ? 0 : closedLoopEventStatus.hashCode());
+ result = prime * result + ((from == null) ? 0 : from.hashCode());
+ result = prime * result + ((payload == null) ? 0 : payload.hashCode());
+ result = prime * result + ((requestId == null) ? 0 : requestId.hashCode());
+ result = prime * result + ((target == null) ? 0 : target.hashCode());
+ result = prime * result + ((targetType == null) ? 0 : targetType.hashCode());
+ result = prime * result + ((version == null) ? 0 : version.hashCode());
+ return result;
+ }
+
+}
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
new file mode 100644
index 0000000..775c14d
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/RadioAccess.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.List;
+
+public class RadioAccess {
+
+ @JsonProperty("FAPServiceNumberOfEntries")
+ private String fapServiceNumberOfEntries;
+
+ @JsonProperty("FAPServiceList")
+ private List<FapServiceList> fapServiceList;
+
+ public RadioAccess() {
+
+ }
+
+ /**
+ * Parameterized Constructor.
+ */
+
+ public RadioAccess(String fapServiceNumberOfEntries, List<FapServiceList> fapServiceList) {
+ super();
+ this.fapServiceNumberOfEntries = fapServiceNumberOfEntries;
+ this.fapServiceList = fapServiceList;
+ }
+
+ public String getFapServiceNumberOfEntries() {
+ return fapServiceNumberOfEntries;
+ }
+
+ public void setFapServiceNumberOfEntries(String fapServiceNumberOfEntries) {
+ this.fapServiceNumberOfEntries = fapServiceNumberOfEntries;
+ }
+
+ public List<FapServiceList> getFapServiceList() {
+ return fapServiceList;
+ }
+
+ public void setFapServiceList(List<FapServiceList> fapServiceList) {
+ this.fapServiceList = fapServiceList;
+ }
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/Ran.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Ran.java
new file mode 100644
index 0000000..f2be944
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Ran.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class Ran {
+
+ @JsonProperty(value = "Common")
+ private Common common;
+
+ public Ran() {
+
+ }
+
+ /**
+ * Parameterized constructor.
+ */
+ public Ran(Common common) {
+ super();
+ this.common = common;
+ }
+
+ public Common getCommon() {
+ return common;
+ }
+
+ public void setCommon(Common common) {
+ this.common = common;
+ }
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/Response.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Response.java
new file mode 100644
index 0000000..46237db
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Response.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class Response {
+
+ @JsonProperty(value = "cellId")
+ private String cellId;
+
+ private int pci;
+
+ public String getCellId() {
+ return cellId;
+ }
+
+ public void setCellId(String cellId) {
+ this.cellId = cellId;
+ }
+
+ public int getPci() {
+ return pci;
+ }
+
+ public void setPci(int pci) {
+ this.pci = pci;
+ }
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/SdnrResponse.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/SdnrResponse.java
new file mode 100644
index 0000000..7fb73b7
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/SdnrResponse.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.model;
+
+import java.util.List;
+
+public class SdnrResponse {
+
+ private List<Response> response;
+
+ public List<Response> getResponse() {
+ return response;
+ }
+
+ public void setResponse(List<Response> response) {
+ this.response = response;
+ }
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/ThreadId.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/ThreadId.java
new file mode 100644
index 0000000..37d741d
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/ThreadId.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.model;
+
+public class ThreadId {
+
+ private long childThreadId;
+
+ public long getChildThreadId() {
+ return childThreadId;
+ }
+
+ public void setChildThreadId(long childThreadId) {
+ this.childThreadId = childThreadId;
+ }
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/X0005b9Lte.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/X0005b9Lte.java
new file mode 100644
index 0000000..d6dc61e
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/X0005b9Lte.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class X0005b9Lte {
+
+ @JsonProperty("phyCellIdInUse")
+ private int phyCellIdInUse;
+
+ @JsonProperty("pnfName")
+ private String pnfName;
+
+ public X0005b9Lte() {
+
+ }
+
+ /**
+ * Parameterized Constructor.
+ */
+
+ public X0005b9Lte(int phyCellIdInUse, String pnfName) {
+ super();
+ this.phyCellIdInUse = phyCellIdInUse;
+ this.pnfName = pnfName;
+ }
+
+ public int getPhyCellIdInUse() {
+ return phyCellIdInUse;
+ }
+
+ public void setPhyCellIdInUse(int phyCellIdInUse) {
+ this.phyCellIdInUse = phyCellIdInUse;
+ }
+
+ public String getPnfName() {
+ return pnfName;
+ }
+
+ public void setPnfName(String pnfName) {
+ this.pnfName = pnfName;
+ }
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/AsyncResponseBody.java b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/AsyncResponseBody.java
new file mode 100644
index 0000000..61e0421
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/AsyncResponseBody.java
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.restclient;
+
+import java.util.List;
+
+public class AsyncResponseBody {
+
+ String transactionId = null;
+ String requestId = null;
+ String requestStatus = null;
+ String statusMessage = null;
+ List<Solution> solutions;
+
+ public String getTransactionId() {
+ return transactionId;
+ }
+
+ public void setTransactionId(String transactionId) {
+ this.transactionId = transactionId;
+ }
+
+ public String getRequestId() {
+ return requestId;
+ }
+
+ public void setRequestId(String requestId) {
+ this.requestId = requestId;
+ }
+
+ public String getRequestStatus() {
+ return requestStatus;
+ }
+
+ @Override
+ public String toString() {
+ return "AsyncResponseBody [transactionId=" + transactionId + ", requestId=" + requestId + ", requestStatus="
+ + requestStatus + ", statusMessage=" + statusMessage + ", solutions=" + solutions + "]";
+ }
+
+ public void setRequestStatus(String requestStatus) {
+ this.requestStatus = requestStatus;
+ }
+
+ public String getStatusMessage() {
+ return statusMessage;
+ }
+
+ public void setStatusMessage(String statusMessage) {
+ this.statusMessage = statusMessage;
+ }
+
+ public List<Solution> getSolutions() {
+ return solutions;
+ }
+
+ public void setSolutions(List<Solution> solutions) {
+ this.solutions = solutions;
+ }
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/CellInfo.java b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/CellInfo.java
new file mode 100644
index 0000000..edac16f
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/CellInfo.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.restclient;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class CellInfo {
+ String networkId = null;
+ List<String> cellIdList = new ArrayList<>();
+
+ public String getNetworkId() {
+ return networkId;
+ }
+
+ public void setNetworkId(String networkId) {
+ this.networkId = networkId;
+ }
+
+ public List<String> getCellIdList() {
+ return cellIdList;
+ }
+
+ public void setCellIdList(List<String> cellIdList) {
+ this.cellIdList = cellIdList;
+ }
+
+
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/OofRequestBody.java b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/OofRequestBody.java
new file mode 100644
index 0000000..2e5eeaa
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/OofRequestBody.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * ============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;
+
+public class OofRequestBody {
+
+ protected RequestInfo requestInfo = new RequestInfo();
+ protected CellInfo cellInfo = new CellInfo();
+
+ public RequestInfo getRequestInfo() {
+ return requestInfo;
+ }
+
+ public void setRequestInfo(RequestInfo requestInfo) {
+ this.requestInfo = requestInfo;
+ }
+
+ public CellInfo getCellInfo() {
+ return cellInfo;
+ }
+
+ public void setCellInfo(CellInfo cellInfo) {
+ this.cellInfo = cellInfo;
+ }
+
+}
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
new file mode 100644
index 0000000..a9ce305
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/OofRestClient.java
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * ============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.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;
+import org.springframework.http.ResponseEntity;
+
+public class OofRestClient {
+ private static Logger log = LoggerFactory.getLogger(OofRestClient.class);
+
+ private OofRestClient() {
+
+ }
+
+ /**
+ * rest client that pci uses to query the OOF for pci solutions.
+ * @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 {
+ log.debug("inside queryoof");
+
+ ResponseEntity<String> response = null;
+ Configuration configuration = Configuration.getInstance();
+ 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);
+
+ 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/PolicyRequestBody.java b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/PolicyRequestBody.java
new file mode 100644
index 0000000..a7c9f08
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/PolicyRequestBody.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.restclient;
+
+public class PolicyRequestBody {
+
+ String configName = null;
+ String policyName = null;
+ String requestId = null;
+
+ public String getConfigName() {
+ return configName;
+ }
+
+ public void setConfigName(String configName) {
+ this.configName = configName;
+ }
+
+ public String getPolicyName() {
+ return policyName;
+ }
+
+ public void setPolicyName(String policyName) {
+ this.policyName = policyName;
+ }
+
+ public String getRequestId() {
+ return requestId;
+ }
+
+ public void setRequestId(String requestId) {
+ this.requestId = requestId;
+ }
+
+}
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
new file mode 100644
index 0000000..7334df2
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/PolicyRestClient.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * ============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/RequestInfo.java b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/RequestInfo.java
new file mode 100644
index 0000000..ff53b33
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/RequestInfo.java
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.restclient;
+
+import java.util.List;
+
+public class RequestInfo {
+ String transactionId = null;
+ String requestId = null;
+ String callbackUrl = null;
+ String sourceId = null;
+ String requestType = null;
+ int numSolutions;
+ List<String> optimizers = null;
+
+ public void setOptimizers(List<String> optimizers) {
+ this.optimizers = optimizers;
+ }
+
+ public List<String> getOptimizers() {
+ return optimizers;
+ }
+
+ int timeout;
+
+ public String getRequestId() {
+ return requestId;
+ }
+
+ public void setRequestId(String requestId) {
+ this.requestId = requestId;
+ }
+
+ public String getCallbackUrl() {
+ return callbackUrl;
+ }
+
+ public void setCallbackUrl(String callbackUrl) {
+ this.callbackUrl = callbackUrl;
+ }
+
+ public String getSourceId() {
+ return sourceId;
+ }
+
+ public void setSourceId(String sourceId) {
+ this.sourceId = sourceId;
+ }
+
+ public String getRequestType() {
+ return requestType;
+ }
+
+ public void setRequestType(String requestType) {
+ this.requestType = requestType;
+ }
+
+ public int getNumSolutions() {
+ return numSolutions;
+ }
+
+ public void setNumSolutions(int numSolutions) {
+ this.numSolutions = numSolutions;
+ }
+
+ public int getTimeout() {
+ return timeout;
+ }
+
+ public void setTimeout(int timeout) {
+ this.timeout = timeout;
+ }
+
+ public String getTransactionId() {
+ return transactionId;
+ }
+
+ public void setTransactionId(String transactionId) {
+ this.transactionId = transactionId;
+ }
+
+}
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
new file mode 100644
index 0000000..0894146
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/SdnrRestClient.java
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * ============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 org.onap.dcaegen2.services.sonhms.Configuration;
+import org.onap.dcaegen2.services.sonhms.exceptions.ConfigDbNotFoundException;
+import org.onap.dcaegen2.services.sonhms.model.CellPciPair;
+import org.onap.dcaegen2.services.sonhms.utils.SonHandlerRestTemplate;
+
+import java.sql.Time;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.json.JSONArray;
+import org.json.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.core.ParameterizedTypeReference;
+import org.springframework.http.ResponseEntity;
+
+
+
+public class SdnrRestClient {
+
+ private static final String DATETIMEFORMAT = "yyyy-MM-dd HH:mm:ss";
+ private static Logger log = LoggerFactory.getLogger(SdnrRestClient.class);
+
+ private SdnrRestClient() {
+
+ }
+
+ /**
+ * Method to get cell list from SDNR.
+ *
+ * @throws ConfigDbNotFoundException
+ * when request to configDB fails
+ */
+ 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 + "/"
+ + encode(ts);
+ return sendRequest(requestUrl);
+ }
+
+ /**
+ * Method to get neibhbour list from SDNR.
+ *
+ * @throws ConfigDbNotFoundException
+ * when request to configDB fails
+ */
+ 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 + "/"
+ + encode(ts);
+ log.debug("request url: {}", requestUrl);
+ String response = sendRequest(requestUrl);
+ List<CellPciPair> nbrList = new ArrayList<>();
+ JSONArray nbrListObj = new JSONArray(response);
+ for (int i = 0; i < nbrListObj.length(); i++) {
+ JSONObject cellObj = nbrListObj.getJSONObject(i);
+ CellPciPair cell = new CellPciPair(cellObj.getString("cellId"), cellObj.getInt("pciValue"));
+ nbrList.add(cell);
+ }
+
+ return nbrList;
+ }
+
+ /**
+ * Method to get PCI from SDNR.
+ *
+ * @throws ConfigDbNotFoundException
+ * when request to configDB fails
+ */
+ 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 + "/"
+ + encode(ts);
+ String response = sendRequest(requestUrl);
+ JSONObject respObj = new JSONObject(response);
+ return respObj.getInt("value");
+ }
+
+ /**
+ * Method to get PNF name from SDNR.
+ *
+ * @throws ConfigDbNotFoundException
+ * when request to configDB fails
+ */
+ 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 + "/"
+ + encode(ts);
+ String response = sendRequest(requestUrl);
+ JSONObject responseObject = new JSONObject(response);
+ return responseObject.getString("value");
+ }
+
+ /**
+ * Method to encode url.
+ */
+ private static String encode(String url) {
+ return url.replace(" ", "%20");
+ }
+
+ /**
+ * Method to send request.
+ */
+ private static String sendRequest(String url) throws ConfigDbNotFoundException {
+ ResponseEntity<String> response = SonHandlerRestTemplate.sendGetRequest(url,
+ new ParameterizedTypeReference<String>() {});
+ if (response.equals(null)) {
+ throw new ConfigDbNotFoundException("Cannot reach Config DB");
+ }
+ return response.getBody();
+ }
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/Solution.java b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/Solution.java
new file mode 100644
index 0000000..66af930
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/Solution.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.restclient;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Solution {
+ String startTime = null;
+ String finishTime = null;
+ String networkId = null;
+ List<SonSolution> pciSolutions = new ArrayList<>();
+
+ public String getStartTime() {
+ return startTime;
+ }
+
+ public void setStartTime(String startTime) {
+ this.startTime = startTime;
+ }
+
+ public String getFinishTime() {
+ return finishTime;
+ }
+
+ public void setFinishTime(String finishTime) {
+ this.finishTime = finishTime;
+ }
+
+ public String getNetworkId() {
+ return networkId;
+ }
+
+ public void setNetworkId(String networkId) {
+ this.networkId = networkId;
+ }
+
+ public List<SonSolution> getPciSolutions() {
+ return pciSolutions;
+ }
+
+ /**
+ * Sets PciSolutions.
+ */
+ public void setPciSolutions(List<SonSolution> pciSolutions) {
+
+ this.pciSolutions = pciSolutions;
+
+ }
+
+ @Override
+ public String toString() {
+ return "Solutions [startTime=" + startTime + ", finishTime=" + finishTime + ", networkId=" + networkId
+ + ", pciSolutions=" + pciSolutions + "]";
+ }
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/SonSolution.java b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/SonSolution.java
new file mode 100644
index 0000000..25f474a
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/SonSolution.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * ============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;
+
+public class SonSolution {
+
+ String cellId = null;
+ int pci;
+
+ public String getCellId() {
+ return cellId;
+ }
+
+ public void setCellId(String cellId) {
+ this.cellId = cellId;
+ }
+
+ public int getPci() {
+ return pci;
+ }
+
+ public void setPci(int pci) {
+ this.pci = pci;
+ }
+
+}
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
new file mode 100644
index 0000000..a30288a
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/AppConfig.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * ============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.util.ArrayList;
+import java.util.List;
+
+import org.apache.http.conn.ssl.NoopHostnameVerifier;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.MediaType;
+import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
+import org.springframework.http.converter.ByteArrayHttpMessageConverter;
+import org.springframework.web.client.RestTemplate;
+
+@Configuration
+public class AppConfig {
+
+
+ /**
+ * Rest Template bean.
+ */
+ @Bean
+ public static RestTemplate initRestTemplateForPdfAsByteArrayAndSelfSignedHttps() {
+ RestTemplate restTemplate = new RestTemplate(useApacheHttpClientWithSelfSignedSupport());
+ restTemplate.getMessageConverters().add(generateByteArrayHttpMessageConverter());
+ return restTemplate;
+ }
+
+ private static HttpComponentsClientHttpRequestFactory useApacheHttpClientWithSelfSignedSupport() {
+ CloseableHttpClient httpClient = HttpClients.custom().setSSLHostnameVerifier(new NoopHostnameVerifier())
+ .build();
+ HttpComponentsClientHttpRequestFactory useApacheHttpClient = new HttpComponentsClientHttpRequestFactory();
+ useApacheHttpClient.setHttpClient(httpClient);
+ return useApacheHttpClient;
+ }
+
+ private static ByteArrayHttpMessageConverter generateByteArrayHttpMessageConverter() {
+ ByteArrayHttpMessageConverter byteArrayHttpMessageConverter = new ByteArrayHttpMessageConverter();
+
+ List<MediaType> supportedApplicationTypes = new ArrayList<MediaType>();
+ 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
new file mode 100644
index 0000000..63a738c
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/BeanUtil.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * ============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 org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.stereotype.Service;
+
+@Service
+public class BeanUtil implements ApplicationContextAware {
+ private static ApplicationContext context;
+
+ @Override
+ public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+ context = applicationContext;
+ }
+
+ public static <T> T getBean(Class<T> beanClass) {
+ return context.getBean(beanClass);
+ }
+}
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
new file mode 100644
index 0000000..79d0c61
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtils.java
@@ -0,0 +1,344 @@
+/*******************************************************************************
+ * ============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 org.onap.dcaegen2.services.sonhms.ClusterDetailsComponent;
+import org.onap.dcaegen2.services.sonhms.NotificationToClusterMapping;
+import org.onap.dcaegen2.services.sonhms.child.Graph;
+import org.onap.dcaegen2.services.sonhms.dao.ClusterDetailsRepository;
+import org.onap.dcaegen2.services.sonhms.entity.ClusterDetails;
+import org.onap.dcaegen2.services.sonhms.exceptions.ConfigDbNotFoundException;
+import org.onap.dcaegen2.services.sonhms.model.CellPciPair;
+import org.onap.dcaegen2.services.sonhms.model.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;
+
+
+
+public class ClusterUtils {
+
+ private static Logger log = LoggerFactory.getLogger(ClusterUtils.class);
+
+ public List<ClusterDetails> getAllClusters() {
+ ClusterDetailsComponent clusterDetailsComponent = new ClusterDetailsComponent();
+ return clusterDetailsComponent.getClusterDetails();
+ }
+
+ /**
+ * Get clusters for notifications.
+ */
+ public NotificationToClusterMapping getClustersForNotification(Notification notification,
+ List<ClusterDetails> clusterDetails) {
+
+ NotificationToClusterMapping mapping = new NotificationToClusterMapping();
+
+ Map<FapServiceList, String> cellsInCluster = new HashMap<>();
+ List<FapServiceList> newCells = new ArrayList<>();
+
+ List<FapServiceList> fapServiceList = notification.getPayload().getRadioAccess().getFapServiceList();
+
+ for (FapServiceList fapService : fapServiceList) {
+
+ for (ClusterDetails clusterDetail : clusterDetails) {
+
+ Set<String> cellsInNotification = getCellsInNotification(fapService);
+
+ Graph cluster = new Graph(clusterDetail.getClusterInfo());
+
+ Set<String> clusterCells = getCellsInCluster(cluster);
+
+ log.debug("cells in cluster {}", clusterCells);
+
+ cellsInNotification.retainAll(clusterCells);
+
+ if (!cellsInNotification.isEmpty()) {
+ log.debug("cell or it's neighbour in the cluster");
+ cellsInCluster.put(fapService, clusterDetail.getClusterId());
+ break;
+ }
+ }
+
+ if (!cellsInCluster.containsKey(fapService)) {
+ newCells.add(fapService);
+ }
+ }
+
+ mapping.setCellsinCluster(cellsInCluster);
+ mapping.setNewCells(newCells);
+ return mapping;
+ }
+
+ /**
+ * Get cluster details from cluster ID.
+ */
+ public Either<ClusterDetails, Integer> getClusterDetailsFromClusterId(String clusterId,
+ List<ClusterDetails> clusterDetails) {
+
+ for (ClusterDetails clusterDetail : clusterDetails) {
+ if (clusterDetail.getClusterId().equals(clusterId)) {
+ return Either.left(clusterDetail);
+ }
+ }
+ return Either.right(404);
+ }
+
+ /**
+ * Get clusters for Cell.
+ */
+ public Either<Graph, Integer> getClusterForCell(FapServiceList fapService, List<Graph> newClusters) {
+
+ if (newClusters.isEmpty()) {
+ return Either.right(404);
+ }
+
+
+ for (Graph cluster : newClusters) {
+
+ Set<String> cellsInNotification = getCellsInNotification(fapService);
+ Set<String> clusterCells = getCellsInCluster(cluster);
+
+ cellsInNotification.retainAll(clusterCells);
+
+ if (!(cellsInNotification.isEmpty())) {
+ return Either.left(cluster);
+ }
+
+ }
+
+ return Either.right(404);
+ }
+
+ private Set<String> getCellsInNotification(FapServiceList fapService) {
+ Set<String> cellsInNotification = new HashSet<>();
+ cellsInNotification.add(fapService.getAlias());
+ List<LteNeighborListInUseLteCell> nbrList = fapService.getCellConfig().getLte().getRan().getNeighborListInUse()
+ .getLteNeighborListInUseLteCell();
+ for (LteNeighborListInUseLteCell nbr : nbrList) {
+ cellsInNotification.add(nbr.getAlias());
+ }
+
+ return cellsInNotification;
+ }
+
+ private Set<String> getCellsInCluster(Graph cluster) {
+ Map<CellPciPair, ArrayList<CellPciPair>> cellPciNeighbourMap = cluster.getCellPciNeighbourMap();
+ log.debug("cell_pci_map {}", cellPciNeighbourMap);
+ Set<CellPciPair> keys = cellPciNeighbourMap.keySet();
+ Set<String> clusterCells = new HashSet<>();
+ for (CellPciPair cellPciPair : keys) {
+ log.debug("cells {}", cellPciPair.getCellId());
+ clusterCells.add(cellPciPair.getCellId());
+ }
+
+ return clusterCells;
+ }
+
+ /**
+ * Create cluster from notification.
+ */
+ public Graph createCluster(FapServiceList fapService) throws ConfigDbNotFoundException {
+
+ Graph cluster = new Graph();
+ log.debug("cluster formation started");
+ int phycellId = fapService.getX0005b9Lte().getPhyCellIdInUse();
+ String cellId = fapService.getCellConfig().getLte().getRan().getCellIdentity();
+
+ CellPciPair val = new CellPciPair();
+ val.setCellId(cellId);
+ val.setPhysicalCellId(phycellId);
+ List<LteNeighborListInUseLteCell> neighbourlist;
+ neighbourlist = fapService.getCellConfig().getLte().getRan().getNeighborListInUse()
+ .getLteNeighborListInUseLteCell();
+ log.debug("Neighbor list size: {}", neighbourlist.size());
+
+ for (int i = 0; i < neighbourlist.size(); i++) {
+ String cell = neighbourlist.get(i).getAlias();
+ int phy = neighbourlist.get(i).getPhyCellId();
+
+ log.debug("cellID: {}", cell);
+ log.debug("PCI: {}", phy);
+ CellPciPair val1 = new CellPciPair();
+ val1.setCellId(cell);
+ val1.setPhysicalCellId(phy);
+ cluster.addEdge(val, val1);
+ log.debug("cluster: {}", cluster);
+
+ List<CellPciPair> nbrList = SdnrRestClient.getNbrList(neighbourlist.get(i).getAlias());
+
+ for (CellPciPair nbr : nbrList) {
+ String cid = nbr.getCellId();
+ int pci = nbr.getPhysicalCellId();
+ CellPciPair val3 = new CellPciPair();
+ val3.setCellId(cid);
+ val3.setPhysicalCellId(pci);
+
+ cluster.addEdge(val1, val3);
+ }
+ }
+
+ log.debug("final cluster: {}", cluster);
+ return cluster;
+ }
+
+ /**
+ * Save cluster.
+ */
+ public String saveCluster(Graph cluster, UUID clusterId, Long threadId) {
+
+ String cellPciNeighbourString = cluster.getPciNeighbourJson();
+
+ log.debug("cluster hahsmap to string : {}", cellPciNeighbourString);
+ cluster.setGraphId(clusterId);
+
+ ClusterDetails details = new ClusterDetails();
+ details.setClusterId(clusterId.toString());
+ details.setClusterInfo(cellPciNeighbourString);
+ details.setChildThreadId(threadId);
+
+ ClusterDetailsRepository clusterDetailsRepository = BeanUtil.getBean(ClusterDetailsRepository.class);
+ clusterDetailsRepository.save(details);
+
+ return clusterId.toString();
+ }
+
+ /**
+ * update cluster.
+ */
+ public Graph modifyCluster(Graph cluster, FapServiceList fapser) {
+
+ int phycellId = fapser.getX0005b9Lte().getPhyCellIdInUse();
+ String cellId = fapser.getCellConfig().getLte().getRan().getCellIdentity();
+ CellPciPair mainCellPciPair = new CellPciPair();
+ mainCellPciPair.setCellId(cellId);
+ mainCellPciPair.setPhysicalCellId(phycellId);
+ List<LteNeighborListInUseLteCell> newNeighbourList;
+ newNeighbourList = fapser.getCellConfig().getLte().getRan().getNeighborListInUse()
+ .getLteNeighborListInUseLteCell();
+
+ Map<CellPciPair, ArrayList<CellPciPair>> clusterMap;
+ clusterMap = cluster.getCellPciNeighbourMap();
+
+ // coe
+
+ List<CellPciPair> tempCellPair = new ArrayList<>();
+ for (Map.Entry<CellPciPair, ArrayList<CellPciPair>> entry : clusterMap.entrySet()) {
+ CellPciPair oldClusterKeys = entry.getKey();
+ tempCellPair.add(oldClusterKeys);
+ }
+
+ for (CellPciPair entry : tempCellPair) {
+ String cell = entry.getCellId();
+ int physicalCell = entry.getPhysicalCellId();
+ CellPciPair mapVal = new CellPciPair();
+ mapVal.setCellId(cell);
+ mapVal.setPhysicalCellId(physicalCell);
+
+ if (cellId.equals(cell)) {
+
+ // removes the old neighbours and adds new neighbours for that cell
+ cluster.updateVertex(mapVal, mainCellPciPair);
+
+ }
+
+ }
+
+ /////// update cluster with new pci values for the same cell
+
+ if (clusterMap.containsKey(mainCellPciPair)) {
+ ArrayList<CellPciPair> oldClusterArray;
+ oldClusterArray = clusterMap.get(mainCellPciPair);
+ oldClusterArray.clear();
+
+ for (int i = 0; i < newNeighbourList.size(); i++) {
+ String cid = newNeighbourList.get(i).getAlias();
+ int phy = newNeighbourList.get(i).getPhyCellId();
+ CellPciPair val2 = new CellPciPair();
+ val2.setCellId(cid);
+ val2.setPhysicalCellId(phy);
+ cluster.addEdge(mainCellPciPair, val2);
+ }
+
+ }
+
+ for (CellPciPair entry : tempCellPair) {
+ String cell = entry.getCellId();
+ int physicalCell = entry.getPhysicalCellId();
+ CellPciPair mapVal = new CellPciPair();
+ mapVal.setCellId(cell);
+ mapVal.setPhysicalCellId(physicalCell);
+ for (int j = 0; j < newNeighbourList.size(); j++) {
+ String cid1 = newNeighbourList.get(j).getAlias();
+ int phy1 = newNeighbourList.get(j).getPhyCellId();
+ CellPciPair val3 = new CellPciPair();
+ val3.setCellId(cid1);
+ val3.setPhysicalCellId(phy1);
+
+ if (cid1.equals(cell)) {
+
+ // removes the old neighbours and adds new neighbours for that cell
+ cluster.updateVertex(mapVal, val3);
+
+ }
+
+ }
+ }
+
+ for (int j = 0; j < newNeighbourList.size(); j++) {
+ String cid1 = newNeighbourList.get(j).getAlias();
+ int phy1 = newNeighbourList.get(j).getPhyCellId();
+ CellPciPair val3 = new CellPciPair();
+ val3.setCellId(cid1);
+ val3.setPhysicalCellId(phy1);
+ if (clusterMap.containsKey(val3)) {
+ cluster.addEdge(mainCellPciPair, val3);
+ }
+
+ }
+
+ for (int k = 0; k < newNeighbourList.size(); k++) {
+ String cid2 = newNeighbourList.get(k).getAlias();
+ int phy2 = newNeighbourList.get(k).getPhyCellId();
+ CellPciPair val5 = new CellPciPair();
+ val5.setCellId(cid2);
+ val5.setPhysicalCellId(phy2);
+ cluster.addEdge(mainCellPciPair, val5);
+ }
+
+ log.debug("Modified Cluster {}", cluster);
+
+ return cluster;
+ }
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/utils/FileIo.java b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/FileIo.java
new file mode 100644
index 0000000..7eaafbe
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/FileIo.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * son-handler
+ * ================================================================================
+ * Copyright (C) 2019 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.utils;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+
+public class FileIo {
+
+ private FileIo() {
+
+ }
+
+ /**
+ * Reads from File.
+ */
+ public static String readFromFile(String file) {
+ String content = "";
+ try (BufferedReader bufferedReader = new BufferedReader(new FileReader(file))) {
+ content = bufferedReader.readLine();
+ String temp;
+ while ((temp = bufferedReader.readLine()) != null) {
+ content = content.concat(temp);
+ }
+ content = content.trim();
+ } catch (Exception e) {
+ content = null;
+ }
+ return content;
+ }
+
+}
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
new file mode 100644
index 0000000..7745117
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/SonHandlerRestTemplate.java
@@ -0,0 +1,162 @@
+/*******************************************************************************
+ * ============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.util.Collections;
+
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.ParameterizedTypeReference;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Component;
+import org.springframework.web.client.RestTemplate;
+
+@Component
+public class SonHandlerRestTemplate {
+ @Autowired
+ static RestTemplate restTemplate;
+
+ private static final String AUTH = "Authorization";
+ private static final String EXCEPTION_MSG = "Exception caught during request {}";
+ private static final Logger log = org.slf4j.LoggerFactory.getLogger(SonHandlerRestTemplate.class);
+
+ private SonHandlerRestTemplate() {
+
+ }
+
+ /**
+ * Send Post Request.
+ */
+
+ public static <T> ResponseEntity<T> sendPostRequest(String requestUrl, String requestBody,
+ ParameterizedTypeReference<T> responseType) {
+ HttpHeaders headers = new HttpHeaders();
+ headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
+ headers.setContentType(MediaType.APPLICATION_JSON);
+ 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 policy.
+ */
+ public static <T> ResponseEntity<T> sendPostToPolicy(String requestUrl, String requestBody,
+ ParameterizedTypeReference<T> responseType) {
+ HttpHeaders headers = new HttpHeaders();
+ headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
+ headers.setContentType(MediaType.APPLICATION_JSON);
+ headers.add("ClientAuth", "cHl0aG9uOnRlc3Q=");
+ headers.add(AUTH, "Basic dGVzdHBkcDphbHBoYTEyMw== ");
+ headers.add("Environment", "TEST");
+ HttpEntity<Object> requestEntity = new HttpEntity<>(requestBody, headers);
+ try {
+ return restTemplate.exchange(requestUrl, HttpMethod.POST, requestEntity, responseType);
+ } catch (Exception e) {
+ log.debug(EXCEPTION_MSG, e.getMessage());
+ return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+ }
+ }
+
+ /**
+ * Send Get Request.
+ */
+
+ public static <T> ResponseEntity<T> sendGetRequest(String requestUrl, ParameterizedTypeReference<T> responseType) {
+ HttpHeaders headers = new HttpHeaders();
+ headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
+ HttpEntity<Void> requestEntity = new HttpEntity<>(headers);
+ try {
+ return restTemplate.exchange(requestUrl, HttpMethod.GET, requestEntity, responseType);
+ } catch (Exception e) {
+ log.debug(EXCEPTION_MSG, e.getMessage());
+ return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+ }
+ }
+
+ /**
+ * Send Get Request to SDNR.
+ */
+
+ public static <T> ResponseEntity<T> sendGetRequest(String requestUrl, String requestBody,
+ ParameterizedTypeReference<T> responseType) {
+ HttpHeaders headers = new HttpHeaders();
+ headers.setAccept(Collections.singletonList(MediaType.TEXT_PLAIN));
+ 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 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.
+ */
+
+ public static <T> ResponseEntity<T> sendPostRequestToOof(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 cGNpX3Rlc3Q6cGNpX3Rlc3Rwd2Q=");
+ 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);
+ }
+ }
+
+}
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
new file mode 100644
index 0000000..07e7219
--- /dev/null
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/ThreadUtils.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * pcims
+ * ================================================================================
+ * Copyright (C) 2018 Wipro Limited.
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ ******************************************************************************/
+
+package org.onap.dcaegen2.services.sonhms.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.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+
+public class ThreadUtils {
+
+ private static Logger log = LoggerFactory.getLogger(ThreadUtils.class);
+
+ /**
+ * Create thread.
+ */
+ public Boolean createNewThread(List<Graph> newClusters, BlockingQueue<List<String>> childStatusQueue,
+ ExecutorService pool, EventHandler eventHandler) {
+ for (Graph cluster : newClusters) {
+
+ BlockingQueue<FapServiceList> queue = new LinkedBlockingQueue<>();
+ ThreadId threadId = new ThreadId();
+ threadId.setChildThreadId(0);
+ ChildThread child = new ChildThread(childStatusQueue, cluster, queue, threadId);
+ pool.execute(child);
+ waitForThreadId(threadId);
+ UUID clusterId = UUID.randomUUID();
+
+ ClusterUtils clusterUtils = new ClusterUtils();
+ clusterUtils.saveCluster(cluster, clusterId, threadId.getChildThreadId());
+ EventHandler.addChildThreadMap(threadId.getChildThreadId(), child);
+ eventHandler.addChildStatus(threadId.getChildThreadId(), "processingNotifications");
+ }
+ return true;
+
+ }
+
+ private void waitForThreadId(ThreadId threadId) {
+
+ ThreadId thread = threadId;
+ try {
+ synchronized (thread) {
+ while (thread.getChildThreadId() == 0) {
+ thread.wait();
+ }
+ }
+ } catch (InterruptedException e) {
+
+ log.error("ChildThread queue error {}", e);
+ Thread.currentThread().interrupt();
+ }
+ }
+
+}