summaryrefslogtreecommitdiffstats
path: root/components/slice-analysis-ms
diff options
context:
space:
mode:
Diffstat (limited to 'components/slice-analysis-ms')
-rw-r--r--components/slice-analysis-ms/ChangeLog.md1
-rw-r--r--components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/controller/ConfigFetchFromCbs.java38
2 files changed, 22 insertions, 17 deletions
diff --git a/components/slice-analysis-ms/ChangeLog.md b/components/slice-analysis-ms/ChangeLog.md
index f3a6910b..bae8280d 100644
--- a/components/slice-analysis-ms/ChangeLog.md
+++ b/components/slice-analysis-ms/ChangeLog.md
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## [1.1.4] - 2022/07/28
- [DCAEGEN2-3120](https://jira.onap.org/browse/DCAEGEN2-3120) - Enhance sliceanalysis MS to use DCAE SDK dmaap-client lib
- [DCAEGEN2-3157](https://jira.onap.org/browse/DCAEGEN2-3157) - CodeCoverage improvement for dcaegen2-services-slice-analysis-ms
+ - [DCAEGEN2-3242](https://jira.onap.org/browse/DCAEGEN2-3242) - Fix bug in ConfigFectchFromCbs that fetch will get hung when policy config in pdp engine is empty
## [1.1.3] - 2022/05/11
- [DCAEGEN2-3156](https://jira.onap.org/browse/DCAEGEN2-3156) - Fix bug in fetching PM data from DES
diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/controller/ConfigFetchFromCbs.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/controller/ConfigFetchFromCbs.java
index fbb47e32..2bdb0506 100644
--- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/controller/ConfigFetchFromCbs.java
+++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/controller/ConfigFetchFromCbs.java
@@ -3,6 +3,7 @@
* slice-analysis-ms
* ================================================================================
* Copyright (C) 2020-2021 Wipro 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.
@@ -82,33 +83,36 @@ public class ConfigFetchFromCbs implements Runnable {
// Create the client and use it to get the configuration
final CbsRequest request = CbsRequests.getAll(diagnosticContext);
return CbsClientFactory.createCbsClient(cbsClientConfiguration)
- .flatMapMany(cbsClient -> cbsClient.updates(request, initialDelay, period)).subscribe(jsonObject -> {
- log.info("configuration and policy from CBS {}", jsonObject);
- JsonObject config = jsonObject.getAsJsonObject("config");
- Duration newPeriod = Duration.ofSeconds(config.get("cbsPollingInterval").getAsInt());
- if (!newPeriod.equals(period)) {
- interval = newPeriod;
- synchronized (this) {
- this.notifyAll();
- }
-
+ .flatMapMany(cbsClient -> cbsClient.updates(request, initialDelay, period)).subscribe(jsonObject -> {
+ log.info("configuration and policy from CBS {}", jsonObject);
+ JsonObject config = jsonObject.getAsJsonObject("config");
+ Duration newPeriod = Duration.ofSeconds(config.get("cbsPollingInterval").getAsInt());
+ if (!newPeriod.equals(period)) {
+ interval = newPeriod;
+ synchronized (this) {
+ this.notifyAll();
}
- Configuration.getInstance().updateConfigurationFromJsonObject(config);
+ }
+ Configuration.getInstance().updateConfigurationFromJsonObject(config);
+
+ Type mapType = new TypeToken<Map<String, Object>>() {
+ }.getType();
- Type mapType = new TypeToken<Map<String, Object>>() {
- }.getType();
- if (jsonObject.getAsJsonObject("policies") != null) {
+ if (jsonObject.getAsJsonObject("policies") != null) {
+ if(jsonObject.getAsJsonObject("policies").getAsJsonArray("items").size() == 0) {
+ log.error("No policy in policy drool pdp engine, nothing to update.");
+ } else {
JsonObject policyJson = jsonObject.getAsJsonObject("policies").getAsJsonArray("items").get(0)
- .getAsJsonObject().getAsJsonObject("config");
+ .getAsJsonObject().getAsJsonObject("config");
Map<String, Object> policy = new Gson().fromJson(policyJson, mapType);
configPolicy.setConfig(policy);
log.info("Config policy {}", configPolicy);
}
- }, throwable -> log.warn("Ooops", throwable));
+ }
+ }, throwable -> log.warn("Ooops", throwable));
}
-
@Override
public void run() {
Boolean done = false;