diff options
author | 2020-11-06 18:46:12 +0530 | |
---|---|---|
committer | 2020-11-11 00:15:23 -0800 | |
commit | 006ab23bc2863627571ea7a065de7b05e78b21f6 (patch) | |
tree | 7446007755f5caf128005fae2251574bb5e4cceb /components/slice-analysis-ms/src/main/java/org/onap/slice/analysis | |
parent | 77b30f2626ace37c10e45fa86ce1e6d12c6999e0 (diff) |
-Avoid removal of samples ico insufficient data
-set aafpass and username to null if not present
Review Comments fixed
-pom version modified
-indentation and java docs are added
Issue-ID: DCAEGEN2-2509
Signed-off-by: Ahila P <ahila.pandaram@wipro.com>
Change-Id: I870cc3e91cf0914ba53f0b930d60684a5bd39ef1
Diffstat (limited to 'components/slice-analysis-ms/src/main/java/org/onap/slice/analysis')
3 files changed, 46 insertions, 6 deletions
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 index 8bdbb1a8..91a07d4f 100644 --- 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 @@ -260,9 +260,18 @@ public class Configuration { minPercentageChange = jsonObject.get("sliceanalysisms.minPercentageChange").getAsInt(); initialDelaySeconds = jsonObject.get("sliceanalysisms.initialDelaySeconds").getAsLong(); - aafUsername = jsonObject.get("aafUsername").getAsString(); - aafPassword = jsonObject.get("aafPassword").getAsString(); - + if(jsonObject.get("aafUsername") == null) { + aafUsername = null; + } + else { + aafUsername = jsonObject.get("aafUsername").getAsString(); + } + if(jsonObject.get("aafPassword") == null) { + aafPassword = null; + } + else { + aafPassword = jsonObject.get("aafPassword").getAsString(); + } log.info("configuration from CBS {}", this); } } 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 index 6868bc46..b676273f 100644 --- 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 @@ -25,6 +25,7 @@ import java.util.List; import org.onap.slice.analysis.ms.configdb.IConfigDbService; import org.onap.slice.analysis.ms.models.Configuration; +import org.onap.slice.analysis.ms.models.SubCounter; import org.onap.slice.analysis.ms.utils.BeanUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -38,6 +39,7 @@ public class ConsumerThread extends Thread { private IConfigDbService configDbService; private SnssaiSamplesProcessor snssaiSamplesProcessor; private long initialDelaySec; + private int samples; /** * Default constructor. @@ -46,8 +48,8 @@ public class ConsumerThread extends Thread { super(); this.pmDataQueue = BeanUtil.getBean(PmDataQueue.class); this.configDbService = BeanUtil.getBean(IConfigDbService.class); - this.snssaiSamplesProcessor = BeanUtil.getBean(SnssaiSamplesProcessor.class); this.initialDelaySec = Configuration.getInstance().getInitialDelaySeconds(); + this.samples = Configuration.getInstance().getSamples(); } /** @@ -56,12 +58,13 @@ public class ConsumerThread extends Thread { @Override public void run() { boolean done = false; - String snssai = ""; boolean result = false; + String snssai = ""; List<String> nfs = null; while (!done) { try { Thread.sleep(initialDelaySec); + log.info("Starting Consumer Thread"); snssai = pmDataQueue.getSnnsaiFromQueue(); if (!snssai.equals("")) { log.info("Consumer thread processing data for s-nssai {}",snssai); @@ -72,7 +75,8 @@ public class ConsumerThread extends Thread { pmDataQueue.putSnssaiToQueue(snssai); log.error("Exception caught while fetching nfs of snssai {}, {}", snssai, e.getMessage()); } - if(nfs != null) { + if(nfs != null && checkForEnoughSamples(nfs, snssai)) { + this.snssaiSamplesProcessor = BeanUtil.getBean(SnssaiSamplesProcessor.class); result = snssaiSamplesProcessor.processSamplesOfSnnsai(snssai, nfs); if(!result) { log.info("Not enough samples to process for {}",snssai); @@ -86,4 +90,18 @@ public class ConsumerThread extends Thread { } } } + + /** + * Checks whether enough samples are available for the network functions + */ + public boolean checkForEnoughSamples(List<String> nfs, String snssai) { + for(String nf : nfs) { + if(! pmDataQueue.checkSamplesInQueue(new SubCounter(nf, snssai), samples)) { + log.info("Not enough samples to process for network function {} of snssai {}", nf, snssai); + pmDataQueue.putSnssaiToQueue(snssai); + return false; + } + } + return true; + } } 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 index 4f196979..868b94c7 100644 --- 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 @@ -79,6 +79,19 @@ public class PmDataQueue { } return sampleList; } + + /** + * check whether the queue has enough number of samples for that subcounter + */ + public boolean checkSamplesInQueue(SubCounter subCounter, int samples) { + if (subCounterMap.containsKey(subCounter)){ + Queue<List<MeasurementObject>> measQueue = subCounterMap.get(subCounter); + if(measQueue.size() >= samples) { + return true; + } + } + return false; + } /** * put S-NSSAI to the queue |