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.onap.vfc.nfvo.emsdriver.commons.constant.Constant;
19 import org.onap.vfc.nfvo.emsdriver.commons.model.CollectVo;
20 import org.onap.vfc.nfvo.emsdriver.commons.model.EMSInfo;
21 import org.onap.vfc.nfvo.emsdriver.commons.utils.DriverThread;
22 import org.onap.vfc.nfvo.emsdriver.configmgr.ConfigurationInterface;
23 import org.onap.vfc.nfvo.emsdriver.configmgr.ConfigurationManager;
25 import java.util.ArrayList;
26 import java.util.List;
28 public class AlarmManager extends DriverThread {
30 private ConfigurationInterface configurationInterface;
33 public void dispose() {
34 log.debug("AlarmManager is start");
35 //get alarm CONFIG_PROPERTIES_LOCATION
36 List<EMSInfo> emsInfos = configurationInterface.getAllEMSInfo();
37 while (isRun() && emsInfos.isEmpty()) {
38 emsInfos = configurationInterface.getAllEMSInfo();
39 if (emsInfos.isEmpty()) {
42 log.debug("The configuration properties from " + ConfigurationManager.CONFIG_PROPERTIES_LOCATION + " is not load");
43 } catch (Exception e) {
44 log.error("Exception",e);
48 List<CollectVo> collectVos = new ArrayList<>();
49 for (EMSInfo emsInfo : emsInfos) {
51 CollectVo collectVo = emsInfo.getCollectVoByType(Constant.COLLECT_TYPE_ALARM);
52 if (collectVo != null) {
53 collectVo.setEmsName(emsInfo.getName());
54 collectVos.add(collectVo);
56 log.error("emsInfo.getCollectVoByType(EMS_RESOUCE) result CollectVo = null emsInfo =" + emsInfo);
60 for (CollectVo collectVo : collectVos) {
61 AlarmTaskThread alarm = new AlarmTaskThread(collectVo);
62 alarm.setName(collectVo.getIP() + collectVo.getPort());
64 log.info("AlarmTaskThread is start");
70 * @return the configurationInterface
72 public ConfigurationInterface getConfigurationInterface() {
73 return configurationInterface;
77 * @param configurationInterface the configurationInterface to set
79 public void setConfigurationInterface(
80 ConfigurationInterface configurationInterface) {
81 this.configurationInterface = configurationInterface;