From 8882e23eedce9e9236e1d979b2056b62dd974d91 Mon Sep 17 00:00:00 2001 From: dhebeha Date: Tue, 8 Sep 2020 13:02:32 +0530 Subject: Add support to consume, process pm message from DB - Add support for analysing pm data - Add support to trigger closed loop - Add support for configDb Interface Implementation - Add support for Intelligent slicing Issue-ID: DCAEGEN2-2255 Signed-off-by: dhebeha Change-Id: I185dbb6da45ae6ee74f0a090e2d604914163588b --- .../org/onap/slice/analysis/ms/Application.java | 4 +- .../org/onap/slice/analysis/ms/MainThread.java | 58 +++++ .../onap/slice/analysis/ms/beans/ConfigPolicy.java | 72 ------ .../slice/analysis/ms/beans/Configuration.java | 242 ------------------- .../ms/configdb/ConfigDbInterfaceService.java | 127 ++++++++++ .../analysis/ms/configdb/IConfigDbService.java | 39 +++ .../analysis/ms/controller/ConfigFetchFromCbs.java | 4 +- .../onap/slice/analysis/ms/dmaap/DmaapClient.java | 45 ++-- .../ms/dmaap/IntelligentSlicingCallback.java | 69 ++++++ .../slice/analysis/ms/dmaap/NewPmNotification.java | 8 +- .../analysis/ms/dmaap/NotificationCallback.java | 2 +- .../analysis/ms/dmaap/PmNotificationCallback.java | 2 +- .../slice/analysis/ms/dmaap/PolicyDmaapClient.java | 2 +- .../ms/dmaap/PolicyNotificationCallback.java | 6 +- .../org/onap/slice/analysis/ms/models/CUModel.java | 101 ++++++++ .../onap/slice/analysis/ms/models/CellCUList.java | 80 +++++++ .../onap/slice/analysis/ms/models/ConfigData.java | 94 ++++++++ .../slice/analysis/ms/models/ConfigPolicy.java | 72 ++++++ .../slice/analysis/ms/models/Configuration.java | 265 +++++++++++++++++++++ .../slice/analysis/ms/models/MLOutputModel.java | 82 +++++++ .../analysis/ms/models/MeasurementObject.java | 96 ++++++++ .../onap/slice/analysis/ms/models/SubCounter.java | 76 ++++++ .../analysis/ms/models/configdb/CellsModel.java | 51 ++++ .../ms/models/configdb/NetworkFunctionModel.java | 52 ++++ .../models/pmnotification/CommonEventHeader.java | 138 +++++++++++ .../analysis/ms/models/pmnotification/Event.java | 47 ++++ .../models/pmnotification/MeasDataCollection.java | 77 ++++++ .../ms/models/pmnotification/MeasInfoId.java | 39 +++ .../ms/models/pmnotification/MeasInfoList.java | 59 +++++ .../ms/models/pmnotification/MeasResult.java | 48 ++++ .../ms/models/pmnotification/MeasTypes.java | 41 ++++ .../ms/models/pmnotification/MeasValuesList.java | 58 +++++ .../ms/models/pmnotification/Perf3gppFields.java | 48 ++++ .../ms/models/pmnotification/PmNotification.java | 39 +++ .../onap/slice/analysis/ms/models/policy/AAI.java | 61 +++++ .../ms/models/policy/AdditionalProperties.java | 75 ++++++ .../analysis/ms/models/policy/OnsetMessage.java | 136 +++++++++++ .../slice/analysis/ms/models/policy/Payload.java | 95 ++++++++ .../ms/restclients/ConfigDbRestClient.java | 64 +++++ .../slice/analysis/ms/restclients/RestClient.java | 80 +++++++ .../analysis/ms/service/AverageCalculator.java | 94 ++++++++ .../slice/analysis/ms/service/ConsumerThread.java | 72 ++++++ .../analysis/ms/service/IPmEventProcessor.java | 35 +++ .../analysis/ms/service/MLMessageProcessor.java | 73 ++++++ .../slice/analysis/ms/service/PmDataQueue.java | 96 ++++++++ .../analysis/ms/service/PmEventProcessor.java | 105 ++++++++ .../onap/slice/analysis/ms/service/PmThread.java | 92 +++++++ .../slice/analysis/ms/service/PolicyService.java | 111 +++++++++ .../ms/service/SnssaiSamplesProcessor.java | 190 +++++++++++++++ .../onap/slice/analysis/ms/utils/DmaapUtils.java | 2 +- 50 files changed, 3278 insertions(+), 346 deletions(-) create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/MainThread.java delete mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/beans/ConfigPolicy.java delete mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/beans/Configuration.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/configdb/ConfigDbInterfaceService.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/configdb/IConfigDbService.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/IntelligentSlicingCallback.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/CUModel.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/CellCUList.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/ConfigData.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/ConfigPolicy.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/Configuration.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/MLOutputModel.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/MeasurementObject.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/SubCounter.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/configdb/CellsModel.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/configdb/NetworkFunctionModel.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/CommonEventHeader.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/Event.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasDataCollection.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasInfoId.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasInfoList.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasResult.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasTypes.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasValuesList.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/Perf3gppFields.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/PmNotification.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/policy/AAI.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/policy/AdditionalProperties.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/policy/OnsetMessage.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/policy/Payload.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/restclients/ConfigDbRestClient.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/restclients/RestClient.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/AverageCalculator.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/ConsumerThread.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/IPmEventProcessor.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/MLMessageProcessor.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/PmDataQueue.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/PmEventProcessor.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/PmThread.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/PolicyService.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/SnssaiSamplesProcessor.java (limited to 'components/slice-analysis-ms/src/main') diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/Application.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/Application.java index f522e008..f04e86d8 100644 --- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/Application.java +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/Application.java @@ -37,9 +37,9 @@ import java.util.Map; import javax.sql.DataSource; -import org.onap.slice.analysis.ms.beans.ConfigPolicy; -import org.onap.slice.analysis.ms.beans.Configuration; import org.onap.slice.analysis.ms.controller.ConfigFetchFromCbs; +import org.onap.slice.analysis.ms.models.ConfigPolicy; +import org.onap.slice.analysis.ms.models.Configuration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.jdbc.DataSourceBuilder; diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/MainThread.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/MainThread.java new file mode 100644 index 00000000..925a196f --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/MainThread.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * son-handler + * ================================================================================ + * Copyright (C) 2019-2020 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.slice.analysis.ms; + +import javax.annotation.PostConstruct; + +import org.onap.slice.analysis.ms.dmaap.NewPmNotification; +import org.onap.slice.analysis.ms.service.ConsumerThread; +import org.onap.slice.analysis.ms.service.PmThread; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * This class starts the pm thread and consumer thread + */ +@Component +public class MainThread { + + private static Logger log = LoggerFactory.getLogger(MainThread.class); + + @Autowired + private NewPmNotification newPmNotification; + + + /** + * main thread initialization. + */ + @PostConstruct + public void init() { + log.debug("initializing main thread"); + Thread pmThread = new Thread(new PmThread(newPmNotification)); + pmThread.start(); + Thread consumerThread = new Thread(new ConsumerThread()); + consumerThread.start(); + } + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/beans/ConfigPolicy.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/beans/ConfigPolicy.java deleted file mode 100644 index d4cd53b8..00000000 --- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/beans/ConfigPolicy.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * slice-analysis-ms - * ================================================================================ - * Copyright (C) 2020 Wipro Limited. - * ============================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - * - *******************************************************************************/ - -package org.onap.slice.analysis.ms.beans; - -import java.util.Map; - -/** - * - * Model class for configuration policy - * - */ - -public class ConfigPolicy { - - private static ConfigPolicy instance = null; - private Map config; - - protected ConfigPolicy() { - - } - - /** - * Get instance of class. - */ - public static ConfigPolicy getInstance() { - if (instance == null) { - instance = new ConfigPolicy(); - } - return instance; - } - - /** - * Get config param of ConfigPolicy - */ - public Map getConfig() { - return config; - } - - /** - * set config param of ConfigPolicy - */ - public void setConfig(Map config) { - this.config = config; - } - - /** - * Return ConfigPolicy instance as String - */ - @Override - public String toString() { - return "ConfigPolicy [config=" + config + "]"; - } -} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/beans/Configuration.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/beans/Configuration.java deleted file mode 100644 index c7072343..00000000 --- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/beans/Configuration.java +++ /dev/null @@ -1,242 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * slice-analysis-ms - * ================================================================================ - * Copyright (C) 2020 Wipro Limited. - * ============================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - * - *******************************************************************************/ - -package org.onap.slice.analysis.ms.beans; - -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.List; -import java.util.Map; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Model class for the application Configuration - */ -public class Configuration { - private static Logger log = LoggerFactory.getLogger(Configuration.class); - - private static Configuration instance = null; - private String pgHost; - private int pgPort; - private String pgUsername; - private String pgPassword; - private List dmaapServers; - private String configDbService; - private String cg; - private String cid; - private int pollingInterval; - private int pollingTimeout; - private String aafUsername; - private String aafPassword; - private Map streamsSubscribes; - private Map streamsPublishes; - - /** - * Check if topic is secure. - */ - public boolean isSecured() { - return (aafUsername != null); - - } - - public String getAafUsername() { - return aafUsername; - } - - public void setAafUsername(String aafUsername) { - this.aafUsername = aafUsername; - } - - public String getAafPassword() { - return aafPassword; - } - - public void setAafPassword(String aafPassword) { - this.aafPassword = aafPassword; - } - - public Map getStreamsSubscribes() { - return streamsSubscribes; - } - - public void setStreamsSubscribes(Map streamsSubscribes) { - this.streamsSubscribes = streamsSubscribes; - } - - public Map getStreamsPublishes() { - return streamsPublishes; - } - - public void setStreamsPublishes(Map streamsPublishes) { - this.streamsPublishes = streamsPublishes; - } - - protected Configuration() { - - } - - /** - * Get instance of class. - */ - public static Configuration getInstance() { - if (instance == null) { - instance = new Configuration(); - } - return instance; - } - - 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 String getPgHost() { - return pgHost; - } - - public void setPgHost(String pgHost) { - this.pgHost = pgHost; - } - - public int getPgPort() { - return pgPort; - } - - public void setPgPort(int pgPort) { - this.pgPort = pgPort; - } - - public String getPgUsername() { - return pgUsername; - } - - public void setPgUsername(String pgUsername) { - this.pgUsername = pgUsername; - } - - public String getPgPassword() { - return pgPassword; - } - - public void setPgPassword(String pgPassword) { - this.pgPassword = pgPassword; - } - - public List getDmaapServers() { - return dmaapServers; - } - - public void setDmaapServers(List dmaapServers) { - this.dmaapServers = dmaapServers; - } - - public String getConfigDbService() { - return configDbService; - } - - public void setConfigDbService(String configDbService) { - this.configDbService = configDbService; - } - - - - @Override - public String toString() { - return "Configuration [pgHost=" + pgHost + ", pgPort=" + pgPort + ", pgUsername=" + pgUsername + ", pgPassword=" - + pgPassword + ", dmaapServers=" + dmaapServers + ", configDbService=" + configDbService + ", cg=" + cg - + ", cid=" + cid + ", pollingInterval=" + pollingInterval + ", pollingTimeout=" + pollingTimeout - + ", aafUsername=" + aafUsername + ", aafPassword=" + aafPassword + ", streamsSubscribes=" - + streamsSubscribes + ", streamsPublishes=" + streamsPublishes + "]"; - } - - /** - * updates application configuration. - */ - public void updateConfigurationFromJsonObject(JsonObject jsonObject) { - - log.info("Updating configuration from CBS"); - - Type mapType = new TypeToken>() { - }.getType(); - - JsonObject subscribes = jsonObject.getAsJsonObject("streams_subscribes"); - streamsSubscribes = new Gson().fromJson(subscribes, mapType); - - JsonObject publishes = jsonObject.getAsJsonObject("streams_publishes"); - streamsPublishes = new Gson().fromJson(publishes, mapType); - - pgPort = jsonObject.get("postgres.port").getAsInt(); - pollingInterval = jsonObject.get("sliceanalysisms.pollingInterval").getAsInt(); - pgPassword = jsonObject.get("postgres.password").getAsString(); - pgUsername = jsonObject.get("postgres.username").getAsString(); - pgHost = jsonObject.get("postgres.host").getAsString(); - - JsonArray servers = jsonObject.getAsJsonArray("sliceanalysisms.dmaap.server"); - Type listType = new TypeToken>() { - }.getType(); - dmaapServers = new Gson().fromJson(servers, listType); - - cg = jsonObject.get("sliceanalysisms.cg").getAsString(); - cid = jsonObject.get("sliceanalysisms.cid").getAsString(); - configDbService = jsonObject.get("sliceanalysisms.configDb.service").getAsString(); - - pollingTimeout = jsonObject.get("sliceanalysisms.pollingInterval").getAsInt(); - - log.info("configuration from CBS {}", this); - - } - - - -} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/configdb/ConfigDbInterfaceService.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/configdb/ConfigDbInterfaceService.java new file mode 100644 index 00000000..488aca81 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/configdb/ConfigDbInterfaceService.java @@ -0,0 +1,127 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ +package org.onap.slice.analysis.ms.configdb; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.annotation.PostConstruct; + +import org.onap.slice.analysis.ms.models.Configuration; +import org.onap.slice.analysis.ms.models.configdb.CellsModel; +import org.onap.slice.analysis.ms.models.configdb.NetworkFunctionModel; +import org.onap.slice.analysis.ms.restclients.ConfigDbRestClient; +import org.onap.slice.analysis.ms.utils.BeanUtil; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; + +/** + * + * Service for config db interfaces + * + */ +@Service +public class ConfigDbInterfaceService implements IConfigDbService { + + private ConfigDbRestClient restclient; + private String configDbBaseUrl = Configuration.getInstance().getConfigDbService(); + + @PostConstruct + public void init() { + this.restclient = BeanUtil.getBean(ConfigDbRestClient.class); + } + + /** + * Fetches the current configuration of an S-NSSAI from config DB + */ + public Map fetchCurrentConfigurationOfSlice(String snssai){ + Map responseMap = null; + String reqUrl=configDbBaseUrl+"/api/sdnc-config-db/v4/profile-config/"+snssai; + + ResponseEntity> response=restclient.sendGetRequest(reqUrl,new ParameterizedTypeReference>() { + }); + responseMap=response.getBody(); + return responseMap; + } + + /** + * Fetches the current configuration of RIC from config DB + */ + public Map> fetchCurrentConfigurationOfRIC(String snssai){ + String reqUrl=configDbBaseUrl+"/api/sdnc-config-db/v4/slice-config/"+snssai; + ResponseEntity>> response=restclient.sendGetRequest(reqUrl, new ParameterizedTypeReference>>() { + }); + return response.getBody(); + } + + /** + * Fetches all the network functions of an S-NSSAI from config DB + */ + public List fetchNetworkFunctionsOfSnssai(String snssai){ + List responseList=new ArrayList<>(); + String reqUrl=configDbBaseUrl+"/api/sdnc-config-db/v4/du-list/"+snssai; + ResponseEntity> response=restclient.sendGetRequest(reqUrl, new ParameterizedTypeReference>() { + }); + for(NetworkFunctionModel networkFn:response.getBody()) { + responseList.add(networkFn.getgNBDUId()); + } + return responseList; + } + + /** + * Fetches the RICS of an S-NSSAI from config DB + */ + public Map> fetchRICsOfSnssai(String snssai){ + + Map> responseMap=new HashMap<>(); + + String reqUrl=configDbBaseUrl+"/api/sdnc-config-db/v4/du-cell-list/"+snssai; + + ResponseEntity>> response=restclient.sendGetRequest(reqUrl, new ParameterizedTypeReference>>() { + }); + + + for (Map.Entry> entry : response.getBody().entrySet()) { + List cellslist=new ArrayList<>(); + for(CellsModel cellmodel:entry.getValue()) { + + cellslist.add(cellmodel.getCellLocalId()); + } + responseMap.put(entry.getKey(), cellslist); + } + + return responseMap; + } + + /** + * Fetches the details of a service + */ + public Map fetchServiceDetails(String snssai){ + String reqUrl=configDbBaseUrl+"/api/sdnc-config-db/v4/subscriber-details/"+snssai; + ResponseEntity> response=restclient.sendGetRequest(reqUrl, new ParameterizedTypeReference>() { + }); + return response.getBody(); + } + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/configdb/IConfigDbService.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/configdb/IConfigDbService.java new file mode 100644 index 00000000..3c8a9f8a --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/configdb/IConfigDbService.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.slice.analysis.ms.configdb; + +import java.util.List; +import java.util.Map; + +/** + * + * Interface for config db service + * + */ +public interface IConfigDbService { + + public Map> fetchRICsOfSnssai(String snssai); + public List fetchNetworkFunctionsOfSnssai(String snssai); + public Map fetchCurrentConfigurationOfSlice(String snssai); + public Map> fetchCurrentConfigurationOfRIC(String snssai); + public Map fetchServiceDetails(String snssai); +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/controller/ConfigFetchFromCbs.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/controller/ConfigFetchFromCbs.java index e8e4e11b..ea148f25 100644 --- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/controller/ConfigFetchFromCbs.java +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/controller/ConfigFetchFromCbs.java @@ -34,8 +34,8 @@ import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api.CbsRequests; import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.CbsRequest; import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.EnvProperties; import org.onap.dcaegen2.services.sdk.rest.services.model.logging.RequestDiagnosticContext; -import org.onap.slice.analysis.ms.beans.ConfigPolicy; -import org.onap.slice.analysis.ms.beans.Configuration; +import org.onap.slice.analysis.ms.models.ConfigPolicy; +import org.onap.slice.analysis.ms.models.Configuration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/DmaapClient.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/DmaapClient.java index 6e0ea401..08a89541 100644 --- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/DmaapClient.java +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/DmaapClient.java @@ -30,7 +30,7 @@ import java.util.concurrent.TimeUnit; import javax.annotation.PostConstruct; -import org.onap.slice.analysis.ms.beans.Configuration; +import org.onap.slice.analysis.ms.models.Configuration; import org.onap.slice.analysis.ms.utils.DmaapUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -69,23 +69,29 @@ public class DmaapClient { @SuppressWarnings("unchecked") public synchronized void startClient() { - Map streamSubscribes = Configuration.getInstance().getStreamsSubscribes(); + Map streamSubscribes = configuration.getStreamsSubscribes(); String pmTopicUrl = ((Map) ((Map) streamSubscribes .get("performance_management_topic")).get("dmaap_info")).get("topic_url"); String[] pmTopicSplit = pmTopicUrl.split("\\/"); String pmTopic = pmTopicSplit[pmTopicSplit.length - 1]; log.debug("pm topic : {}", pmTopic); + String policyResponseTopicUrl = ((Map) ((Map) streamSubscribes .get("dcae_cl_response_topic")).get("dmaap_info")).get("topic_url"); String[] policyResponseTopicUrlSplit = policyResponseTopicUrl.split("\\/"); String policyResponseTopic = policyResponseTopicUrlSplit[policyResponseTopicUrlSplit.length - 1]; log.debug("policyResponse Topic : {}", policyResponseTopic); - CambriaConsumer pmNotifCambriaConsumer = null; - CambriaConsumer policyResponseCambriaConsumer = null; - - pmNotifCambriaConsumer = dmaapUtils.buildConsumer(configuration, pmTopic); - policyResponseCambriaConsumer = dmaapUtils.buildConsumer(configuration, policyResponseTopic); + + String intelligentSlicingTopicUrl = ((Map) ((Map) streamSubscribes + .get("intelligent_slicing_topic")).get("dmaap_info")).get("topic_url"); + String[] intelligentSlicingTopicSplit = intelligentSlicingTopicUrl.split("\\/"); + String intelligentSlicingTopic = intelligentSlicingTopicSplit[intelligentSlicingTopicSplit.length - 1]; + log.debug("intelligent slicing topic : {}", pmTopic); + + CambriaConsumer pmNotifCambriaConsumer = dmaapUtils.buildConsumer(configuration, pmTopic); + CambriaConsumer policyResponseCambriaConsumer = dmaapUtils.buildConsumer(configuration, policyResponseTopic); + CambriaConsumer intelligentSlicingCambriaConsumer = dmaapUtils.buildConsumer(configuration, intelligentSlicingTopic); ScheduledExecutorService executorPool; @@ -97,16 +103,21 @@ public class DmaapClient { executorPool.scheduleAtFixedRate(pmNotificationConsumer, 0, configuration.getPollingInterval(), TimeUnit.SECONDS); - // create notification consumers for Policy - NotificationConsumer policyNotificationConsumer = new NotificationConsumer(policyResponseCambriaConsumer, - new PolicyNotificationCallback()); - // start policy notification consumer threads - executorPool = Executors.newScheduledThreadPool(10); - executorPool.scheduleAtFixedRate(policyNotificationConsumer, 0, configuration.getPollingInterval(), - TimeUnit.SECONDS); - - - + // create notification consumers for Policy + NotificationConsumer policyNotificationConsumer = new NotificationConsumer(policyResponseCambriaConsumer, + new PolicyNotificationCallback()); + // start policy notification consumer threads + executorPool = Executors.newScheduledThreadPool(10); + executorPool.scheduleAtFixedRate(policyNotificationConsumer, 0, configuration.getPollingInterval(), + TimeUnit.SECONDS); + + // create notification consumers for ML MS + NotificationConsumer intelligentSlicingConsumer = new NotificationConsumer(intelligentSlicingCambriaConsumer, + new IntelligentSlicingCallback()); + // start intelligent Slicing notification consumer threads + executorPool = Executors.newScheduledThreadPool(10); + executorPool.scheduleAtFixedRate(intelligentSlicingConsumer, 0, configuration.getPollingInterval(), + TimeUnit.SECONDS); } } diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/IntelligentSlicingCallback.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/IntelligentSlicingCallback.java new file mode 100644 index 00000000..dd6760ba --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/IntelligentSlicingCallback.java @@ -0,0 +1,69 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.slice.analysis.ms.dmaap; + +import java.io.IOException; + +import org.onap.slice.analysis.ms.models.MLOutputModel; +import org.onap.slice.analysis.ms.service.MLMessageProcessor; +import org.onap.slice.analysis.ms.utils.BeanUtil; +import org.slf4j.Logger; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; + +/** + * Handles Notification on dmaap for ML ms events + */ +public class IntelligentSlicingCallback implements NotificationCallback { + private static final Logger log = org.slf4j.LoggerFactory.getLogger(IntelligentSlicingCallback.class); + private MLMessageProcessor mlMsMessageProcessor; + + public IntelligentSlicingCallback() { + mlMsMessageProcessor = BeanUtil.getBean(MLMessageProcessor.class); + } + + /** + * Trigger on Notification from ML ms + */ + @Override + public void activateCallBack(String msg) { + handlePolicyNotification(msg); + } + + /** + * Parse and take actions on reception of Notification from ML ms + * @param msg + */ + private void handlePolicyNotification(String msg) { + log.info("Message received from ML ms: {}" ,msg); + ObjectMapper obj = new ObjectMapper(); + MLOutputModel output = null; + try { + output = obj.readValue(msg, new TypeReference(){}); + mlMsMessageProcessor.processMLMsg(output); + } + catch (IOException e) { + log.error("Error converting ML msg to object, {}",e.getMessage()); + } + } +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/NewPmNotification.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/NewPmNotification.java index 5c1f496b..66c3f706 100644 --- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/NewPmNotification.java +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/NewPmNotification.java @@ -32,7 +32,7 @@ import org.springframework.stereotype.Component; @Component public class NewPmNotification { - private Boolean newNotif; + private boolean newNotif; /** * Initialize new pm Notification flag @@ -42,15 +42,15 @@ public class NewPmNotification { newNotif = false; } - public Boolean getNewNotif() { + public boolean getNewNotif() { return newNotif; } - public void setNewNotif(Boolean newNotif) { + public void setNewNotif(boolean newNotif) { this.newNotif = newNotif; } - public NewPmNotification(Boolean newNotif) { + public NewPmNotification(boolean newNotif) { super(); this.newNotif = newNotif; } diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/NotificationCallback.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/NotificationCallback.java index 427b4048..ce1ebd6f 100644 --- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/NotificationCallback.java +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/NotificationCallback.java @@ -21,7 +21,7 @@ package org.onap.slice.analysis.ms.dmaap; -public abstract class NotificationCallback { +public interface NotificationCallback { public abstract void activateCallBack(String msg); diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/PmNotificationCallback.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/PmNotificationCallback.java index 17e50aca..963165d2 100644 --- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/PmNotificationCallback.java +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/PmNotificationCallback.java @@ -30,7 +30,7 @@ import org.slf4j.LoggerFactory; /** * Handles Notification on dmaap for Performance events */ -public class PmNotificationCallback extends NotificationCallback { +public class PmNotificationCallback implements NotificationCallback { private static Logger log = LoggerFactory.getLogger(PmNotificationCallback.class); diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/PolicyDmaapClient.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/PolicyDmaapClient.java index 81ca9ef1..06604040 100644 --- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/PolicyDmaapClient.java +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/PolicyDmaapClient.java @@ -25,7 +25,7 @@ import com.att.nsa.cambria.client.CambriaBatchingPublisher; import java.io.IOException; import java.util.Map; -import org.onap.slice.analysis.ms.beans.Configuration; +import org.onap.slice.analysis.ms.models.Configuration; import org.onap.slice.analysis.ms.utils.DmaapUtils; /** diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/PolicyNotificationCallback.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/PolicyNotificationCallback.java index 57aadd18..146b60a9 100644 --- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/PolicyNotificationCallback.java +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/PolicyNotificationCallback.java @@ -26,7 +26,7 @@ import org.slf4j.Logger; /** * Handles Notification on dmaap for Policy events */ -public class PolicyNotificationCallback extends NotificationCallback { +public class PolicyNotificationCallback implements NotificationCallback { private static final Logger log = org.slf4j.LoggerFactory.getLogger(PolicyNotificationCallback.class); @@ -43,7 +43,7 @@ public class PolicyNotificationCallback extends NotificationCallback { * @param msg */ private void handlePolicyNotification(String msg) { - log.info("Message received from policy: " +msg); - //TBD - actions to perform on reception of notification from policy + log.info("Message received from policy: " +msg); + //TBD - actions to perform on reception of notification from policy } } diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/CUModel.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/CUModel.java new file mode 100644 index 00000000..6473ab23 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/CUModel.java @@ -0,0 +1,101 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.slice.analysis.ms.models; + +import java.util.List; + +/** + * Model class for CU model + */ +public class CUModel { + + private String gNBCUName; + private String nearRTRICId; + private List cellCUList; + + public String getgNBCUName() { + return gNBCUName; + } + + public void setgNBCUName(String gNBCUName) { + this.gNBCUName = gNBCUName; + } + + public String getNearRTRICId() { + return nearRTRICId; + } + + public void setNearRTRICId(String nearRTRICId) { + this.nearRTRICId = nearRTRICId; + } + + public List getCellCUList() { + return cellCUList; + } + + public void setCellCUList(List cellCUList) { + this.cellCUList = cellCUList; + } + + @Override + public String toString() { + return "CUModel [gNBCUName=" + gNBCUName + ", nearRTRICId=" + nearRTRICId + ", cellCUList=" + cellCUList + "]"; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((cellCUList == null) ? 0 : cellCUList.hashCode()); + result = prime * result + ((gNBCUName == null) ? 0 : gNBCUName.hashCode()); + result = prime * result + ((nearRTRICId == null) ? 0 : nearRTRICId.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; + CUModel other = (CUModel) obj; + if (cellCUList == null) { + if (other.cellCUList != null) + return false; + } else if (!cellCUList.equals(other.cellCUList)) + return false; + if (gNBCUName == null) { + if (other.gNBCUName != null) + return false; + } else if (!gNBCUName.equals(other.gNBCUName)) + return false; + if (nearRTRICId == null) { + if (other.nearRTRICId != null) + return false; + } else if (!nearRTRICId.equals(other.nearRTRICId)) + return false; + return true; + } + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/CellCUList.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/CellCUList.java new file mode 100644 index 00000000..cd566778 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/CellCUList.java @@ -0,0 +1,80 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.slice.analysis.ms.models; + +/** + * Model class for cell information + */ +public class CellCUList { + + private Integer cellLocalId; + private ConfigData configData; + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((cellLocalId == null) ? 0 : cellLocalId.hashCode()); + result = prime * result + ((configData == null) ? 0 : configData.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; + CellCUList other = (CellCUList) obj; + if (cellLocalId == null) { + if (other.cellLocalId != null) + return false; + } else if (!cellLocalId.equals(other.cellLocalId)) + return false; + if (configData == null) { + if (other.configData != null) + return false; + } else if (!configData.equals(other.configData)) + return false; + return true; + } + + public Integer getCellLocalId() { + return cellLocalId; + } + + public void setCellLocalId(Integer cellLocalId) { + this.cellLocalId = cellLocalId; + } + + public ConfigData getConfigData() { + return configData; + } + + public void setConfigData(ConfigData configData) { + this.configData = configData; + } + + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/ConfigData.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/ConfigData.java new file mode 100644 index 00000000..f8711154 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/ConfigData.java @@ -0,0 +1,94 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.slice.analysis.ms.models; + +/** + * Model class for the config data + */ +public class ConfigData { + + private String maxNumberofConns; + private String predictedMaxNumberofConns; + private String lastUpdatedTS; + + public String getMaxNumberofConns() { + return maxNumberofConns; + } + + public void setMaxNumberofConns(String maxNumberofConns) { + this.maxNumberofConns = maxNumberofConns; + } + + public String getPredictedMaxNumberofConns() { + return predictedMaxNumberofConns; + } + + public void setPredictedMaxNumberofConns(String predictedMaxNumberofConns) { + this.predictedMaxNumberofConns = predictedMaxNumberofConns; + } + + public String getLastUpdatedTS() { + return lastUpdatedTS; + } + + public void setLastUpdatedTS(String lastUpdatedTS) { + this.lastUpdatedTS = lastUpdatedTS; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((lastUpdatedTS == null) ? 0 : lastUpdatedTS.hashCode()); + result = prime * result + ((maxNumberofConns == null) ? 0 : maxNumberofConns.hashCode()); + result = prime * result + ((predictedMaxNumberofConns == null) ? 0 : predictedMaxNumberofConns.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; + ConfigData other = (ConfigData) obj; + if (lastUpdatedTS == null) { + if (other.lastUpdatedTS != null) + return false; + } else if (!lastUpdatedTS.equals(other.lastUpdatedTS)) + return false; + if (maxNumberofConns == null) { + if (other.maxNumberofConns != null) + return false; + } else if (!maxNumberofConns.equals(other.maxNumberofConns)) + return false; + if (predictedMaxNumberofConns == null) { + if (other.predictedMaxNumberofConns != null) + return false; + } else if (!predictedMaxNumberofConns.equals(other.predictedMaxNumberofConns)) + return false; + return true; + } + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/ConfigPolicy.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/ConfigPolicy.java new file mode 100644 index 00000000..6f2b4ec6 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/ConfigPolicy.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.slice.analysis.ms.models; + +import java.util.Map; + +/** + * + * Model class for configuration policy + * + */ + +public class ConfigPolicy { + + private static ConfigPolicy instance = null; + private Map config; + + protected ConfigPolicy() { + + } + + /** + * Get instance of class. + */ + public static ConfigPolicy getInstance() { + if (instance == null) { + instance = new ConfigPolicy(); + } + return instance; + } + + /** + * Get config param of ConfigPolicy + */ + public Map getConfig() { + return config; + } + + /** + * set config param of ConfigPolicy + */ + public void setConfig(Map config) { + this.config = config; + } + + /** + * Return ConfigPolicy instance as String + */ + @Override + public String toString() { + return "ConfigPolicy [config=" + config + "]"; + } +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/Configuration.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/Configuration.java new file mode 100644 index 00000000..25a80463 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/Configuration.java @@ -0,0 +1,265 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.slice.analysis.ms.models; + +import java.lang.reflect.Type; +import java.util.List; +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import com.google.gson.reflect.TypeToken; + +/** + * Model class for the application Configuration + */ +public class Configuration { + private static Logger log = LoggerFactory.getLogger(Configuration.class); + + private static Configuration instance = null; + private String pgHost; + private int pgPort; + private String pgUsername; + private String pgPassword; + private List dmaapServers; + private String configDbService; + private String cg; + private String cid; + private int pollingInterval; + private int pollingTimeout; + private String aafUsername; + private String aafPassword; + private Map streamsSubscribes; + private Map streamsPublishes; + private int samples; + private int minPercentageChange; + private long initialDelaySeconds; + /** + * Check if topic is secure. + */ + public boolean isSecured() { + return (aafUsername != null); + + } + + public String getAafUsername() { + return aafUsername; + } + + public void setAafUsername(String aafUsername) { + this.aafUsername = aafUsername; + } + + public String getAafPassword() { + return aafPassword; + } + + public void setAafPassword(String aafPassword) { + this.aafPassword = aafPassword; + } + + public Map getStreamsSubscribes() { + return streamsSubscribes; + } + + public void setStreamsSubscribes(Map streamsSubscribes) { + this.streamsSubscribes = streamsSubscribes; + } + + public Map getStreamsPublishes() { + return streamsPublishes; + } + + public void setStreamsPublishes(Map streamsPublishes) { + this.streamsPublishes = streamsPublishes; + } + + protected Configuration() { + + } + + /** + * Get instance of class. + */ + public static Configuration getInstance() { + if (instance == null) { + instance = new Configuration(); + } + return instance; + } + + 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 String getPgHost() { + return pgHost; + } + + public void setPgHost(String pgHost) { + this.pgHost = pgHost; + } + + public int getPgPort() { + return pgPort; + } + + public void setPgPort(int pgPort) { + this.pgPort = pgPort; + } + + public String getPgUsername() { + return pgUsername; + } + + public void setPgUsername(String pgUsername) { + this.pgUsername = pgUsername; + } + + public String getPgPassword() { + return pgPassword; + } + + public void setPgPassword(String pgPassword) { + this.pgPassword = pgPassword; + } + + public List getDmaapServers() { + return dmaapServers; + } + + public void setDmaapServers(List dmaapServers) { + this.dmaapServers = dmaapServers; + } + + public String getConfigDbService() { + return configDbService; + } + + public void setConfigDbService(String configDbService) { + this.configDbService = configDbService; + } + + public int getSamples() { + return samples; + } + + public void setSamples(int samples) { + this.samples = samples; + } + + public int getMinPercentageChange() { + return minPercentageChange; + } + + public void setMinPercentageChange(int minPercentageChange) { + this.minPercentageChange = minPercentageChange; + } + + public long getInitialDelaySeconds() { + return initialDelaySeconds; + } + + public void setInitialDelaySeconds(long initialDelaySeconds) { + this.initialDelaySeconds = initialDelaySeconds; + } + + @Override + public String toString() { + return "Configuration [pgHost=" + pgHost + ", pgPort=" + pgPort + ", pgUsername=" + pgUsername + ", pgPassword=" + + pgPassword + ", dmaapServers=" + dmaapServers + ", configDbService=" + configDbService + ", cg=" + cg + + ", cid=" + cid + ", pollingInterval=" + pollingInterval + ", pollingTimeout=" + pollingTimeout + + ", aafUsername=" + aafUsername + ", aafPassword=" + aafPassword + ", streamsSubscribes=" + + streamsSubscribes + ", streamsPublishes=" + streamsPublishes + ", samples=" + samples + + ", minPercentageChange=" + minPercentageChange + ", initialDelaySeconds=" + initialDelaySeconds + "]"; + } + + /** + * updates application configuration. + */ + public void updateConfigurationFromJsonObject(JsonObject jsonObject) { + + log.info("Updating configuration from CBS"); + + Type mapType = new TypeToken>() { + }.getType(); + + JsonObject subscribes = jsonObject.getAsJsonObject("streams_subscribes"); + streamsSubscribes = new Gson().fromJson(subscribes, mapType); + + JsonObject publishes = jsonObject.getAsJsonObject("streams_publishes"); + streamsPublishes = new Gson().fromJson(publishes, mapType); + + pgPort = jsonObject.get("postgres.port").getAsInt(); + pollingInterval = jsonObject.get("sliceanalysisms.pollingInterval").getAsInt(); + pgPassword = jsonObject.get("postgres.password").getAsString(); + pgUsername = jsonObject.get("postgres.username").getAsString(); + pgHost = jsonObject.get("postgres.host").getAsString(); + + JsonArray servers = jsonObject.getAsJsonArray("sliceanalysisms.dmaap.server"); + Type listType = new TypeToken>() {}.getType(); + dmaapServers = new Gson().fromJson(servers, listType); + + cg = jsonObject.get("sliceanalysisms.cg").getAsString(); + cid = jsonObject.get("sliceanalysisms.cid").getAsString(); + configDbService = jsonObject.get("sliceanalysisms.configDb.service").getAsString(); + + pollingTimeout = jsonObject.get("sliceanalysisms.pollingTimeout").getAsInt(); + samples = jsonObject.get("sliceanalysisms.samples").getAsInt(); + minPercentageChange = jsonObject.get("sliceanalysisms.minPercentageChange").getAsInt(); + initialDelaySeconds = jsonObject.get("sliceanalysisms.initialDelaySeconds").getAsLong(); + + log.info("configuration from CBS {}", this); + } +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/MLOutputModel.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/MLOutputModel.java new file mode 100644 index 00000000..7533d215 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/MLOutputModel.java @@ -0,0 +1,82 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.slice.analysis.ms.models; + +import java.util.List; + +/** + * Model class for ML output object + */ +public class MLOutputModel { + private String snssai; + private List data; + public String getSnssai() { + return snssai; + } + public void setSnssai(String snssai) { + this.snssai = snssai; + } + public List getData() { + return data; + } + public void setData(List data) { + this.data = data; + } + + @Override + public String toString() { + return "MLOutputModel [snssai=" + snssai + ", data=" + data + "]"; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((data == null) ? 0 : data.hashCode()); + result = prime * result + ((snssai == null) ? 0 : snssai.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; + MLOutputModel other = (MLOutputModel) obj; + if (data == null) { + if (other.data != null) + return false; + } else if (!data.equals(other.data)) + return false; + if (snssai == null) { + if (other.snssai != null) + return false; + } else if (!snssai.equals(other.snssai)) + return false; + return true; + } + + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/MeasurementObject.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/MeasurementObject.java new file mode 100644 index 00000000..047c9856 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/MeasurementObject.java @@ -0,0 +1,96 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + + +package org.onap.slice.analysis.ms.models; + +import java.util.Map; + +/** + * Model class for the Measurement Object + */ +public class MeasurementObject { + private String measurementObjectId; + private Map pmData; + + public String getMeasurementObjectId() { + return measurementObjectId; + } + + public void setMeasurementObjectId(String measurementObjectId) { + this.measurementObjectId = measurementObjectId; + } + + public Map getPmData() { + return pmData; + } + + public void setPmData(Map pmData) { + this.pmData = pmData; + } + + public MeasurementObject(String measurementObjectId, Map pmData) { + super(); + this.measurementObjectId = measurementObjectId; + this.pmData = pmData; + } + + public MeasurementObject(String measurementObjectId) { + super(); + this.measurementObjectId = measurementObjectId; + } + + public MeasurementObject() { + + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((measurementObjectId == null) ? 0 : measurementObjectId.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; + MeasurementObject other = (MeasurementObject) obj; + if (measurementObjectId == null) { + if (other.measurementObjectId != null) + return false; + } else if (!measurementObjectId.equals(other.measurementObjectId)) + return false; + return true; + } + + @Override + public String toString() { + return "MeasurementObject [measurementObjectId=" + measurementObjectId + ", pmData=" + pmData + "]"; + } + + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/SubCounter.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/SubCounter.java new file mode 100644 index 00000000..2990d365 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/SubCounter.java @@ -0,0 +1,76 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + + +package org.onap.slice.analysis.ms.models; + +/** + * Model class for the SubCounter Object which servers as key for PM data Queue + */ +public final class SubCounter { + final String networkFunction; + final String measuredObject; + + public SubCounter(String networkFunction, String measuredObject) { + super(); + this.networkFunction = networkFunction; + this.measuredObject = measuredObject; + } + + public String getNetworkFunction() { + return networkFunction; + } + + public String getMeasuredObject() { + return measuredObject; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((networkFunction == null) ? 0 : networkFunction.hashCode()); + result = prime * result + ((measuredObject == null) ? 0 : measuredObject.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; + SubCounter other = (SubCounter) obj; + if (networkFunction == null) { + if (other.networkFunction != null) + return false; + } else if (!networkFunction.equals(other.networkFunction)) + return false; + if (measuredObject == null) { + if (other.measuredObject != null) + return false; + } else if (!measuredObject.equals(other.measuredObject)) + return false; + return true; + } +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/configdb/CellsModel.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/configdb/CellsModel.java new file mode 100644 index 00000000..e024bf7c --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/configdb/CellsModel.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ +package org.onap.slice.analysis.ms.models.configdb; + + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * Model class for the CellsModel Object + */ + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CellsModel { + + private String cellLocalId; + + + public String getCellLocalId() { + return cellLocalId; + } + + public void setCellLocalId(String cellLocalId) { + this.cellLocalId = cellLocalId; + } + + @Override + public String toString() { + return "CellsModel [cellLocalId=" + cellLocalId + "]"; + } + + + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/configdb/NetworkFunctionModel.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/configdb/NetworkFunctionModel.java new file mode 100644 index 00000000..46291d51 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/configdb/NetworkFunctionModel.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ +package org.onap.slice.analysis.ms.models.configdb; + + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * Model class for the NetworkFunction Object + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class NetworkFunctionModel { + + private String gNBDUId; + + + public String getgNBDUId() { + return gNBDUId; + } + + public void setgNBDUId(String gNBDUId) { + this.gNBDUId = gNBDUId; + } + + @Override + public String toString() { + return "NetworkFunctionModel [gNBDUId=" + gNBDUId + "]"; + } + + + + + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/CommonEventHeader.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/CommonEventHeader.java new file mode 100644 index 00000000..08c2b983 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/CommonEventHeader.java @@ -0,0 +1,138 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.slice.analysis.ms.models.pmnotification; + +/** + * Model class for the CommonEventHeader Object + */ +public class CommonEventHeader { + + private String domain; + private String eventId; + private long sequence; + private String eventName; + private String sourceName; + private String reportingEntityName; + private String priority; + private long startEpochMicrosec; + private long lastEpochMicrosec; + private String version; + private String vesEventListenerVersion; + private String timeZoneOffset; + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public String getEventId() { + return eventId; + } + + public void setEventId(String eventId) { + this.eventId = eventId; + } + + public long getSequence() { + return sequence; + } + + public void setSequence(long sequence) { + this.sequence = sequence; + } + + public String getEventName() { + return eventName; + } + + public void setEventName(String eventName) { + this.eventName = eventName; + } + + public String getSourceName() { + return sourceName; + } + + public void setSourceName(String sourceName) { + this.sourceName = sourceName; + } + + public String getReportingEntityName() { + return reportingEntityName; + } + + public void setReportingEntityName(String reportingEntityName) { + this.reportingEntityName = reportingEntityName; + } + + public String getPriority() { + return priority; + } + + public void setPriority(String priority) { + this.priority = priority; + } + + public long getStartEpochMicrosec() { + return startEpochMicrosec; + } + + public void setStartEpochMicrosec(long startEpochMicrosec) { + this.startEpochMicrosec = startEpochMicrosec; + } + + public long getLastEpochMicrosec() { + return lastEpochMicrosec; + } + + public void setLastEpochMicrosec(long lastEpochMicrosec) { + this.lastEpochMicrosec = lastEpochMicrosec; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getVesEventListenerVersion() { + return vesEventListenerVersion; + } + + public void setVesEventListenerVersion(String vesEventListenerVersion) { + this.vesEventListenerVersion = vesEventListenerVersion; + } + + public String getTimeZoneOffset() { + return timeZoneOffset; + } + + public void setTimeZoneOffset(String timeZoneOffset) { + this.timeZoneOffset = timeZoneOffset; + } + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/Event.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/Event.java new file mode 100644 index 00000000..4e41e261 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/Event.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.slice.analysis.ms.models.pmnotification; + +/** + * Model class for the Event Object + */ +public class Event { + + private CommonEventHeader commonEventHeader; + private Perf3gppFields perf3gppFields; + + public CommonEventHeader getCommonEventHeader() { + return commonEventHeader; + } + + public void setCommonEventHeader(CommonEventHeader commonEventHeader) { + this.commonEventHeader = commonEventHeader; + } + + public Perf3gppFields getPerf3gppFields() { + return perf3gppFields; + } + + public void setPerf3gppFields(Perf3gppFields perf3gppFields) { + this.perf3gppFields = perf3gppFields; + } +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasDataCollection.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasDataCollection.java new file mode 100644 index 00000000..f5e36c28 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasDataCollection.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.slice.analysis.ms.models.pmnotification; + +import java.util.List; + +/** + * Model class for the MeasDataCollection Object + */ +public class MeasDataCollection { + + private long granularityPeriod; + private String measuredEntityUserName; + private String measuredEntityDn; + private String measuredEntitySoftwareVersion; + private List measInfoList; + + public long getGranularityPeriod() { + return granularityPeriod; + } + + public void setGranularityPeriod(long granularityPeriod) { + this.granularityPeriod = granularityPeriod; + } + + public String getMeasuredEntityUserName() { + return measuredEntityUserName; + } + + public void setMeasuredEntityUserName(String measuredEntityUserName) { + this.measuredEntityUserName = measuredEntityUserName; + } + + public String getMeasuredEntityDn() { + return measuredEntityDn; + } + + public void setMeasuredEntityDn(String measuredEntityDn) { + this.measuredEntityDn = measuredEntityDn; + } + + public String getMeasuredEntitySoftwareVersion() { + return measuredEntitySoftwareVersion; + } + + public void setMeasuredEntitySoftwareVersion(String measuredEntitySoftwareVersion) { + this.measuredEntitySoftwareVersion = measuredEntitySoftwareVersion; + } + + public List getMeasInfoList() { + return measInfoList; + } + + public void setMeasInfoList(List measInfoList) { + this.measInfoList = measInfoList; + } + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasInfoId.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasInfoId.java new file mode 100644 index 00000000..5b8f6b31 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasInfoId.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.slice.analysis.ms.models.pmnotification; + +/** + * Model class for the MeasInfoId Object + */ +public class MeasInfoId { + + private String sMeasInfoId; + + public String getsMeasInfoId() { + return sMeasInfoId; + } + + public void setsMeasInfoId(String sMeasInfoId) { + this.sMeasInfoId = sMeasInfoId; + } + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasInfoList.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasInfoList.java new file mode 100644 index 00000000..34283a7d --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasInfoList.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.slice.analysis.ms.models.pmnotification; + +import java.util.List; + +/** + * Model class for the MeasInfoList Object + */ +public class MeasInfoList { + + private MeasInfoId measInfoId; + private MeasTypes measTypes; + private List measValuesList = null; + + public MeasInfoId getMeasInfoId() { + return measInfoId; + } + + public void setMeasInfoId(MeasInfoId measInfoId) { + this.measInfoId = measInfoId; + } + + public MeasTypes getMeasTypes() { + return measTypes; + } + + public void setMeasTypes(MeasTypes measTypes) { + this.measTypes = measTypes; + } + + public List getMeasValuesList() { + return measValuesList; + } + + public void setMeasValuesList(List measValuesList) { + this.measValuesList = measValuesList; + } + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasResult.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasResult.java new file mode 100644 index 00000000..1e418001 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasResult.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.slice.analysis.ms.models.pmnotification; + +/** + * Model class for the MeasResult Object + */ +public class MeasResult { + + private int p; + private String sValue; + + public int getP() { + return p; + } + + public void setP(int p) { + this.p = p; + } + + public String getsValue() { + return sValue; + } + + public void setsValue(String sValue) { + this.sValue = sValue; + } + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasTypes.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasTypes.java new file mode 100644 index 00000000..f441166d --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasTypes.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.slice.analysis.ms.models.pmnotification; + +import java.util.List; + +/** + * Model class for the MeasTypes Object + */ +public class MeasTypes { + + private List sMeasTypesList; + + public List getsMeasTypesList() { + return sMeasTypesList; + } + + public void setsMeasTypesList(List sMeasTypesList) { + this.sMeasTypesList = sMeasTypesList; + } + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasValuesList.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasValuesList.java new file mode 100644 index 00000000..38b7c23c --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasValuesList.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.slice.analysis.ms.models.pmnotification; + +import java.util.List; + +/** + * Model class for the MeasValuesList Object + */ +public class MeasValuesList { + + private String measObjInstId; + private String suspectFlag; + private List measResults = null; + + public String getMeasObjInstId() { + return measObjInstId; + } + + public void setMeasObjInstId(String measObjInstId) { + this.measObjInstId = measObjInstId; + } + + public String getSuspectFlag() { + return suspectFlag; + } + + public void setSuspectFlag(String suspectFlag) { + this.suspectFlag = suspectFlag; + } + + public List getMeasResults() { + return measResults; + } + + public void setMeasResults(List measResults) { + this.measResults = measResults; + } +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/Perf3gppFields.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/Perf3gppFields.java new file mode 100644 index 00000000..dfe9cbca --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/Perf3gppFields.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.slice.analysis.ms.models.pmnotification; + +/** + * Model class for the Perf3gppFields Object + */ +public class Perf3gppFields { + + private String perf3gppFieldsVersion; + private MeasDataCollection measDataCollection; + + public String getPerf3gppFieldsVersion() { + return perf3gppFieldsVersion; + } + + public void setPerf3gppFieldsVersion(String perf3gppFieldsVersion) { + this.perf3gppFieldsVersion = perf3gppFieldsVersion; + } + + public MeasDataCollection getMeasDataCollection() { + return measDataCollection; + } + + public void setMeasDataCollection(MeasDataCollection measDataCollection) { + this.measDataCollection = measDataCollection; + } + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/PmNotification.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/PmNotification.java new file mode 100644 index 00000000..a2dc49e8 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/PmNotification.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.slice.analysis.ms.models.pmnotification; + +/** + * Model class for the PmNotification Object + */ +public class PmNotification { + + Event event; + + public Event getEvent() { + return event; + } + + public void setEvent(Event event) { + this.event = event; + } + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/policy/AAI.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/policy/AAI.java new file mode 100644 index 00000000..73d94d75 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/policy/AAI.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.slice.analysis.ms.models.policy; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Model class for the AAI Object + */ +public class AAI { + @JsonProperty("vserver.is-closed-loop-disabled") + private String vserverIsClosedLoopDisabled; + @JsonProperty("vserver.prov-status") + private String vserverProvStatus; + @JsonProperty("vserver.vserver-name") + private String vserverVserverName; + + public String getVserverIsClosedLoopDisabled() { + return vserverIsClosedLoopDisabled; + } + + public void setVserverIsClosedLoopDisabled(String vserverIsClosedLoopDisabled) { + this.vserverIsClosedLoopDisabled = vserverIsClosedLoopDisabled; + } + + public String getVserverProvStatus() { + return vserverProvStatus; + } + + public void setVserverProvStatus(String vserverProvStatus) { + this.vserverProvStatus = vserverProvStatus; + } + + public String getVserverVserverName() { + return vserverVserverName; + } + + public void setVserverVserverName(String vserverVserverName) { + this.vserverVserverName = vserverVserverName; + } + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/policy/AdditionalProperties.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/policy/AdditionalProperties.java new file mode 100644 index 00000000..0d4e4bd8 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/policy/AdditionalProperties.java @@ -0,0 +1,75 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.slice.analysis.ms.models.policy; + +import java.util.List; +import java.util.Map; + +/** + * Model class for the AdditionalProperties Object + */ +public class AdditionalProperties { + private String modifyAction; + private List snssaiList; + private String sliceProfileId; + private T resourceConfig; + private Map nsiInfo; + private String scriptName; + public String getModifyAction() { + return modifyAction; + } + public void setModifyAction(String modifyAction) { + this.modifyAction = modifyAction; + } + public List getSnssaiList() { + return snssaiList; + } + public void setSnssaiList(List snssaiList) { + this.snssaiList = snssaiList; + } + public String getSliceProfileId() { + return sliceProfileId; + } + public void setSliceProfileId(String sliceProfileId) { + this.sliceProfileId = sliceProfileId; + } + public T getResourceConfig() { + return resourceConfig; + } + public void setResourceConfig(T resourceConfig) { + this.resourceConfig = resourceConfig; + } + public Map getNsiInfo() { + return nsiInfo; + } + public void setNsiInfo(Map nsiInfo) { + this.nsiInfo = nsiInfo; + } + public String getScriptName() { + return scriptName; + } + public void setScriptName(String scriptName) { + this.scriptName = scriptName; + } + + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/policy/OnsetMessage.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/policy/OnsetMessage.java new file mode 100644 index 00000000..671a9561 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/policy/OnsetMessage.java @@ -0,0 +1,136 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.slice.analysis.ms.models.policy; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Model class for the OnsetMessage Object + */ +public class OnsetMessage { + + private String closedLoopControlName; + private Long closedLoopAlarmStart; + private String closedLoopEventClient; + private String closedLoopEventStatus; + private String requestID; + + @JsonProperty("target_type") + private String targetType; + + @JsonProperty("AAI") + private AAI aai; + + private String target; + private Payload payload; + private String from; + private String version; + + public String getClosedLoopControlName() { + return closedLoopControlName; + } + + public void setClosedLoopControlName(String closedLoopControlName) { + this.closedLoopControlName = closedLoopControlName; + } + + 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 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 AAI getAai() { + return aai; + } + + public void setAai(AAI aAI) { + this.aai = aAI; + } + + public Payload getPayload() { + return payload; + } + + public void setPayload(Payload payload) { + this.payload = payload; + } + + 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; + } + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/policy/Payload.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/policy/Payload.java new file mode 100644 index 00000000..57aab994 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/policy/Payload.java @@ -0,0 +1,95 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ +package org.onap.slice.analysis.ms.models.policy; + +/** + * Model class for the Paylaod Object + */ +public class Payload { + + private String name; + private String serviceInstanceID; + private String globalSubscriberId; + private String subscriptionServiceType; + private String networkType; + private AdditionalProperties additionalProperties; + + + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + public String getServiceInstanceID() { + return serviceInstanceID; + } + + + public void setServiceInstanceID(String serviceInstanceId) { + this.serviceInstanceID = serviceInstanceId; + } + + + public String getGlobalSubscriberId() { + return globalSubscriberId; + } + + + public void setGlobalSubscriberId(String globalSubscriberId) { + this.globalSubscriberId = globalSubscriberId; + } + + + public String getSubscriptionServiceType() { + return subscriptionServiceType; + } + + + public void setSubscriptionServiceType(String subscriptionServiceType) { + this.subscriptionServiceType = subscriptionServiceType; + } + + + public String getNetworkType() { + return networkType; + } + + + public void setNetworkType(String networkType) { + this.networkType = networkType; + } + + + public AdditionalProperties getAdditionalProperties() { + return additionalProperties; + } + + + public void setAdditionalProperties(AdditionalProperties additionalProperties) { + this.additionalProperties = additionalProperties; + } + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/restclients/ConfigDbRestClient.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/restclients/ConfigDbRestClient.java new file mode 100644 index 00000000..dbc42912 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/restclients/ConfigDbRestClient.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.slice.analysis.ms.restclients; + +import java.util.Collections; + +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Component; + +/** + * This class represents rest client for config db interfaces + */ +@Component +public class ConfigDbRestClient extends RestClient { + + public ConfigDbRestClient() { + super(); + } + + /** + * Send Post Request to Config DB. + */ + + public ResponseEntity sendPostRequest(String requestUrl, String requestBody, + ParameterizedTypeReference responseType) { + HttpHeaders headers = new HttpHeaders(); + headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); + headers.setContentType(MediaType.APPLICATION_JSON); + return super.sendPostRequest(headers, requestUrl, requestBody, responseType); + } + + /** + * Send Get Request to Config DB. + */ + + public ResponseEntity sendGetRequest(String requestUrl, ParameterizedTypeReference responseType) { + HttpHeaders headers = new HttpHeaders(); + headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); + headers.setContentType(MediaType.APPLICATION_JSON); + return super.sendGetRequest(headers, requestUrl, responseType); + } +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/restclients/RestClient.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/restclients/RestClient.java new file mode 100644 index 00000000..5946fd1d --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/restclients/RestClient.java @@ -0,0 +1,80 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.slice.analysis.ms.restclients; + +import org.onap.slice.analysis.ms.utils.BeanUtil; +import org.slf4j.Logger; +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.ResponseEntity; +import org.springframework.stereotype.Component; +import org.springframework.web.client.RestTemplate; + +/** + * This class is for base rest client + */ +@Component +public class RestClient { + + private static final String EXCEPTION_MSG = "Exception caught during request {}"; + private static final Logger log = org.slf4j.LoggerFactory.getLogger(RestClient.class); + + protected RestClient() { + + } + + /** + * Post Request Template. + */ + + public ResponseEntity sendPostRequest(HttpHeaders headers, String requestUrl, String requestBody, + ParameterizedTypeReference responseType) { + HttpEntity requestEntity = new HttpEntity<>(requestBody, headers); + try { + RestTemplate restTemplate = BeanUtil.getBean(RestTemplate.class); + return restTemplate.exchange(requestUrl, HttpMethod.POST, requestEntity, responseType); + } catch (Exception e) { + log.debug(EXCEPTION_MSG, e.getMessage()); + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } + } + + /** + * Get Request Template. + */ + + public ResponseEntity sendGetRequest(HttpHeaders headers, String requestUrl, ParameterizedTypeReference responseType) { + HttpEntity requestEntity = new HttpEntity<>(headers); + try { + RestTemplate restTemplate = BeanUtil.getBean(RestTemplate.class); + return restTemplate.exchange(requestUrl, HttpMethod.GET, requestEntity, responseType); + } catch (Exception e) { + log.debug(EXCEPTION_MSG, e.getMessage()); + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } + } + + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/AverageCalculator.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/AverageCalculator.java new file mode 100644 index 00000000..a003e9c0 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/AverageCalculator.java @@ -0,0 +1,94 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.slice.analysis.ms.service; + +import java.util.ArrayList; +import java.util.List; + +import javax.annotation.PostConstruct; + +import org.onap.slice.analysis.ms.models.MeasurementObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +/** + * This class has utility methods for calculating the average of samples + */ +@Component +public class AverageCalculator { + private static Logger log = LoggerFactory.getLogger(AverageCalculator.class); + private List pmNames; + + @PostConstruct + public void init() { + pmNames = new ArrayList<>(); + pmNames.add("PrbUsedDl"); + pmNames.add("PrbUsedUl"); + } + + /** + * Find average of samples + */ + public List findAverageOfSamples(List> samples) { + int numOfSamples = samples.size(); + List result = new ArrayList<>(); + samples.forEach(sample -> + sample.forEach(cellMeasObj -> { + int index = result.indexOf(cellMeasObj); + if(index != -1) { + result.set(index, findSum(result.get(index), cellMeasObj)); + } + else { + result.add(cellMeasObj); + } + }) + ); + return findAvg(result, numOfSamples); + } + + /** + * Calculate the sum + */ + public MeasurementObject findSum(MeasurementObject existing, MeasurementObject current) { + pmNames.forEach(pmName -> { + int newValue = current.getPmData().get(pmName) + existing.getPmData().get(pmName); + existing.getPmData().put(pmName, newValue); + }); + return existing; + } + + /** + * Calculate the average + */ + public List findAvg(List result, int numOfSamples) { + result.forEach(cellMeasObj -> + pmNames.forEach(pmName -> { + int value = (cellMeasObj.getPmData().get(pmName))/numOfSamples; + cellMeasObj.getPmData().put(pmName, value); + }) + ); + log.debug("Average of measurement data samples {}",result); + return result; + } +} + diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/ConsumerThread.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/ConsumerThread.java new file mode 100644 index 00000000..39235cd5 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/ConsumerThread.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.slice.analysis.ms.service; + +import org.onap.slice.analysis.ms.configdb.IConfigDbService; +import org.onap.slice.analysis.ms.models.Configuration; +import org.onap.slice.analysis.ms.utils.BeanUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * This Thread class consumes message from pm data queue and sends onset message to policy + */ +public class ConsumerThread extends Thread { + private static Logger log = LoggerFactory.getLogger(PmThread.class); + private PmDataQueue pmDataQueue; + private IConfigDbService configDbService; + private SnssaiSamplesProcessor snssaiSamplesProcessor; + private long initialDelaySec; + + /** + * Default constructor. + */ + public ConsumerThread() { + super(); + this.pmDataQueue = BeanUtil.getBean(PmDataQueue.class); + this.configDbService = BeanUtil.getBean(IConfigDbService.class); + this.snssaiSamplesProcessor = BeanUtil.getBean(SnssaiSamplesProcessor.class); + this.initialDelaySec = Configuration.getInstance().getInitialDelaySeconds(); + } + + /** + * Consumes data from PM data queue, process the data and sends onset message to policy if needed + */ + @Override + public void run() { + boolean done = false; + String snssai = ""; + while (!done) { + try { + Thread.sleep(initialDelaySec); + snssai = pmDataQueue.getSnnsaiFromQueue(); + if (!snssai.equals("")) { + log.info("Consumer thread started for s-nssai {}",snssai); + snssaiSamplesProcessor.processSamplesOfSnnsai(snssai, configDbService.fetchNetworkFunctionsOfSnssai(snssai)); + } + } catch (Exception e) { + log.error("Exception in Consumer Thread ", e); + done = true; + } + } + } +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/IPmEventProcessor.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/IPmEventProcessor.java new file mode 100644 index 00000000..0a67df81 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/IPmEventProcessor.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.slice.analysis.ms.service; + +import java.util.List; +import java.util.Map; + +import org.onap.slice.analysis.ms.models.MeasurementObject; +import org.onap.slice.analysis.ms.models.pmnotification.Event; + +/** + * Interface for pm event processor + */ +public interface IPmEventProcessor { + public Map> processEvent(Event event); +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/MLMessageProcessor.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/MLMessageProcessor.java new file mode 100644 index 00000000..bee7b30e --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/MLMessageProcessor.java @@ -0,0 +1,73 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.slice.analysis.ms.service; + +import java.util.List; +import java.util.Map; + +import javax.annotation.PostConstruct; + +import org.onap.slice.analysis.ms.configdb.IConfigDbService; +import org.onap.slice.analysis.ms.models.CUModel; +import org.onap.slice.analysis.ms.models.MLOutputModel; +import org.onap.slice.analysis.ms.models.policy.AdditionalProperties; +import org.onap.slice.analysis.ms.utils.BeanUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +/** + * Process the message sent by ML service and sends notification to policy + */ +@Component +@Scope("Prototype") +public class MLMessageProcessor { + private static Logger log = LoggerFactory.getLogger(MLMessageProcessor.class); + + private IConfigDbService configDbService; + private PolicyService policyService; + + + @PostConstruct + public void init() { + configDbService = BeanUtil.getBean(IConfigDbService.class); + } + + public void processMLMsg(MLOutputModel mlOutputMsg) { + String snssai = mlOutputMsg.getSnssai(); + List cuData = mlOutputMsg.getData(); + Map> ricToCellMapping = configDbService.fetchRICsOfSnssai(snssai); + log.debug("RIC to cell mapping of S-NSSAI {} is {}",snssai,ricToCellMapping); + for(CUModel cuModel: cuData) { + String cellId = String.valueOf(cuModel.getCellCUList().get(0).getCellLocalId()); + ricToCellMapping.forEach((ricId, cells) -> { + if(cells.contains(cellId)) { + cuModel.setNearRTRICId(ricId); + } + }); + } + AdditionalProperties addProps = new AdditionalProperties<>(); + addProps.setResourceConfig(mlOutputMsg); + policyService.sendOnsetMessageToPolicy(snssai, addProps, configDbService.fetchServiceDetails(snssai)); + } +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/PmDataQueue.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/PmDataQueue.java new file mode 100644 index 00000000..d907bfed --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/PmDataQueue.java @@ -0,0 +1,96 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.slice.analysis.ms.service; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Queue; +import java.util.concurrent.LinkedBlockingQueue; + +import org.onap.slice.analysis.ms.models.MeasurementObject; +import org.onap.slice.analysis.ms.models.SubCounter; +import org.springframework.stereotype.Component; + +/** + * This class represents the data structure for storing the pm events + */ +@Component +public class PmDataQueue { + private Map>> subCounterMap = Collections.synchronizedMap(new LinkedHashMap>>()); + private Queue snssaiList = new LinkedBlockingQueue<>(); + + /** + * put the measurement data for (an S-NSSAI from a network function) in the queue + */ + public void putDataToQueue(SubCounter subCounter, List measurementObjectData) { + Queue> measQueue; + if (subCounterMap.containsKey(subCounter)){ + subCounterMap.get(subCounter).add(measurementObjectData); + } + else { + measQueue = new LinkedBlockingQueue<>(); + measQueue.add(measurementObjectData); + subCounterMap.put(subCounter, measQueue); + } + } + + /** + * get the measurement data for (an S-NSSAI from a network function) from the queue + * returns the specified number of samples + */ + public List> getSamplesFromQueue(SubCounter subCounter, int samples) { + List> sampleList = new LinkedList<>(); + if (subCounterMap.containsKey(subCounter)){ + Queue> measQueue = subCounterMap.get(subCounter); + while(samples > 0) { + sampleList.add(measQueue.remove()); + samples --; + } + } + return sampleList; + } + + /** + * put S-NSSAI to the queue + */ + public void putSnssaiToQueue(String snssai) { + if (!snssaiList.contains(snssai)) + snssaiList.add(snssai); + } + + /** + * get S-NSSAI from the queue + */ + public String getSnnsaiFromQueue() { + String snssai = ""; + try { + snssai = snssaiList.remove(); + } + catch(Exception e) { + + } + return snssai; + } +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/PmEventProcessor.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/PmEventProcessor.java new file mode 100644 index 00000000..99c24c8a --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/PmEventProcessor.java @@ -0,0 +1,105 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.slice.analysis.ms.service; + +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import org.onap.slice.analysis.ms.models.MeasurementObject; +import org.onap.slice.analysis.ms.models.pmnotification.Event; +import org.onap.slice.analysis.ms.models.pmnotification.MeasInfoList; +import org.onap.slice.analysis.ms.models.pmnotification.MeasResult; +import org.onap.slice.analysis.ms.models.pmnotification.MeasValuesList; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +/** + * This class is responsible for processing PmEvent + */ +@Component +@Scope("prototype") +public class PmEventProcessor implements IPmEventProcessor{ + protected Map> instanceMap = new HashMap<>(); + + + /** + * Process the PM event + */ + public Map> processEvent(Event event) { + List measurements = event.getPerf3gppFields().getMeasDataCollection().getMeasInfoList(); + measurements.forEach(measurement -> { + List collectedSubCounters = measurement.getMeasTypes().getsMeasTypesList(); + List subCounterMeasurements = measurement.getMeasValuesList(); + subCounterMeasurements.forEach(subCounterMeasurement -> processMeasurementObjectData(collectedSubCounters, subCounterMeasurement)); + }); + return instanceMap; + } + + /** + * Process the measurement data from every measurement object. eg cell + */ + public void processMeasurementObjectData(List collectedSubCounters, MeasValuesList subCounterMeasurement) { + List measResultList = subCounterMeasurement.getMeasResults(); + String measObjId = subCounterMeasurement.getMeasObjInstId(); + measResultList.forEach(measResult -> { + String pmName = collectedSubCounters.get(measResult.getP()-1); + Integer pmValue = Integer.valueOf(measResult.getsValue()); + Map pmMapping = getMapKey(pmName); + String snssai = pmMapping.get("snssai"); + String pm = pmMapping.get("pm"); + Map pmData = new HashMap<>(); + pmData.put(pm, pmValue); + if (instanceMap.containsKey(snssai)) { + int index = instanceMap.get(snssai).indexOf(new MeasurementObject(measObjId)); + if (index == -1) { + instanceMap.get(snssai).add(new MeasurementObject(measObjId,pmData)); + } + else { + instanceMap.get(snssai).get(index).getPmData().put(pmName, pmValue); + } + } + else { + List l = new LinkedList<>(); + l.add(new MeasurementObject(measObjId,pmData)); + instanceMap.put(snssai, l); + } + }); + } + + /** + * Fetch pm name and S-NSSAI + */ + public Map getMapKey(String pmName) { + String [] pmNameArr = pmName.split("\\."); + String snssai = ""; + String pm = pmNameArr[1]; + Map result = new HashMap<>(); + result.put("pm", pm); + if ((pm.equalsIgnoreCase("PrbUsedDl")) || (pm.equalsIgnoreCase("PrbUsedUl"))){ + snssai = pmNameArr[2]; + } + result.put("snssai", snssai); + return result; + } +} \ No newline at end of file diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/PmThread.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/PmThread.java new file mode 100644 index 00000000..d9091b3c --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/PmThread.java @@ -0,0 +1,92 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.slice.analysis.ms.service; + +import java.util.List; +import java.util.Map; + +import org.onap.slice.analysis.ms.data.repository.PerformanceNotificationsRepository; +import org.onap.slice.analysis.ms.dmaap.NewPmNotification; +import org.onap.slice.analysis.ms.models.MeasurementObject; +import org.onap.slice.analysis.ms.models.SubCounter; +import org.onap.slice.analysis.ms.models.pmnotification.PmNotification; +import org.onap.slice.analysis.ms.utils.BeanUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.fasterxml.jackson.databind.ObjectMapper; + +/** + * This Thread class consumes pm message from database and puts it in the queue for further processing + */ +public class PmThread extends Thread { + private static Logger log = LoggerFactory.getLogger(PmThread.class); + private NewPmNotification newPmNotification; + private PerformanceNotificationsRepository performanceNotificationsRepository; + private IPmEventProcessor pmEventProcessor; + private PmDataQueue pmDataQueue; + + /** + * parameterized constructor. + */ + public PmThread(NewPmNotification newPmNotification) { + super(); + this.newPmNotification = newPmNotification; + this.performanceNotificationsRepository = BeanUtil.getBean(PerformanceNotificationsRepository.class); + this.pmEventProcessor = BeanUtil.getBean(IPmEventProcessor.class); + this.pmDataQueue = BeanUtil.getBean(PmDataQueue.class); + } + + /** + * check for new PM notification. Fetch notification from the database, process and put it in the pm data queue + */ + @Override + public void run() { + log.info("PM thread starting ..."); + boolean done = false; + PmNotification pmNotification; + Map> processedData; + while (!done) { + try { + Thread.sleep(1000); + if (newPmNotification.getNewNotif()) { + log.info("New PM notification from Dmaap"); + String pmNotificationString = performanceNotificationsRepository.getPerformanceNotificationFromQueue(); + if(pmNotificationString != null) { + ObjectMapper mapper = new ObjectMapper(); + pmNotification = mapper.readValue(pmNotificationString, PmNotification.class); + processedData = pmEventProcessor.processEvent(pmNotification.getEvent()); + String networkFunction = pmNotification.getEvent().getPerf3gppFields().getMeasDataCollection().getMeasuredEntityDn(); + processedData.forEach((key,value) -> { + SubCounter subCounter = new SubCounter(networkFunction, key); + pmDataQueue.putDataToQueue(subCounter, value); + pmDataQueue.putSnssaiToQueue(subCounter.getMeasuredObject()); + }); + } + } + } catch (Exception e) { + log.error("Exception in PM Thread ", e); + done = true; + } + } + } +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/PolicyService.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/PolicyService.java new file mode 100644 index 00000000..80063398 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/PolicyService.java @@ -0,0 +1,111 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.slice.analysis.ms.service; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import javax.annotation.PostConstruct; + +import org.onap.slice.analysis.ms.dmaap.PolicyDmaapClient; +import org.onap.slice.analysis.ms.models.Configuration; +import org.onap.slice.analysis.ms.models.policy.AAI; +import org.onap.slice.analysis.ms.models.policy.AdditionalProperties; +import org.onap.slice.analysis.ms.models.policy.OnsetMessage; +import org.onap.slice.analysis.ms.models.policy.Payload; +import org.onap.slice.analysis.ms.utils.DmaapUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import com.fasterxml.jackson.databind.ObjectMapper; + +@Component +public class PolicyService { + private PolicyDmaapClient policyDmaapClient; + private static Logger log = LoggerFactory.getLogger(PolicyService.class); + + @PostConstruct + public void init() { + Configuration configuration = Configuration.getInstance(); + policyDmaapClient = new PolicyDmaapClient(new DmaapUtils(), configuration); + } + + protected OnsetMessage formPolicyOnsetMessage(String snssai, AdditionalProperties addProps, Map serviceDetails) { + OnsetMessage onsetmsg = new OnsetMessage(); + Payload payload = new Payload(); + payload.setGlobalSubscriberId(serviceDetails.get("globalSubscriberId")); + payload.setSubscriptionServiceType(serviceDetails.get("subscriptionServiceType")); + payload.setNetworkType("AN"); + payload.setName(serviceDetails.get("ranNFNSSIId")); + payload.setServiceInstanceID(serviceDetails.get("ranNFNSSIId")); + + addProps.setModifyAction(""); + Map nsiInfo = new HashMap<>(); + nsiInfo.put("nsiId", UUID.randomUUID().toString()); + nsiInfo.put("nsiName", ""); + addProps.setNsiInfo(nsiInfo); + addProps.setScriptName("AN"); + addProps.setSliceProfileId(serviceDetails.get("sliceProfileId")); + addProps.setModifyAction("reconfigure"); + List snssaiList = new ArrayList<>(); + snssaiList.add(snssai); + addProps.setSnssaiList(snssaiList); + + payload.setAdditionalProperties(addProps); + onsetmsg.setPayload(payload); + + onsetmsg.setClosedLoopControlName("ControlLoop-Slicing-116d7b00-dbeb-4d03-8719-d0a658fa735b"); + onsetmsg.setClosedLoopAlarmStart(System.currentTimeMillis()); + onsetmsg.setClosedLoopEventClient("microservice.sliceAnalysisMS"); + onsetmsg.setClosedLoopEventStatus("ONSET"); + onsetmsg.setRequestID(UUID.randomUUID().toString()); + onsetmsg.setTarget("vserver.vserver-name"); + onsetmsg.setTargetType("VNF"); + onsetmsg.setFrom("DCAE"); + onsetmsg.setVersion("1.0.2"); + AAI aai = new AAI(); + aai.setVserverIsClosedLoopDisabled("false"); + aai.setVserverProvStatus("ACTIVE"); + aai.setVserverVserverName(serviceDetails.get("ranNFNSSIId")); + onsetmsg.setAai(aai); + return onsetmsg; + } + + protected void sendOnsetMessageToPolicy(String snssai, AdditionalProperties addProps, Map serviceDetails) { + OnsetMessage onsetMessage = formPolicyOnsetMessage(snssai, addProps, serviceDetails); + ObjectMapper obj = new ObjectMapper(); + String msg = ""; + try { + log.debug("Policy onset message for S-NSSAI: {} is {}", snssai, msg); + msg = obj.writeValueAsString(onsetMessage); + policyDmaapClient.sendNotificationToPolicy(msg); + } + catch (Exception e) { + log.error("Error sending notification to policy, {}",e.getMessage()); + } + } + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/SnssaiSamplesProcessor.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/SnssaiSamplesProcessor.java new file mode 100644 index 00000000..2e56190f --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/SnssaiSamplesProcessor.java @@ -0,0 +1,190 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ +package org.onap.slice.analysis.ms.service; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import javax.annotation.PostConstruct; + +import org.onap.slice.analysis.ms.configdb.IConfigDbService; +import org.onap.slice.analysis.ms.models.Configuration; +import org.onap.slice.analysis.ms.models.MeasurementObject; +import org.onap.slice.analysis.ms.models.SubCounter; +import org.onap.slice.analysis.ms.models.policy.AdditionalProperties; +import org.onap.slice.analysis.ms.utils.BeanUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +/** + * This class process the measurement data of an S-NSSAI + */ +@Component +@Scope("Prototype") +public class SnssaiSamplesProcessor { + private static Logger log = LoggerFactory.getLogger(SnssaiSamplesProcessor.class); + + private PolicyService policyService; + private IConfigDbService configDbService; + private PmDataQueue pmDataQueue; + private AverageCalculator averageCalculator; + private List snssaiMeasurementList = new ArrayList<>(); + private Map> ricToCellMapping = new HashMap<>(); + private Map> ricToPrbsMapping = new HashMap<>(); + private Map> ricToThroughputMapping = new HashMap<>(); + private int samples; + private List pmsToCompute; + private Map prbThroughputMapping = new HashMap<>(); + private int minPercentageChange; + + @PostConstruct + public void init() { + Configuration configuration = Configuration.getInstance(); + samples = configuration.getSamples(); + pmsToCompute = new ArrayList<>(); + pmsToCompute.add("PrbUsedDl"); + pmsToCompute.add("PrbUsedUl"); + prbThroughputMapping = new HashMap<>(); + prbThroughputMapping.put("PrbUsedDl", "dLThptPerSlice"); + prbThroughputMapping.put("PrbUsedUl", "uLThptPerSlice"); + minPercentageChange = configuration.getMinPercentageChange(); + policyService = BeanUtil.getBean(PolicyService.class); + configDbService = BeanUtil.getBean(IConfigDbService.class); + pmDataQueue = BeanUtil.getBean(PmDataQueue.class); + averageCalculator = BeanUtil.getBean(AverageCalculator.class); + } + + /** + * process the measurement data of an S-NSSAI + */ + public void processSamplesOfSnnsai(String snssai, List networkFunctions) { + networkFunctions.forEach(nf -> { + log.debug("Average of samples for {}:", snssai); + addToMeasurementList(averageCalculator.findAverageOfSamples(pmDataQueue.getSamplesFromQueue(new SubCounter(nf, snssai), samples))); + }); + ricToCellMapping = configDbService.fetchRICsOfSnssai(snssai); + log.debug("RIC to Cell Mapping for {} S-NSSAI: {}", snssai, ricToCellMapping); + Map> ricConfiguration = configDbService.fetchCurrentConfigurationOfRIC(snssai); + Map sliceConfiguration = configDbService.fetchCurrentConfigurationOfSlice(snssai); + log.debug("RIC Configuration: {}", ricConfiguration); + log.debug("Slice Configuration: {}", sliceConfiguration); + pmsToCompute.forEach(pm -> { + sumOfPrbsAcrossCells(pm); + int sum = computeSum(pm); + computeThroughput(sliceConfiguration, sum, pm); + calculatePercentageChange(ricConfiguration, pm); + }); + updateConfiguration(); + if(ricToThroughputMapping.size() > 0) { + AdditionalProperties>> addProps = new AdditionalProperties<>(); + addProps.setResourceConfig(ricToThroughputMapping); + policyService.sendOnsetMessageToPolicy(snssai, addProps, configDbService.fetchServiceDetails(snssai)); + } + + } + + /** + * process the measurement data of an S-NSSAI + */ + protected void updateConfiguration() { + Iterator>> it = ricToThroughputMapping.entrySet().iterator(); + Map.Entry> entry = null; + while(it.hasNext()) { + entry = it.next(); + if(entry.getValue().size() == 0) { + it.remove(); + } + } + } + + private void addToMeasurementList(List sample) { + snssaiMeasurementList.addAll(sample); + } + + /** + * Calculate the change in the configuration value and keep the configuration only if it is greater than a + * specific limit + */ + protected void calculatePercentageChange(Map> ricConfiguration, String pm) { + Iterator>> it = ricToThroughputMapping.entrySet().iterator(); + Map.Entry> entry = null; + float existing = 0; + float change = 0; + while(it.hasNext()) { + entry = it.next(); + existing = ricConfiguration.get(entry.getKey()).get(pm); + change = ((Math.abs(entry.getValue().get(pm) - existing))/existing)*100; + if (change <= minPercentageChange) { + ricToThroughputMapping.get(entry.getKey()).remove(pm); + } + } + } + + protected void sumOfPrbsAcrossCells(String pmName) { + ricToCellMapping.forEach((ric,cells) -> { + int sumOfPrbs = 0; + for(String cell : cells) { + int index = snssaiMeasurementList.indexOf(new MeasurementObject(cell)); + sumOfPrbs += snssaiMeasurementList.get(index).getPmData().get(pmName); + } + if(ricToPrbsMapping.containsKey(ric)) { + ricToPrbsMapping.get(ric).put(pmName, sumOfPrbs); + } + else { + Map pmToPrbMapping = new HashMap<>(); + pmToPrbMapping.put(pmName, sumOfPrbs); + ricToPrbsMapping.put(ric, pmToPrbMapping); + } + }); + } + + protected Integer computeSum(String pm) { + return ricToPrbsMapping.entrySet().stream().map(x -> x.getValue().get(pm)).reduce(0, Integer::sum); + } + + protected void computeThroughput(Map sliceConfiguration, int sum, String pm) { + Iterator>> it = ricToPrbsMapping.entrySet().iterator(); + Map.Entry> entry = null; + Map throughtputMap = null; + String ric = ""; + int value = 0; + while(it.hasNext()) { + entry = it.next(); + ric = entry.getKey(); + value = Math.round(((float)entry.getValue().get(pm)/sum)*(float)sliceConfiguration.get(prbThroughputMapping.get(pm))); + if(ricToThroughputMapping.containsKey(ric)) { + ricToThroughputMapping.get(ric).put(prbThroughputMapping.get(pm), value); + } + else { + throughtputMap = new HashMap<>(); + throughtputMap.put(prbThroughputMapping.get(pm), value); + ricToThroughputMapping.put(ric, throughtputMap); + } + } + + } + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/utils/DmaapUtils.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/utils/DmaapUtils.java index 0952f754..7457533b 100644 --- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/utils/DmaapUtils.java +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/utils/DmaapUtils.java @@ -33,7 +33,7 @@ import com.att.nsa.cambria.client.CambriaTopicManager; import java.net.MalformedURLException; import java.security.GeneralSecurityException; -import org.onap.slice.analysis.ms.beans.Configuration; +import org.onap.slice.analysis.ms.models.Configuration; /** * Utility class to perform actions related to Dmaap -- cgit 1.2.3-korg