[SLICEANALYSIS] Bugfix for sliceanalysis startup Exception, springcontext config... 99/131199/5
authordecheng zhang <decheng.zhang@huawei.com>
Mon, 26 Sep 2022 18:42:41 +0000 (14:42 -0400)
committerdecheng zhang <decheng.zhang@huawei.com>
Tue, 27 Sep 2022 14:28:58 +0000 (10:28 -0400)
Remove duplicated SpringContextUtil

Issue-ID: DCAEGEN2-3270
Signed-off-by: decheng zhang <decheng.zhang@huawei.com>
Change-Id: I463e6f8c1b33db61f64b4fe5f3dc38a1bc94f0f6
Signed-off-by: decheng zhang <decheng.zhang@huawei.com>
components/slice-analysis-ms/ChangeLog.md
components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/ConfigThread.java
components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/utils/SpringContextUtil.java [deleted file]

index 417ad64..aadb09b 100644 (file)
@@ -16,11 +16,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
          - [DCAEGEN2-3255](https://jira.onap.org/browse/DCAEGEN2-3255) - Fix bug of application failed to start
 
          - [DCAEGEN2-3264](https://jira.onap.org/browse/DCAEGEN2-3264) - Fix bug that cll service instance info didn't get updated when a cll service is deleted
-    
+
          - [DCAEGEN2-3240](https://jira.onap.org/browse/DCAEGEN2-3240) - Implement runtime service configuration
 
          - [DCAEGEN2-3273](https://jira.onap.org/browse/DCAEGEN2-3273) - Fix bug that config thread hang up when cbs policy is empty
 
+         - [DCAEGEN2-3270](https://jira.onap.org/browse/DCAEGEN2-3270) - Dcae slicems startup error
+
 ## [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
 
index 0bd41e2..88477eb 100644 (file)
@@ -1,76 +1,75 @@
-/*******************************************************************************\r
- *  ============LICENSE_START=======================================================\r
- *  slice-analysis-ms\r
- *  ================================================================================\r
- *   Copyright (C) 2022 Huawei Technologies Co., Ltd.\r
- *   ==============================================================================\r
- *     Licensed under the Apache License, Version 2.0 (the "License");\r
- *     you may not use this file except in compliance with the License.\r
- *     You may obtain a copy of the License at\r
- *\r
- *          http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- *     Unless required by applicable law or agreed to in writing, software\r
- *     distributed under the License is distributed on an "AS IS" BASIS,\r
- *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- *     See the License for the specific language governing permissions and\r
- *     limitations under the License.\r
- *     ============LICENSE_END=========================================================\r
- *\r
- *******************************************************************************/\r
-\r
-package org.onap.slice.analysis.ms.service;\r
-\r
-import org.onap.slice.analysis.ms.models.ConfigPolicy;\r
-import org.onap.slice.analysis.ms.service.ccvpn.CCVPNPmDatastore;\r
-import org.onap.slice.analysis.ms.utils.SpringContextUtil;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-/**\r
- * This thread is used to convert ccvpn runtime configurations from policy to our local memory CCVPNPmDatastore\r
- */\r
-public class ConfigThread extends Thread{\r
-\r
-    CCVPNPmDatastore ccvpnPmDatastore = (CCVPNPmDatastore) SpringContextUtil.getBean(CCVPNPmDatastore.class);\r
-    private static Logger log = LoggerFactory.getLogger(ConfigThread.class);\r
-\r
-\r
-    public ConfigThread () {\r
-        super();\r
-    }\r
-\r
-    public void run() {\r
-        log.info("Config Thread is starting...");\r
-        boolean done = false;\r
-        while(!done) {\r
-            try {\r
-                Thread.sleep(1000);\r
-                ConfigPolicy configPolicy = ConfigPolicy.getInstance();\r
-                if(configPolicy.getConfig() != null) {\r
-                    String cllId = null;\r
-                    Boolean clBwAssuranceStatus = null;\r
-                    int originalBw = 0;\r
-                    if(configPolicy.getConfig().containsKey("cllId")){\r
-                        cllId = String.valueOf(configPolicy.getConfig().get("cllId"));\r
-                    }\r
-                    if(configPolicy.getConfig().containsKey("closedLoopStatus")){\r
-                        clBwAssuranceStatus = String.valueOf(configPolicy.getConfig().get("closedLoopStatus")).equalsIgnoreCase("true");\r
-                    }\r
-                    if(configPolicy.getConfig().containsKey("originalBw")){\r
-                        originalBw = Integer.parseInt(String.valueOf(configPolicy.getConfig().get("originalBw")));\r
-                    }\r
-                    if(cllId!=null && clBwAssuranceStatus!=null){\r
-                        ccvpnPmDatastore.updateConfigFromPolicy(cllId, clBwAssuranceStatus, originalBw);\r
-                    }\r
-                } else {\r
-                    log.error("Config policy is empty, nothing to update.");\r
-                }\r
-\r
-            } catch (Exception e) {\r
-                log.error("Exception in Config Thread ", e);\r
-                done = true;\r
-            }\r
-        }\r
-    }\r
-}\r
+/*******************************************************************************
+ *  ============LICENSE_START=======================================================
+ *  slice-analysis-ms
+ *  ================================================================================
+ *   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
+ *
+ *     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.service;
+
+import org.onap.slice.analysis.ms.models.ConfigPolicy;
+import org.onap.slice.analysis.ms.service.ccvpn.CCVPNPmDatastore;
+import org.onap.slice.analysis.ms.utils.BeanUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This thread is used to convert ccvpn runtime configurations from policy to our local memory CCVPNPmDatastore
+ */
+public class ConfigThread extends Thread{
+
+    CCVPNPmDatastore ccvpnPmDatastore = BeanUtil.getBean(CCVPNPmDatastore.class);
+    private static Logger log = LoggerFactory.getLogger(ConfigThread.class);
+
+    public ConfigThread () {
+        super();
+    }
+
+    public void run() {
+        log.info("Config Thread is starting...");
+        boolean done = false;
+        while(!done) {
+            try {
+                Thread.sleep(1000);
+                ConfigPolicy configPolicy = ConfigPolicy.getInstance();
+                if(configPolicy != null && configPolicy.getConfig() != null) {
+                    String cllId = null;
+                    Boolean clBwAssuranceStatus = null;
+                    int originalBw = 0;
+                    if(configPolicy.getConfig().containsKey("cllId")){
+                        cllId = String.valueOf(configPolicy.getConfig().get("cllId"));
+                    }
+                    if(configPolicy.getConfig().containsKey("closedLoopStatus")){
+                        clBwAssuranceStatus = String.valueOf(configPolicy.getConfig().get("closedLoopStatus")).equalsIgnoreCase("true");
+                    }
+                    if(configPolicy.getConfig().containsKey("originalBw")){
+                        originalBw = Integer.parseInt(String.valueOf(configPolicy.getConfig().get("originalBw")));
+                    }
+                    if(cllId!=null && clBwAssuranceStatus!=null){
+                        ccvpnPmDatastore.updateConfigFromPolicy(cllId, clBwAssuranceStatus, originalBw);
+                    }
+                } else {
+                    log.error("Config policy is empty, nothing to update.");
+                }
+
+            } catch (Exception e) {
+                log.error("Exception in Config Thread ", e);
+                done = true;
+            }
+        }
+    }
+}
diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/utils/SpringContextUtil.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/utils/SpringContextUtil.java
deleted file mode 100644 (file)
index ebe227d..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************\r
- *  ============LICENSE_START=======================================================\r
- *   slice-analysis-ms\r
- *  ================================================================================\r
- *   Copyright (C) 2022 Huawei Technologies Co., Ltd.\r
- *   ==============================================================================\r
- *     Licensed under the Apache License, Version 2.0 (the "License");\r
- *     you may not use this file except in compliance with the License.\r
- *     You may obtain a copy of the License at\r
- *\r
- *          http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- *     Unless required by applicable law or agreed to in writing, software\r
- *     distributed under the License is distributed on an "AS IS" BASIS,\r
- *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- *     See the License for the specific language governing permissions and\r
- *     limitations under the License.\r
- *     ============LICENSE_END=========================================================\r
- *\r
- *******************************************************************************/\r
-\r
-package org.onap.slice.analysis.ms.utils;\r
-\r
-import org.springframework.beans.BeansException;\r
-import org.springframework.context.ApplicationContext;\r
-import org.springframework.context.ApplicationContextAware;\r
-import org.springframework.context.annotation.Configuration;\r
-\r
-/**\r
- * This is provided for threads to get bean.\r
- */\r
-@Configuration\r
-public class SpringContextUtil implements ApplicationContextAware {\r
-    private static ApplicationContext applicationContext = null;\r
-\r
-    @Override\r
-    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {\r
-        SpringContextUtil.applicationContext = applicationContext;\r
-    }\r
-\r
-    public static ApplicationContext getApplicationContext() {\r
-        return applicationContext;\r
-    }\r
-\r
-    public static Object getBean(String beanName) {\r
-        return applicationContext.getBean(beanName);\r
-    }\r
-\r
-    public static Object getBean(Class c) {\r
-        return applicationContext.getBean(c);\r
-    }\r
-}\r