summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorqingshuting <qingshuting1@huawei.com>2022-09-16 11:46:41 +0800
committerqingshuting <qingshuting1@huawei.com>2022-09-21 09:46:59 +0800
commit6c604ab12049847edb17370712ed2feb75b68581 (patch)
tree230f8d6d09703efea51bbeba54c26705e1dfadd6
parent1e79ea037afb8b679dab871b395ac64c7c745d49 (diff)
[SLICEANALYSIS] Fix bug of SDK fetch getting hung when policy config injakarta
pdp engine is empty Issue-ID: DCAEGEN2-3242 Signed-off-by: qingshuting <qingshuting1@huawei.com> Change-Id: I122b32ae382d1341b0cd3921a0b50bd005f36f98
-rw-r--r--components/slice-analysis-ms/ChangeLog.md3
-rw-r--r--components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/MainThread.java45
-rw-r--r--components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/controller/ConfigFetchFromCbs.java15
3 files changed, 35 insertions, 28 deletions
diff --git a/components/slice-analysis-ms/ChangeLog.md b/components/slice-analysis-ms/ChangeLog.md
index 5521e8f0..bdce8659 100644
--- a/components/slice-analysis-ms/ChangeLog.md
+++ b/components/slice-analysis-ms/ChangeLog.md
@@ -4,10 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
-
## [1.1.3] - 2022/05/11
- [DCAEGEN2-3156](https://jira.onap.org/browse/DCAEGEN2-3156) - Fix bug in fetching PM data from DES
+ - [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.2] - 2022/05/01
- [DCAEGEN2-3145](https://jira.onap.org/browse/DCAEGEN2-3145) - Filter RAN related service instances in AAI
diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/MainThread.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/MainThread.java
index 57a831ea..b80ac793 100644
--- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/MainThread.java
+++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/MainThread.java
@@ -1,22 +1,23 @@
/*******************************************************************************
* ============LICENSE_START=======================================================
- * son-handler
+ * slice-analysis-ms
* ================================================================================
* Copyright (C) 2019-2020 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.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * 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=========================================================
- *
+ *
*******************************************************************************/
package org.onap.slice.analysis.ms;
@@ -26,26 +27,26 @@ import org.onap.slice.analysis.ms.service.PmThread;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-/**
+/**
* This class starts the pm thread and consumer thread
*/
public class MainThread {
- private static Logger log = LoggerFactory.getLogger(MainThread.class);
-
- private MainThread() {
-
- }
-
- /**
- * main thread initialization.
- */
- public static void initiateThreads() {
- log.debug("initializing Pm thread & Consumer thread");
- Thread pmThread = new Thread(new PmThread());
- pmThread.start();
- Thread consumerThread = new Thread(new ConsumerThread());
- consumerThread.start();
- }
+ private static Logger log = LoggerFactory.getLogger(MainThread.class);
+
+ private MainThread() {
+
+ }
+
+ /**
+ * main thread initialization.
+ */
+ public static void initiateThreads() {
+ log.debug("initializing Pm thread & Consumer thread");
+ Thread pmThread = new Thread(new PmThread());
+ pmThread.start();
+ Thread consumerThread = new Thread(new ConsumerThread());
+ consumerThread.start();
+ }
}
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..ea93424a 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.
@@ -33,7 +34,6 @@ import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api.CbsClientFact
import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api.CbsRequests;
import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.CbsRequest;
import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.CbsClientConfiguration;
-import org.onap.dcaegen2.services.sdk.rest.services.model.logging.ImmutableRequestDiagnosticContext;
import org.onap.dcaegen2.services.sdk.rest.services.model.logging.RequestDiagnosticContext;
import org.onap.slice.analysis.ms.models.ConfigPolicy;
import org.onap.slice.analysis.ms.models.Configuration;
@@ -97,12 +97,17 @@ public class ConfigFetchFromCbs implements Runnable {
Type mapType = new TypeToken<Map<String, Object>>() {
}.getType();
+
if (jsonObject.getAsJsonObject("policies") != null) {
- JsonObject policyJson = jsonObject.getAsJsonObject("policies").getAsJsonArray("items").get(0)
+ 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");
- Map<String, Object> policy = new Gson().fromJson(policyJson, mapType);
- configPolicy.setConfig(policy);
- log.info("Config policy {}", configPolicy);
+ Map<String, Object> policy = new Gson().fromJson(policyJson, mapType);
+ configPolicy.setConfig(policy);
+ log.info("Config policy {}", configPolicy);
+ }
}
}, throwable -> log.warn("Ooops", throwable));
}