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