diff options
author | 2022-03-23 20:46:04 -0400 | |
---|---|---|
committer | 2022-04-15 23:21:29 -0400 | |
commit | ad5981f8e4969c41724885c830dda2cef304adf9 (patch) | |
tree | 486c291810101b2a325dab77c0c87b85a52e6f0c /components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap | |
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>
Diffstat (limited to 'components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap')
4 files changed, 50 insertions, 13 deletions
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); } |