diff options
author | decheng zhang <decheng.zhang@huawei.com> | 2022-03-23 20:46:04 -0400 |
---|---|---|
committer | decheng zhang <decheng.zhang@huawei.com> | 2022-04-15 23:21:29 -0400 |
commit | ad5981f8e4969c41724885c830dda2cef304adf9 (patch) | |
tree | 486c291810101b2a325dab77c0c87b85a52e6f0c | |
parent | b5ffdfa0e652e7d7b6c320d28fc78eded8a0763a (diff) |
[SLICEANALYSIS] Bugfix1.1.1-slice-analysis-ms
- Add two attributes in policy payload: modelInvariantUuid and modelUuid
- Fix MrTopicParams builder bug
- Fix aai-subscriber server configuration and AAI-EVENT topic name
- Add safeguard for processing network-policy-list
- Fix AAI-EVENT entity format changes
- Add debug log lines
- Turn on scan in logback setting
Issue-ID: DCAEGEN2-3141
Signed-off-by: decheng zhang <decheng.zhang@huawei.com>
Change-Id: I0885035d85c55a6bff985b13f534c9db99e8fd09
Signed-off-by: decheng zhang <decheng.zhang@huawei.com>
16 files changed, 187 insertions, 63 deletions
diff --git a/components/slice-analysis-ms/ChangeLog.md b/components/slice-analysis-ms/ChangeLog.md index 15287441..d8ef6273 100644 --- a/components/slice-analysis-ms/ChangeLog.md +++ b/components/slice-analysis-ms/ChangeLog.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [1.1.1] - 2022/04/12 - [DCAEGEN2-3142](https://jira.onap.org/browse/DCAEGEN2-3142) - Filter data from AAI to avoid possible exceptions, remove null parameters in policy payload and add logs + - [DCAEGEN2-3141](https://jira.onap.org/browse/DCAEGEN2-3142) - Bugfix in DCAE-SliceAnalysisMs for IBN user-triggered CCVPN closed-loop + ## [1.1.0] - 2022/3/10 - [DCAEGEN2-3063](https://jira.onap.org/browse/DCAEGEN2-3063) - IBN user-triggered CLoud Leased Line update and CCVPN closed-loop diff --git a/components/slice-analysis-ms/src/main/docker/config/sliceanalysisms/config_all.json b/components/slice-analysis-ms/src/main/docker/config/sliceanalysisms/config_all.json index 2e094ee0..63a4a97a 100644 --- a/components/slice-analysis-ms/src/main/docker/config/sliceanalysisms/config_all.json +++ b/components/slice-analysis-ms/src/main/docker/config/sliceanalysisms/config_all.json @@ -51,13 +51,13 @@ "aaf_password": null, "api_key" : null, "api_secret" : null, - "servers" : ["message-router"], + "servers" : ["message-router:3904"], "consumer_group" : "dcae_ccvpn_cl", "consumer_instance" : "dcae_ccvpn_cl_aaievent", "fetch_timeout" : 15000, "fetch_limit" : 100, "dmaap_info":{ - "topic_url":"https://message-router:3905/events/AAI_EVENT", + "topic_url":"http://message-router:3904/events/AAI-EVENT", "client_role":"org.onap.dcae.aaiSub", "location":"onap", "client_id":"sdnr-sliceanalysis-1" diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/aai/AaiService.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/aai/AaiService.java index 289fedfd..ab67c031 100644 --- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/aai/AaiService.java +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/aai/AaiService.java @@ -367,21 +367,24 @@ public class AaiService implements AaiInterface { try { ResponseEntity<String> resp = restclient.sendGetRequest(networkPolicyUrl, new ParameterizedTypeReference<String>() { }); + log.debug("AaiService received {} : {}", resp.getStatusCodeValue(), resp.getBody()); if (resp.getStatusCodeValue() == 200){ String networkPolicy = resp.getBody(); JSONObject networkPolicyJson = new JSONObject(networkPolicy); JSONArray networkPolicyList = networkPolicyJson.optJSONArray("network-policy"); - if (networkPolicyList != null){ + if (networkPolicyList != null && networkPolicyList.length() > 0){ JSONObject networkPolicyOjb = networkPolicyList.getJSONObject(0); result.put("maxBandwidth", networkPolicyOjb.getInt("max-bandwidth")); + log.info("Successfully retrieved max bandwidth for service {}: {}", + serviceId, result.get("maxBandwidth")); return result; } - log.info("Successfully fetched max bandwidth {}: {}", serviceId, result); } + log.warn("Failed to retrieve max bandwidth for service {}, no such network-policy or no valid max-bandwidth " + + "associated", serviceId); } catch (Exception e){ log.warn("Error encountered when fetching maxbandwidth: " + e); - } - return null; + return new HashMap<String, Integer>(); } } diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/AaiEventNotificationCallback.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/AaiEventNotificationCallback.java index dc2cd775..0259f130 100644 --- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/AaiEventNotificationCallback.java +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/AaiEventNotificationCallback.java @@ -29,6 +29,8 @@ import org.onap.slice.analysis.ms.models.Configuration; import org.onap.slice.analysis.ms.service.ccvpn.BandwidthEvaluator; import org.onap.slice.analysis.ms.service.ccvpn.Event; import org.onap.slice.analysis.ms.service.ccvpn.SimpleEvent; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -40,6 +42,7 @@ import javax.annotation.PostConstruct; @Component public class AaiEventNotificationCallback implements NotificationCallback { + private static Logger logger = LoggerFactory.getLogger(AaiEventNotificationCallback.class); private static final String EVENT_HEADER = "event-header"; private static final String ACTION = "action"; private static final String ENTITY_TYPE = "entity-type"; @@ -71,26 +74,60 @@ public class AaiEventNotificationCallback implements NotificationCallback { JsonElement jsonElement = parser.parse(msg); if (jsonElement.isJsonObject()){ //handle a single AAI_EVENT + logger.debug("Handle a single aai-event"); handleMsgJsonObject(jsonElement.getAsJsonObject()); } else if (jsonElement.isJsonArray()){ //handle a series of AAI_EVENT + logger.debug("Handle a series of aai-event"); JsonArray jsonArray = jsonElement.getAsJsonArray(); for (int i=0,e=jsonArray.size(); i<e; i++){ - handleMsgJsonObject(jsonArray.get(i).getAsJsonObject()); + if (jsonArray.get(i).isJsonPrimitive()){ + // Deal with a batch of event message + handleNotification(jsonArray.get(i).getAsString()); + } else { + handleMsgJsonObject(jsonArray.get(i).getAsJsonObject()); + } + } } } private void handleMsgJsonObject(JsonObject jsonObject){ JsonObject header = jsonObject.get(EVENT_HEADER).getAsJsonObject(); - if (header.has(ACTION) && header.get(ACTION).getAsString().equals(aaiNotifTargetAction)) { - if (header.has(ENTITY_TYPE) && header.get(ENTITY_TYPE).getAsString().equals(aaiNotifTargetEntity)){ - if (header.has(SOURCE_NAME) && header.get(SOURCE_NAME).getAsString().equals(aaiNotifTargetSource)) { - JsonObject body = jsonObject.get(ENTITY).getAsJsonObject(); - Event event = new SimpleEvent<>(SimpleEvent.Type.ONDEMAND_CHECK, body); - bandwidthEvaluator.post(event); + if (!header.has(ACTION) || !header.get(ACTION).getAsString().equals(aaiNotifTargetAction)){ + return; + } + if (!header.has(ENTITY_TYPE) || !header.get(ENTITY_TYPE).getAsString().equals(aaiNotifTargetEntity)){ + return; + } + if (!header.has(SOURCE_NAME) || !header.get(SOURCE_NAME).getAsString().equals(aaiNotifTargetSource)){ + return; + } + JsonObject entity = jsonObject.get(ENTITY).getAsJsonObject(); + JsonObject body = getNestedJsonObject(entity, aaiNotifTargetEntity); + logger.debug("AAI-EVENT entity object {}", body); + if (body == null){ + return; + } + Event event = new SimpleEvent<>(SimpleEvent.Type.ONDEMAND_CHECK, body); + bandwidthEvaluator.post(event); + } + + private JsonObject getNestedJsonObject(JsonObject obj, String target){ + for (String k: obj.keySet()){ + if (k.equals(target)){ + //Found it; + return obj.getAsJsonArray(k).get(0).getAsJsonObject(); + } + if (obj.get(k).isJsonObject()) { + return getNestedJsonObject(obj.getAsJsonObject(k), target); + } else if (obj.get(k).isJsonArray()){ + JsonElement tmp = obj.getAsJsonArray(k).get(0); + if (tmp.isJsonObject()){ + return getNestedJsonObject(tmp.getAsJsonObject(), target); } } } + return null; } } diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/MRTopicMonitor.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/MRTopicMonitor.java index 0c1ac604..aa1bc964 100644 --- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/MRTopicMonitor.java +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/MRTopicMonitor.java @@ -91,8 +91,11 @@ public class MRTopicMonitor implements Runnable { public void run(){ while (running){ try { + logger.debug("Topic: {} getting new msg...", name); Iterable<String> dmaapMsgs = consumerWrapper.fetch(); for (String msg : dmaapMsgs){ + logger.debug("Received message: {}" + + "\r\n and processing start", msg); process(msg); } } catch (IOException | RuntimeException e){ diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/MRTopicParams.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/MRTopicParams.java index 66c27413..e5aaa1e3 100644 --- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/MRTopicParams.java +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/MRTopicParams.java @@ -321,12 +321,7 @@ public class MRTopicParams { servers.add(jsonArray.get(i).getAsString()); } } - if (jsonObject.has("servers") && !jsonObject.get("servers").isJsonNull()) { - JsonArray jsonArray = jsonObject.get("servers").getAsJsonArray(); - for (int i=0, e=jsonArray.size(); i<e; i++){ - servers.add(jsonArray.get(i).getAsString()); - } - } + String topicUrl = jsonObject.get("dmaap_info").getAsJsonObject().get("topic_url").getAsString(); if (topicUrl.startsWith("https")){ useHttps = true; diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/VesNotificationCallback.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/VesNotificationCallback.java index 83bfcdbe..584da7b7 100644 --- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/VesNotificationCallback.java +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/VesNotificationCallback.java @@ -104,6 +104,8 @@ public class VesNotificationCallback implements NotificationCallback { log.error("Error converting VES msg to object, {}", e.getMessage()); } if (cllId != null && uniId != null && bw != null){ + log.info("Saving new CCVPN service usage data into ccvpnPmDatastore"); + log.debug("new bandwidth data -- serviceId: {}, uniId: {}, bw: {}", cllId, uniId, bw); ccvpnPmDatastore.addUsedBwToEndpoint(cllId, uniId, bw); } 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 d5aeb7b4..2a509aa1 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 @@ -162,7 +162,7 @@ public class Configuration { aaiNotifTargetAction = jsonObject.get("sliceanalysisms.aaiNotif.targetAction").getAsString(); aaiNotifTargetSource = jsonObject.get("sliceanalysisms.aaiNotif.targetSource").getAsString(); - aaiNotifTargetSource = jsonObject.get("sliceanalysisms.aaiNotif.targetEntity").getAsString(); + aaiNotifTargetEntity = jsonObject.get("sliceanalysisms.aaiNotif.targetEntity").getAsString(); ccvpnEvalInterval = jsonObject.get("sliceanalysisms.ccvpnEvalInterval").getAsInt(); ccvpnEvalThreshold = jsonObject.get("sliceanalysisms.ccvpnEvalThreshold").getAsDouble(); ccvpnEvalPrecision = jsonObject.get("sliceanalysisms.ccvpnEvalPrecision").getAsDouble(); diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/policy/Payload.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/policy/Payload.java index ceaeb730..e0460407 100644 --- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/policy/Payload.java +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/policy/Payload.java @@ -22,13 +22,11 @@ package org.onap.slice.analysis.ms.models.policy; import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.annotation.JsonProperty; /** * Model class for the Paylaod Object */ -@JsonInclude(Include.NON_NULL) +@JsonInclude(JsonInclude.Include.NON_NULL) public class Payload { private String name; @@ -38,6 +36,8 @@ public class Payload { private String networkType; private AdditionalProperties<?> additionalProperties; private String serviceType; + private String modelInvariantUuid; + private String modelUuid; public String getName() { return name; @@ -95,4 +95,19 @@ public class Payload { this.serviceType = serviceType; } + public String getModelInvariantUuid() { + return modelInvariantUuid; + } + + public void setModelInvariantUuid(String modelInvariantUuid) { + this.modelInvariantUuid = modelInvariantUuid; + } + + public String getModelUuid() { + return modelUuid; + } + + public void setModelUuid(String modelUuid) { + this.modelUuid = modelUuid; + } } diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/PolicyService.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/PolicyService.java index 297683b4..01e2886a 100644 --- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/PolicyService.java +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/PolicyService.java @@ -153,6 +153,8 @@ public class PolicyService { payload.setName("cloud-leased-line-101"); payload.setServiceInstanceID(cllId); payload.setAdditionalProperties(additionalProperties); + payload.setModelInvariantUuid("6790ab0e-034f-11eb-adc1-0242ac120002"); + payload.setModelUuid("6790ab0e-034f-11eb-adc1-0242ac120002"); OnsetMessage onsetmsg = new OnsetMessage(); try { @@ -184,7 +186,7 @@ public class PolicyService { String msg = ""; try { msg = objectMapper.writeValueAsString(onsetMessage); - log.info("Policy onset message for ControlLoop-CCVPN-CLL is {}", msg); + log.info("Sending onset message to Onap/Policy for ControlLoop-CCVPN-CLL, the msg: {}", msg); policyDmaapClient.sendNotificationToPolicy(msg); } catch (Exception e) { diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/ccvpn/BandwidthEvaluator.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/ccvpn/BandwidthEvaluator.java index a7847b0e..c66122c1 100644 --- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/ccvpn/BandwidthEvaluator.java +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/ccvpn/BandwidthEvaluator.java @@ -46,6 +46,7 @@ import java.util.concurrent.Future; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; import static java.util.concurrent.Executors.newSingleThreadExecutor; @@ -105,7 +106,7 @@ public class BandwidthEvaluator { @Override public void process(Event event) { if (event.type() == SimpleEvent.Type.PERIODIC_CHECK && isPeriodicCheckOn()){ - log.info("Received new periodic check request: {}", event.time()); + log.info("=== Processing new periodic check request: {} ===", event.time()); Map<Endpointkey, CCVPNPmDatastore.EvictingQueue<Integer>> usedBwMap = ccvpnPmDatastore.getUsedBwMap(); Map<String, Integer> candidate = new TreeMap<>(); for(Map.Entry<Endpointkey, CCVPNPmDatastore.EvictingQueue<Integer>> entry: usedBwMap.entrySet()) { @@ -114,10 +115,12 @@ public class BandwidthEvaluator { if (usedBws == null) { // No enough data for evaluating + log.debug("CCVPN Evaluator Output: service {}, not enough data to evaluate", serviceId); continue; } if (ccvpnPmDatastore.getMaxBwOfSvc(serviceId) == 0) { // Max bandwidth not cached yet + log.debug("CCVPN Evaluator Output: service {}, max bandwidth not cached, wait for next round", serviceId); post(new SimpleEvent(SimpleEvent.Type.AAI_BW_REQ, serviceId)); continue; } @@ -126,48 +129,81 @@ public class BandwidthEvaluator { .summaryStatistics() .getAverage(); if (needAdjust(serviceId, avg, ccvpnPmDatastore.getMaxBwOfSvc(serviceId))) { + log.debug("CCVPN Evaluator Output: service {}, need adjustment, putting into candidate list", serviceId); int newBw = (int) (Math.ceil((avg / threshold) * 1.2 / precision) * precision); candidate.put(serviceId, Math.max(candidate.getOrDefault(serviceId, 0), newBw)); } } + // check svc under maintenance + Map<String , ServiceState> svcUnderMaintenance = getServicesUnderMaintenance(); + for (Map.Entry<String, ServiceState> entry: svcUnderMaintenance.entrySet()){ + candidate.putIfAbsent(entry.getKey(), 0); + } + // fetch the maxbandwidth info if underMaintenance; otherwise send modification request for(Map.Entry<String, Integer> entry: candidate.entrySet()) { if (isServiceUnderMaintenance(entry.getKey())) { + if (entry.getValue() == 0){ + log.debug("CCVPN Evaluator Output: service {}," + + " are in maintenance state, fetching bandwidth info from AAI", entry.getKey()); + } else { + log.debug("CCVPN Evaluator Output: candidate {}," + + " need adjustment, but skipped due to maintenance state", entry.getKey()); + } post(new SimpleEvent(SimpleEvent.Type.AAI_BW_REQ, entry.getKey())); continue; } + log.debug("CCVPN Evaluator Output: candidate {}," + + " need adjustment, sending request to policy", entry.getKey()); ccvpnPmDatastore.updateSvcState(entry.getKey(), ServiceState.UNDER_MAINTENANCE); sendModifyRequest(entry.getKey(), entry.getValue(), RequestOwner.DCAE); } + log.info("=== Processing periodic check complete ==="); } else if (event.type() == SimpleEvent.Type.ONDEMAND_CHECK && isOnDemandCheckOn()) { - log.info("Received new on-demand check request: {}", event.time()); + log.info("=== Processing new on-demand check request: {} ===", event.time()); JsonObject payload = (JsonObject) event.subject(); String serviceId = payload.get(SERVICE_INSTANCE_LOCATION_ID).getAsString(); if (!isServiceUnderMaintenance(serviceId)){ int newBandwidth = payload.get(BANDWIDTH_TOTAL).getAsInt(); Map<String, Integer> maxBandwidthData = aaiService.fetchMaxBandwidthOfService(serviceId); - int oldBandwidth = maxBandwidthData.get("maxBandwidth"); - if (newBandwidth != oldBandwidth) { + if (maxBandwidthData.get("maxBandwidth") != null + && maxBandwidthData.get("maxBandwidth") != newBandwidth){ + log.debug("CCVPN Evaluator Output: on-demand adjustment request for service: {} processed," + + " sending request to policy", serviceId); ccvpnPmDatastore.updateSvcState(serviceId, ServiceState.UNDER_MAINTENANCE); sendModifyRequest(serviceId, newBandwidth, RequestOwner.UUI); } + } else { + log.debug("CCVPN Evaluator Output: service {}," + + " received on-demand request, but skipped due to maintenance state", serviceId); } + log.info("=== Processing on-demand check complete ==="); } } private void sendModifyRequest(String cllId, Integer newBandwidth, RequestOwner owner) { + log.info("Sending modification request to policy. RequestOwner: {} - Service: {} change to bw: {}", + owner, cllId, newBandwidth); policyService.sendOnsetMessageToPolicy( policyService.formPolicyOnsetMessageForCCVPN(cllId, newBandwidth, owner) ); } private boolean needAdjust(String serivceId, double currentAverageUsage, int maxBandwidth){ + log.debug("CCVPN Service Usage Analysis: usage: {}, threshold: {}, maxbw {}", currentAverageUsage, threshold, maxBandwidth); return currentAverageUsage > threshold * maxBandwidth; } private boolean isServiceUnderMaintenance(String serivceId) { return ccvpnPmDatastore.getStatusOfSvc(serivceId) == ServiceState.UNDER_MAINTENANCE; } + + private Map<String, ServiceState> getServicesUnderMaintenance(){ + return ccvpnPmDatastore.getSvcStatusMap().entrySet() + .stream() + .filter(e -> e.getValue() == ServiceState.UNDER_MAINTENANCE) + .collect(Collectors.toMap(p -> p.getKey(), p -> p.getValue())); + } }; /** @@ -177,18 +213,22 @@ public class BandwidthEvaluator { @Override public void process(Event event) { if (event.type() == SimpleEvent.Type.AAI_BW_REQ){ - log.info("Received new AAI network policy query at: {}", event.time()); + log.info("=== Processing new AAI network policy query at: {} ===", event.time()); String serviceId = (String) event.subject(); Map<String, Integer> maxBandwidthData = aaiService.fetchMaxBandwidthOfService(serviceId); - int bwVal = maxBandwidthData.get("maxBandwidth"); - if (maxBandwidthData != null){ + if (maxBandwidthData.get("maxBandwidth") != null){ + log.debug("Successfully retrieved bandwidth info from AAI; service: {}, bandwidth: {}", + serviceId, maxBandwidthData.get("maxBandwidth")); + int bwValue = maxBandwidthData.get("maxBandwidth").intValue(); if (ccvpnPmDatastore.getMaxBwOfSvc(serviceId) == 0){ - ccvpnPmDatastore.updateMaxBw(serviceId, bwVal, true); - } else if (ccvpnPmDatastore.getMaxBwOfSvc(serviceId) != bwVal) { - ccvpnPmDatastore.updateMaxBw(serviceId, bwVal, true); + ccvpnPmDatastore.updateMaxBw(serviceId, bwValue, true); + } else if (ccvpnPmDatastore.getMaxBwOfSvc(serviceId) != bwValue) { + log.debug("Service modification complete; serviceId: {} with new bandwidth: {}", serviceId, bwValue); + ccvpnPmDatastore.updateMaxBw(serviceId, bwValue, true); ccvpnPmDatastore.updateSvcState(serviceId, ServiceState.RUNNING); } } + log.info("=== Processing AAI network policy query complete ==="); } } }; @@ -229,6 +269,8 @@ public class BandwidthEvaluator { * @param event event object */ public void post(@NonNull Event event){ + log.debug("A new event triggered, type: {}, subject: {}, at time: {}", + event.type(), event.subject(), event.time()); if (event.type() == SimpleEvent.Type.AAI_BW_REQ) { aaiEventLoop.add(event); } else if (event.type() == SimpleEvent.Type.PERIODIC_CHECK) { diff --git a/components/slice-analysis-ms/src/main/resources/logback.xml b/components/slice-analysis-ms/src/main/resources/logback.xml index 8d79c4ee..325402b3 100644 --- a/components/slice-analysis-ms/src/main/resources/logback.xml +++ b/components/slice-analysis-ms/src/main/resources/logback.xml @@ -1,27 +1,28 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- +<!-- /******************************************************************************* * ============LICENSE_START======================================================= * slice-analysis-ms * ================================================================================ * Copyright (C) 2020 Wipro Limited. + * Copyright (C) 2022 Huawei Canada Limited. * ============================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= - * + * *******************************************************************************/ - --> - <configuration> +--> +<configuration scan="true"> <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> <layout class="ch.qos.logback.classic.PatternLayout"> diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/ccvpn/BandwidthEvaluatorTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/ccvpn/BandwidthEvaluatorTest.java index c80a1495..f0ce5509 100644 --- a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/ccvpn/BandwidthEvaluatorTest.java +++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/ccvpn/BandwidthEvaluatorTest.java @@ -60,7 +60,7 @@ public class BandwidthEvaluatorTest { @Test public void postTest() { - Event evt = mock(SimpleEvent.class); + Event evt = new SimpleEvent(null, "{}"); bandwidthEvaluator.post(evt); Mockito.verify(bandwidthEvaluator, Mockito.atLeastOnce()).post(Mockito.any(Event.class)); } diff --git a/components/slice-analysis-ms/src/test/resources/aaiEventDmaapMsg.json b/components/slice-analysis-ms/src/test/resources/aaiEventDmaapMsg.json index 82faeeb4..d8cb65cd 100644 --- a/components/slice-analysis-ms/src/test/resources/aaiEventDmaapMsg.json +++ b/components/slice-analysis-ms/src/test/resources/aaiEventDmaapMsg.json @@ -1,25 +1,45 @@ { - "cambria.partition":"AAI", - "event-header":{ - "severity":"NORMAL", - "entity-type":"service-instance", - "top-entity-type":"service-instance", - "entity-link":"/aai/v24/business/customers/customer/IBNCustomer/service-subscriptions/service-subscription/IBN/service-instances/service-instance/cll-01", - "event-type":"AAI-EVENT","domain":"dev","action":"UPDATE", - "sequence-number":"0","id":"51a99267-83ec-4f4f-a676-690ba527bf78", - "source-name":"UUI","version":"v23","timestamp":"20210705-15:18:37:452" + "cambria.partition": "AAI", + "event-header": { + "severity": "NORMAL", + "entity-type": "service-instance", + "top-entity-type": "customer", + "entity-link": "/aai/v24/business/customers/customer/IBNCustomer/service-subscriptions/service-subscription/IBN/service-instances/service-instance/test", + "event-type": "AAI-EVENT", + "domain": "dev", + "action": "UPDATE", + "sequence-number": "0", + "id": "48c2016e-12cb-4f9f-ab25-5eaaf8da9fe8", + "source-name": "UUI", + "version": "v24", + "timestamp": "20220406-19:53:41:550" }, "entity":{ - "service-instance-id":"0835fd19-6726-4081-befb-cc8932c47767", - "service-instance-name":"sa1", - "service-instance-location-id" : "cll-01", - "service-type":"embb", - "service-role":"service-profile", - "environment-context":"01-06E442", - "model-invariant-id":"8b94b147-2233-4e9f-b939-55c1b0e618ac", - "model-version-id":"961ec436-7b16-4d71-9d62-9c4ca5dd94bf", - "resource-version":"1645003055191", - "orchestration-status":"deactivated", - "bandwidth-total" : 8000 + "global-customer-id": "IBNCustomer", + "subscriber-name": "IBNCustomer", + "service-subscriptions": { + "service-subscription": [ + { + "service-type": "IBN", + "service-instances": { + "service-instance": [ + { + "model-version-id": "6790ab0e-034f-11eb-adc1-0242ac120002", + "service-instance-id": "test", + "resource-version": "1649274821478", + "service-type": "IBN", + "service-instance-location-id": "460-00", + "service-role": "TN", + "environment-context": "001-100001", + "bandwidth-total": "4000", + "model-invariant-id": "6790ab0e-034f-11eb-adc1-0242ac120002", + "service-instance-name": "decheng-test-001", + "orchestration-status": "allocated" + } + ] + } + } + ] + } } } diff --git a/components/slice-analysis-ms/src/test/resources/config_all.json b/components/slice-analysis-ms/src/test/resources/config_all.json index b2998703..b48ca753 100644 --- a/components/slice-analysis-ms/src/test/resources/config_all.json +++ b/components/slice-analysis-ms/src/test/resources/config_all.json @@ -40,13 +40,13 @@ "aaf_password": null, "api_key" : null, "api_secret" : null, - "servers" : ["message-router"], + "servers" : ["message-router:3904"], "consumer_group" : "dcae_ccvpn_cl", "consumer_instance" : "dcae_ccvpn_cl_aaievent", "fetch_timeout" : 15000, "fetch_limit" : 100, "dmaap_info":{ - "topic_url":"https://message-router:3905/events/AAI_EVENT", + "topic_url":"http://message-router:3904/events/AAI-EVENT", "client_role":"org.onap.dcae.aaiSub", "location":"onap", "client_id":"sdnr-sliceanalysis-1" diff --git a/components/slice-analysis-ms/src/test/resources/onsetMessage2.json b/components/slice-analysis-ms/src/test/resources/onsetMessage2.json index 530c831f..dbcbda4c 100644 --- a/components/slice-analysis-ms/src/test/resources/onsetMessage2.json +++ b/components/slice-analysis-ms/src/test/resources/onsetMessage2.json @@ -1,6 +1,8 @@ { "closedLoopControlName": "ControlLoop-CCVPN-CLL-227e8b00-dbeb-4d03-8719-d0a658fb846c", "closedLoopAlarmStart": 1605691996370, + "modelInvariantUuid": "6790ab0e-034f-11eb-adc1-0242ac120002", + "modelUuid": "6790ab0e-034f-11eb-adc1-0242ac120002", "closedLoopEventClient": "microservice.sliceAnalysisMS", "closedLoopEventStatus": "ONSET", "requestID": "1e946480-1232-46d4-a39b-614ac534400f", |