summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordhebeha <dhebeha.mj71@wipro.com>2020-09-22 17:58:44 +0530
committerdhebeha <dhebeha.mj71@wipro.com>2020-09-22 19:05:32 +0530
commit9170fe0e3aad7a336b0f0d08e63b9de127a9f9de (patch)
tree26b6e646f23c78aadb3484af0a4f8ab4c7c4d547
parent8882e23eedce9e9236e1d979b2056b62dd974d91 (diff)
Fix dependency injection issues in sliceanalysisms1.0.0-slice-analysis-ms
Issue-ID: DCAEGEN2-2451 Signed-off-by: dhebeha <dhebeha.mj71@wipro.com> Change-Id: I557c06f2e817ed8bdfe3b9c0540a19a8ceaaab52
-rw-r--r--components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/Application.java1
-rw-r--r--components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/MainThread.java23
-rw-r--r--components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/configdb/ConfigDbInterfaceService.java36
-rw-r--r--components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/DmaapClient.java10
-rw-r--r--components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/IntelligentSlicingCallback.java10
-rw-r--r--components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/MLMessageProcessor.java17
-rw-r--r--components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/PmThread.java4
-rw-r--r--components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/SnssaiSamplesProcessor.java16
8 files changed, 54 insertions, 63 deletions
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 f04e86d8..759706e4 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
@@ -65,6 +65,7 @@ public class Application {
getConfig();
log.info("Starting spring boot application");
SpringApplication.run(Application.class, args);
+ MainThread.initiateThreads();
}
private static void getConfig() {
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
index 925a196f..57a831ea 100644
--- 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
@@ -21,35 +21,28 @@
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;
-
-
+
+ private MainThread() {
+
+ }
+
/**
* main thread initialization.
*/
- @PostConstruct
- public void init() {
- log.debug("initializing main thread");
- Thread pmThread = new Thread(new PmThread(newPmNotification));
+ public static void initiateThreads() {
+ log.debug("initializing Pm thread & Consumer thread");
+ Thread pmThread = new Thread(new PmThread());
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/configdb/ConfigDbInterfaceService.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/configdb/ConfigDbInterfaceService.java
index 488aca81..b3cd7b1c 100644
--- 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
@@ -25,13 +25,11 @@ 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.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
@@ -43,15 +41,11 @@ import org.springframework.stereotype.Service;
*/
@Service
public class ConfigDbInterfaceService implements IConfigDbService {
-
+
+ @Autowired
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
*/
@@ -64,7 +58,7 @@ public class ConfigDbInterfaceService implements IConfigDbService {
responseMap=response.getBody();
return responseMap;
}
-
+
/**
* Fetches the current configuration of RIC from config DB
*/
@@ -74,7 +68,7 @@ public class ConfigDbInterfaceService implements IConfigDbService {
});
return response.getBody();
}
-
+
/**
* Fetches all the network functions of an S-NSSAI from config DB
*/
@@ -88,32 +82,32 @@ public class ConfigDbInterfaceService implements IConfigDbService {
}
return responseList;
}
-
+
/**
* Fetches the RICS of an S-NSSAI from config DB
*/
public Map<String, List<String>> fetchRICsOfSnssai(String snssai){
-
+
Map<String,List<String>> responseMap=new HashMap<>();
-
+
String reqUrl=configDbBaseUrl+"/api/sdnc-config-db/v4/du-cell-list/"+snssai;
-
+
ResponseEntity<Map<String,List<CellsModel>>> response=restclient.sendGetRequest(reqUrl, new ParameterizedTypeReference<Map<String,List<CellsModel>>>() {
});
-
+
for (Map.Entry<String, List<CellsModel>> entry : response.getBody().entrySet()) {
List<String> 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
*/
@@ -123,5 +117,5 @@ public class ConfigDbInterfaceService implements IConfigDbService {
});
return response.getBody();
}
-
+
}
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 08a89541..6e0f4f27 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
@@ -21,8 +21,6 @@
package org.onap.slice.analysis.ms.dmaap;
-import com.att.nsa.cambria.client.CambriaConsumer;
-
import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
@@ -34,8 +32,11 @@ import org.onap.slice.analysis.ms.models.Configuration;
import org.onap.slice.analysis.ms.utils.DmaapUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import com.att.nsa.cambria.client.CambriaConsumer;
+
/**
* This class initializes and starts the dmaap client
* to listen on application required dmaap events
@@ -47,6 +48,9 @@ public class DmaapClient {
private static Logger log = LoggerFactory.getLogger(DmaapClient.class);
private DmaapUtils dmaapUtils;
+
+ @Autowired
+ private IntelligentSlicingCallback intelligentSlicingCallback;
/**
* init dmaap client.
@@ -113,7 +117,7 @@ public class DmaapClient {
// create notification consumers for ML MS
NotificationConsumer intelligentSlicingConsumer = new NotificationConsumer(intelligentSlicingCambriaConsumer,
- new IntelligentSlicingCallback());
+ intelligentSlicingCallback);
// start intelligent Slicing notification consumer threads
executorPool = Executors.newScheduledThreadPool(10);
executorPool.scheduleAtFixedRate(intelligentSlicingConsumer, 0, configuration.getPollingInterval(),
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
index dd6760ba..b5d79ff3 100644
--- 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
@@ -25,8 +25,9 @@ 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 org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -34,14 +35,13 @@ import com.fasterxml.jackson.databind.ObjectMapper;
/**
* Handles Notification on dmaap for ML ms events
*/
+@Component
public class IntelligentSlicingCallback implements NotificationCallback {
private static final Logger log = org.slf4j.LoggerFactory.getLogger(IntelligentSlicingCallback.class);
+
+ @Autowired
private MLMessageProcessor mlMsMessageProcessor;
- public IntelligentSlicingCallback() {
- mlMsMessageProcessor = BeanUtil.getBean(MLMessageProcessor.class);
- }
-
/**
* Trigger on Notification from ML ms
*/
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
index bee7b30e..84ff3715 100644
--- 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
@@ -24,15 +24,13 @@ 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.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
@@ -40,18 +38,15 @@ import org.springframework.stereotype.Component;
* Process the message sent by ML service and sends notification to policy
*/
@Component
-@Scope("Prototype")
+@Scope("prototype")
public class MLMessageProcessor {
private static Logger log = LoggerFactory.getLogger(MLMessageProcessor.class);
-
+
+ @Autowired
private IConfigDbService configDbService;
+
+ @Autowired
private PolicyService policyService;
-
-
- @PostConstruct
- public void init() {
- configDbService = BeanUtil.getBean(IConfigDbService.class);
- }
public void processMLMsg(MLOutputModel mlOutputMsg) {
String snssai = mlOutputMsg.getSnssai();
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
index d9091b3c..d8bcbf64 100644
--- 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
@@ -48,9 +48,9 @@ public class PmThread extends Thread {
/**
* parameterized constructor.
*/
- public PmThread(NewPmNotification newPmNotification) {
+ public PmThread() {
super();
- this.newPmNotification = newPmNotification;
+ this.newPmNotification = BeanUtil.getBean(NewPmNotification.class);
this.performanceNotificationsRepository = BeanUtil.getBean(PerformanceNotificationsRepository.class);
this.pmEventProcessor = BeanUtil.getBean(IPmEventProcessor.class);
this.pmDataQueue = BeanUtil.getBean(PmDataQueue.class);
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
index 2e56190f..16fb41ad 100644
--- 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
@@ -33,9 +33,9 @@ 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.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
@@ -43,14 +43,22 @@ import org.springframework.stereotype.Component;
* This class process the measurement data of an S-NSSAI
*/
@Component
-@Scope("Prototype")
+@Scope("prototype")
public class SnssaiSamplesProcessor {
private static Logger log = LoggerFactory.getLogger(SnssaiSamplesProcessor.class);
+ @Autowired
private PolicyService policyService;
+
+ @Autowired
private IConfigDbService configDbService;
+
+ @Autowired
private PmDataQueue pmDataQueue;
+
+ @Autowired
private AverageCalculator averageCalculator;
+
private List<MeasurementObject> snssaiMeasurementList = new ArrayList<>();
private Map<String, List<String>> ricToCellMapping = new HashMap<>();
private Map<String, Map<String, Integer>> ricToPrbsMapping = new HashMap<>();
@@ -71,10 +79,6 @@ public class SnssaiSamplesProcessor {
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);
}
/**