1 /*******************************************************************************
2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2022 Huawei Technologies Co., Ltd.
6 * ==============================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 *******************************************************************************/
22 package org.onap.slice.analysis.ms.service;
24 import org.onap.slice.analysis.ms.models.ConfigPolicy;
25 import org.onap.slice.analysis.ms.service.ccvpn.CCVPNPmDatastore;
26 import org.onap.slice.analysis.ms.utils.BeanUtil;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
31 * This thread is used to convert ccvpn runtime configurations from policy to our local memory CCVPNPmDatastore
33 public class ConfigThread extends Thread{
35 CCVPNPmDatastore ccvpnPmDatastore = BeanUtil.getBean(CCVPNPmDatastore.class);
36 private static Logger log = LoggerFactory.getLogger(ConfigThread.class);
38 public ConfigThread () {
43 log.info("Config Thread is starting...");
48 ConfigPolicy configPolicy = ConfigPolicy.getInstance();
49 if(configPolicy != null && configPolicy.getConfig() != null) {
51 Boolean clBwAssuranceStatus = null;
53 if(configPolicy.getConfig().containsKey("cllId")){
54 cllId = String.valueOf(configPolicy.getConfig().get("cllId"));
56 if(configPolicy.getConfig().containsKey("closedLoopStatus")){
57 clBwAssuranceStatus = String.valueOf(configPolicy.getConfig().get("closedLoopStatus")).equalsIgnoreCase("true");
59 if(configPolicy.getConfig().containsKey("originalBw")){
60 originalBw = Integer.parseInt(String.valueOf(configPolicy.getConfig().get("originalBw")));
62 if(cllId!=null && clBwAssuranceStatus!=null){
63 ccvpnPmDatastore.updateConfigFromPolicy(cllId, clBwAssuranceStatus, originalBw);
66 log.error("Config policy is empty, nothing to update.");
69 } catch (Exception e) {
70 log.error("Exception in Config Thread ", e);