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.collector.CollectMsgReceiverThread;
21 import org.onap.vfc.nfvo.emsdriver.commons.constant.Constant;
22 import org.onap.vfc.nfvo.emsdriver.commons.model.CollectVo;
23 import org.onap.vfc.nfvo.emsdriver.commons.model.EMSInfo;
24 import org.onap.vfc.nfvo.emsdriver.commons.utils.DriverThread;
25 import org.onap.vfc.nfvo.emsdriver.configmgr.ConfigurationInterface;
26 import org.onap.vfc.nfvo.emsdriver.configmgr.ConfigurationManager;
28 import java.util.ArrayList;
29 import java.util.List;
31 public class AlarmManager extends DriverThread {
32 protected static final Logger logger = LoggerFactory.getLogger(AlarmManager.class);
33 private ConfigurationInterface configurationInterface;
36 public void dispose() {
37 logger.debug("AlarmManager is start");
38 // get alarm CONFIG_PROPERTIES_LOCATION
39 List<EMSInfo> emsInfos = configurationInterface.getAllEMSInfo();
40 while (isRun() && emsInfos.isEmpty()) {
41 emsInfos = configurationInterface.getAllEMSInfo();
42 if (emsInfos.isEmpty()) {
45 logger.debug("The configuration properties from "
46 + ConfigurationManager.CONFIG_PROPERTIES_LOCATION
48 } catch (Exception e) {
49 logger.error("Exception", e);
53 List<CollectVo> collectVos = new ArrayList<>();
54 for (EMSInfo emsInfo : emsInfos) {
56 CollectVo collectVo = emsInfo.getCollectVoByType(Constant.COLLECT_TYPE_ALARM);
57 if (collectVo != null) {
58 collectVo.setEmsName(emsInfo.getName());
59 collectVos.add(collectVo);
61 logger.error("emsInfo.getCollectVoByType(EMS_RESOUCE) result CollectVo = null emsInfo ="
66 for (CollectVo collectVo : collectVos) {
67 AlarmTaskThread alarm = new AlarmTaskThread(collectVo);
68 alarm.setName(collectVo.getIP() + collectVo.getPort());
70 logger.info("AlarmTaskThread is start");
76 * @return the configurationInterface
78 public ConfigurationInterface getConfigurationInterface() {
79 return configurationInterface;
83 * @param configurationInterface the configurationInterface to set
85 public void setConfigurationInterface(
86 ConfigurationInterface configurationInterface) {
87 this.configurationInterface = configurationInterface;