2 * Copyright 2017 BOCO Corporation. CMCC Technologies Co., Ltd
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.onap.vfc.nfvo.emsdriver.collector.alarm;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
20 import org.onap.vfc.nfvo.emsdriver.commons.constant.Constant;
21 import org.onap.vfc.nfvo.emsdriver.commons.model.CollectVo;
22 import org.onap.vfc.nfvo.emsdriver.commons.model.EMSInfo;
23 import org.onap.vfc.nfvo.emsdriver.commons.utils.DriverThread;
24 import org.onap.vfc.nfvo.emsdriver.configmgr.ConfigurationInterface;
25 import org.onap.vfc.nfvo.emsdriver.configmgr.ConfigurationManager;
27 import java.util.ArrayList;
28 import java.util.List;
30 public class AlarmManager extends DriverThread {
31 protected static final Logger logger = LoggerFactory.getLogger(AlarmManager.class);
32 private ConfigurationInterface configurationInterface;
35 public void dispose() {
36 logger.debug("AlarmManager is start");
37 // get alarm CONFIG_PROPERTIES_LOCATION
38 List<EMSInfo> emsInfos = configurationInterface.getAllEMSInfo();
39 while (isRun() && emsInfos.isEmpty()) {
40 emsInfos = configurationInterface.getAllEMSInfo();
41 if (emsInfos.isEmpty()) {
44 logger.debug("The configuration properties from "
45 + ConfigurationManager.CONFIG_PROPERTIES_LOCATION
47 } catch (Exception e) {
48 logger.error("Exception", e);
52 List<CollectVo> collectVos = new ArrayList<>();
53 for (EMSInfo emsInfo : emsInfos) {
55 CollectVo collectVo = emsInfo.getCollectVoByType(Constant.COLLECT_TYPE_ALARM);
56 if (collectVo != null) {
57 collectVo.setEmsName(emsInfo.getName());
58 collectVos.add(collectVo);
60 logger.error("emsInfo.getCollectVoByType(EMS_RESOUCE) result CollectVo = null emsInfo ="
65 for (CollectVo collectVo : collectVos) {
66 AlarmTaskThread alarm = new AlarmTaskThread(collectVo);
67 alarm.setName(collectVo.getIP() + collectVo.getPort());
69 logger.info("AlarmTaskThread is start");
75 * @return the configurationInterface
77 public ConfigurationInterface getConfigurationInterface() {
78 return configurationInterface;
82 * @param configurationInterface the configurationInterface to set
84 public void setConfigurationInterface(
85 ConfigurationInterface configurationInterface) {
86 this.configurationInterface = configurationInterface;