summaryrefslogtreecommitdiffstats
path: root/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/ccvpn/FixedUpperBoundStrategy.java
diff options
context:
space:
mode:
authorqingshuting <qingshuting1@huawei.com>2022-09-14 12:05:19 +0800
committerqingshuting <qingshuting1@huawei.com>2022-09-20 23:14:48 +0800
commitf5db5bd223d369a1186c94f43ab642e9c4d69709 (patch)
tree1acf6e5cdeff298622d6f6fad8c1431d0e90b43a /components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/ccvpn/FixedUpperBoundStrategy.java
parent3a0de968e2c5a32a2fa43f791c78455db1c3e641 (diff)
[SLICEMS] Add bw decrease logics and enhance runtime config feature
Add closed loop assurance decrease bw logics. Add a thread transfers latest data from cbs client configs to corresponding value. Add runtime configuration function. Fix the bug that cll service info didn't get updated when a cll service is deleted. Issue-ID: DCAEGEN2-3240 Issue-ID: DCAEGEN2-3264 Issue-ID: DCAEGEN2-3255 Issue-ID: DCAEGEN2-3238 Signed-off-by: qingshuting <qingshuting1@huawei.com> Change-Id: Id611d10973fca1e1715e9e220819dfcf51bbd1ba
Diffstat (limited to 'components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/ccvpn/FixedUpperBoundStrategy.java')
-rw-r--r--components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/ccvpn/FixedUpperBoundStrategy.java58
1 files changed, 39 insertions, 19 deletions
diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/ccvpn/FixedUpperBoundStrategy.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/ccvpn/FixedUpperBoundStrategy.java
index 874e3271..ec864aa0 100644
--- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/ccvpn/FixedUpperBoundStrategy.java
+++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/ccvpn/FixedUpperBoundStrategy.java
@@ -3,6 +3,7 @@
* slice-analysis-ms
* ================================================================================
* Copyright (C) 2022 Huawei Canada Limited.
+ * Copyright (C) 2022 Huawei Technologies Co., Ltd.
* ==============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,6 +35,10 @@ import java.util.Map;
import java.util.TreeMap;
import java.util.stream.Collectors;
+/**
+ * Threshold strategy can be configured via configuration
+ * If "sliceanalysisms.ccvpnEvalStrategy" is set to "FixedUpperBoundStrategy", then this class is triggered.
+ */
@Component
public class FixedUpperBoundStrategy implements EvaluationStrategy{
private static Logger log = LoggerFactory.getLogger(FixedUpperBoundStrategy.class);
@@ -46,7 +51,7 @@ public class FixedUpperBoundStrategy implements EvaluationStrategy{
/**
* Percentage threshold of bandwidth adjustment.
*/
- private static double threshold;
+ private static double upperThreshold;
/**
* Precision of bandwidth evaluation and adjustment.
@@ -67,6 +72,11 @@ public class FixedUpperBoundStrategy implements EvaluationStrategy{
loadConfig();
}
+ /**
+ * Periodically ensure endpoint bw adjustment is under assurance.
+ * This method will be invoked when FixedUpperBoundStrategy is set.
+ * @param event
+ */
@Override
public void execute(Event event){
if (event.type() == SimpleEvent.Type.PERIODIC_CHECK && isPeriodicCheckOn()){
@@ -77,14 +87,18 @@ public class FixedUpperBoundStrategy implements EvaluationStrategy{
String serviceId = entry.getKey().getCllId();
Object[] usedBws = entry.getValue().tryReadToArray();
+ if (!ccvpnPmDatastore.getClosedloopStatus(serviceId)) {
+ log.info("CCVPN Evaluator Output: service {}, closed loop bw modification is off.", serviceId);
+ continue;
+ }
if (usedBws == null) {
// No enough data for evaluating
- log.debug("CCVPN Evaluator Output: service {}, not enough data to evaluate", serviceId);
+ log.info("CCVPN Evaluator Output: service {}, not enough data to evaluate", serviceId);
continue;
}
if (ccvpnPmDatastore.getProvBwOfSvc(serviceId) == 0) {
// Max bandwidth not cached yet
- log.debug("CCVPN Evaluator Output: service {}, max bandwidth not cached, wait for next round", serviceId);
+ log.info("CCVPN Evaluator Output: service {}, max bandwidth not cached, wait for next round", serviceId);
post(new SimpleEvent(SimpleEvent.Type.AAI_BW_REQ, serviceId));
continue;
}
@@ -110,33 +124,39 @@ public class FixedUpperBoundStrategy implements EvaluationStrategy{
// fetch the provisioned bandwidth info if underMaintenance; otherwise send modification request
for(Map.Entry<String, Integer> entry: candidate.entrySet()) {
//still doing adjustment
- if (isServiceUnderMaintenance(entry.getKey())) {
- if (entry.getValue() == 0){
- log.debug("CCVPN Evaluator Output: service {}," +
- " is in maintenance state, fetching bandwidth info from AAI", entry.getKey());
+ String cllId = entry.getKey();
+ Integer newBw = entry.getValue();
+ if(!ccvpnPmDatastore.getClosedloopStatus(cllId)) {
+ log.info("CCVPN Evaluator Output: service {} is not under closed loop assurance", cllId);
+ continue;
+ }
+ if (isServiceUnderMaintenance(cllId)) {
+ if (newBw == 0){
+ log.info("CCVPN Evaluator Output: service {}," +
+ " is in maintenance state, fetching bandwidth info from AAI", cllId);
} else {
- log.debug("CCVPN Evaluator Output: candidate {}," +
- " need an adjustment, but skipped due to in maintenance state", entry.getKey());
+ log.info("CCVPN Evaluator Output: candidate {}," +
+ " need an adjustment, but skipped due to in maintenance state", cllId);
}
- post(new SimpleEvent(SimpleEvent.Type.AAI_BW_REQ, entry.getKey()));
+ post(new SimpleEvent(SimpleEvent.Type.AAI_BW_REQ, cllId));
continue;
}
//not in the mid of adjustment; we are free to adjust.
log.info("CCVPN Evaluator Output: candidate {}," +
- " need an adjustment, sending request to policy", entry.getKey());
+ " need an adjustment, sending request to policy", entry.getKey());
ccvpnPmDatastore.updateSvcState(entry.getKey(), ServiceState.UNDER_MAINTENANCE);
- sendModifyRequest(entry.getKey(), entry.getValue(), RequestOwner.DCAE);
+ sendModifyRequest(entry.getKey(), newBw, RequestOwner.DCAE);
}
log.debug("=== Processing periodic check complete ===");
}
if (event.type() == SimpleEvent.Type.ONDEMAND_CHECK && isOnDemandCheckOn()) {
- log.debug("=== Processing upperbound adjustment request: {} ===", event.time());
+ log.info("=== Processing upperbound adjustment request: {} ===", event.time());
JsonObject payload = (JsonObject) event.subject();
String serviceId = payload.get(SERVICE_INSTANCE_LOCATION_ID).getAsString();
int newBandwidth = payload.get(BANDWIDTH_TOTAL).getAsInt();
log.info("Update service {} bandwidth upperbound to {} ", serviceId, newBandwidth);
ccvpnPmDatastore.updateUpperBoundBw(serviceId, newBandwidth);
- log.debug("=== Processing upperbound adjustment complete ===");
+ log.info("=== Processing upperbound adjustment complete ===");
}
}
@@ -155,7 +175,7 @@ public class FixedUpperBoundStrategy implements EvaluationStrategy{
private void loadConfig() {
configuration = Configuration.getInstance();
- threshold = configuration.getCcvpnEvalThreshold();
+ upperThreshold = configuration.getCcvpnEvalUpperThreshold();
precision = configuration.getCcvpnEvalPrecision(); // in Mbps;
}
@@ -179,9 +199,9 @@ public class FixedUpperBoundStrategy implements EvaluationStrategy{
}
// check if an adjustment is necessary
private boolean needAdjust(String serivceId, double used, int provBandwidth, int upper){
- log.debug("CCVPN Service Usage Analysis: usage: {}, threshold: {}, currentProvisioned {}, upperbound {}",
- used, threshold, provBandwidth, upper);
- return provBandwidth > upper || used > threshold * provBandwidth;
+ log.info("CCVPN Service Usage Analysis: usage: {}, threshold: {}, currentProvisioned {}, upperbound {}",
+ used, upperThreshold, provBandwidth, upper);
+ return provBandwidth > upper || used > upperThreshold * provBandwidth;
}
// calculate new bandwidth to accomodate customer
@@ -189,7 +209,7 @@ public class FixedUpperBoundStrategy implements EvaluationStrategy{
if (cur >= upper){
return upper;
}
- int expected = (int) (Math.ceil((used / threshold) * 1.2 / precision) * precision);
+ int expected = (int) (Math.ceil((used / upperThreshold) * 1.2 / precision) * precision);
return Math.min(expected, upper);
}
// check is service under maint