From 9d6cf9dc122d8c980e1bc96b86b5c0233c372fd0 Mon Sep 17 00:00:00 2001 From: decheng zhang Date: Tue, 23 Aug 2022 18:02:28 -0400 Subject: [SLICEANALYSIS] Enhance BandwidthEvaluator to listen on user's bandwidth threshold Put bandwidth evaluation into seperated evaluationStrategy; minor enhance to bandwidth evalution and adjustment; adding ratelimiter for each network function calling. Issue-ID: DCAEGEN2-3239 Issue-ID: DCAEGEN2-3195 Signed-off-by: decheng zhang Change-Id: Id5e64fea0a03b0b41054840911ea6a7336956415 Signed-off-by: decheng zhang --- .../ms/service/ccvpn/CCVPNPmDatastore.java | 51 +++++++++++++--------- 1 file changed, 31 insertions(+), 20 deletions(-) (limited to 'components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/ccvpn/CCVPNPmDatastore.java') diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/ccvpn/CCVPNPmDatastore.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/ccvpn/CCVPNPmDatastore.java index 9c86f6e7..6d9b9604 100644 --- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/ccvpn/CCVPNPmDatastore.java +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/ccvpn/CCVPNPmDatastore.java @@ -43,7 +43,11 @@ public class CCVPNPmDatastore { private static final Pattern pattern = Pattern.compile("([0-9.]+)\\s*(kb|Kb|mb|Mb|Gb|gb)*"); private static final int WINDOW_SIZE = 5; private final ConcurrentMap svcStatus = new ConcurrentHashMap<>(); - private final ConcurrentMap endpointToMaxBw = new ConcurrentHashMap<>(); + // Provisioned bandwidth of each endpoint + private final ConcurrentMap endpointToProvBw = new ConcurrentHashMap<>(); + // Max bandwidth (upper-bound) of each endpoint + private final ConcurrentMap upperBoundBw = new ConcurrentHashMap<>(); + // Current bandwidth usage data list from customers private final ConcurrentMap> endpointToUsedBw = new ConcurrentHashMap<>(); /** @@ -67,12 +71,12 @@ public class CCVPNPmDatastore { } /** - * Return max bandwidth of cll service. If max bandwidth is null or missing, return 0; + * Return provisioned bandwidth of cll service. If provisioned bandwidth is null or missing, return 0; * @param cllId target cll instance id * @return Integer bandwidth value */ - public Integer getMaxBwOfSvc(String cllId){ - return endpointToMaxBw.getOrDefault(cllId, 0); + public Integer getProvBwOfSvc(String cllId){ + return endpointToProvBw.getOrDefault(cllId, 0); } /** @@ -84,6 +88,10 @@ public class CCVPNPmDatastore { return svcStatus.getOrDefault(cllId, ServiceState.UNKNOWN); } + public Integer getUpperBoundBwOfSvc(String cllId){ + return upperBoundBw.getOrDefault(cllId, Integer.MAX_VALUE); + } + /** * return the complete map of cll service status * @return complete map of serviceStatusMap @@ -102,18 +110,27 @@ public class CCVPNPmDatastore { } /** - * Update max bandwidth value to given bandwidth string + * Update provisioned bandwidth value to given bandwidth string * @param cllId target cll instance id * @param bw new bandwidth */ - public void updateMaxBw(String cllId, String bw){ + public void updateProvBw(String cllId, String bw){ double bwvvaldb = Double.parseDouble(bw); int bwvval = (int) bwvvaldb; - updateMaxBw(cllId, bwvval, false); + updateProvBw(cllId, bwvval, false); + } + + /** + * Update upper bound bandwidth value to given bandwidth + * @param cllId target cll instance id + * @param bw new bandwidth + */ + public void updateUpperBoundBw(String cllId, int bw){ + upperBoundBw.put(cllId, bw); } /** - * Update max bandwidth to given bandwidth value; + * Update provisioned bandwidth to given bandwidth value; * if @param{override} is false, only write the bandwidth if it is absent. * Otherwise override the old value no matter if it exists or not * Also, when @param{override} is true, compare the provided value with the old value, if equals, return false; @@ -123,15 +140,15 @@ public class CCVPNPmDatastore { * @param override override old value or not * @return whether bandwidth value is changed or not. */ - public boolean updateMaxBw(String cllId, int bw, boolean override){ - ; - if ( endpointToMaxBw.putIfAbsent(cllId, bw) == null || !override){ + public boolean updateProvBw(String cllId, int bw, boolean override){ + if (!override && !endpointToProvBw.containsKey(cllId)){ + endpointToProvBw.put(cllId, bw); return true; } else { - if (endpointToMaxBw.get(cllId) == bw){ + if (endpointToProvBw.get(cllId) == bw){ return false; } else { - endpointToMaxBw.replace(cllId, bw); + endpointToProvBw.replace(cllId, bw); return true; } } @@ -166,13 +183,7 @@ public class CCVPNPmDatastore { log.warn("Illigal bw string: " + bw); } - EvictingQueue dataq = new EvictingQueue(WINDOW_SIZE); - dataq.offer(result); - EvictingQueue q = endpointToUsedBw.putIfAbsent(enk, dataq); - if (q != null) { - q.offer(result); - } - + endpointToUsedBw.computeIfAbsent(enk, k -> new EvictingQueue(WINDOW_SIZE)).offer(result); } /** -- cgit 1.2.3-korg