-/*******************************************************************************\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;
+ }
+ }
+ }
+}
+++ /dev/null
-/*******************************************************************************\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