summaryrefslogtreecommitdiffstats
path: root/components/slice-analysis-ms/src/main/java/org/onap/slice
diff options
context:
space:
mode:
Diffstat (limited to 'components/slice-analysis-ms/src/main/java/org/onap/slice')
-rw-r--r--components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/controller/ConfigFetchFromCbs.java38
1 files changed, 21 insertions, 17 deletions
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;