diff options
author | 2022-08-23 18:02:28 -0400 | |
---|---|---|
committer | 2022-09-08 09:30:17 -0400 | |
commit | 9d6cf9dc122d8c980e1bc96b86b5c0233c372fd0 (patch) | |
tree | 9a0c4985113da0f1bd2e61c87adf1e1dec25c0d8 /components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/ccvpn/CCVPNPmDatastore.java | |
parent | c21ca66f190f76feb5800ee500ff87ff7e67f5c5 (diff) |
[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 <decheng.zhang@huawei.com>
Change-Id: Id5e64fea0a03b0b41054840911ea6a7336956415
Signed-off-by: decheng zhang <decheng.zhang@huawei.com>
Diffstat (limited to 'components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/ccvpn/CCVPNPmDatastore.java')
-rw-r--r-- | components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/ccvpn/CCVPNPmDatastore.java | 51 |
1 files changed, 31 insertions, 20 deletions
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<String, ServiceState> svcStatus = new ConcurrentHashMap<>(); - private final ConcurrentMap<String, Integer> endpointToMaxBw = new ConcurrentHashMap<>(); + // Provisioned bandwidth of each endpoint + private final ConcurrentMap<String, Integer> endpointToProvBw = new ConcurrentHashMap<>(); + // Max bandwidth (upper-bound) of each endpoint + private final ConcurrentMap<String, Integer> upperBoundBw = new ConcurrentHashMap<>(); + // Current bandwidth usage data list from customers private final ConcurrentMap<Endpointkey, EvictingQueue<Integer>> 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<Integer> dataq = new EvictingQueue<Integer>(WINDOW_SIZE); - dataq.offer(result); - EvictingQueue q = endpointToUsedBw.putIfAbsent(enk, dataq); - if (q != null) { - q.offer(result); - } - + endpointToUsedBw.computeIfAbsent(enk, k -> new EvictingQueue<Integer>(WINDOW_SIZE)).offer(result); } /** |