Modify groupId for ems driver
[vfc/nfvo/driver/ems.git] / ems / boco / src / main / java / org / onap / vfc / nfvo / emsdriver / collector / alarm / AlarmManager.java
1 /**
2  * Copyright 2017 BOCO Corporation. CMCC Technologies Co., Ltd
3  *
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 package org.onap.vfc.nfvo.emsdriver.collector.alarm;
17 import java.util.ArrayList;
18 import java.util.List;
19
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
26 public class AlarmManager  extends DriverThread{
27
28         private ConfigurationInterface configurationInterface;
29         
30         @Override
31         public void dispose() {
32                 log.debug("AlarmManager is start");
33                 //get alarm config
34                 List<EMSInfo> emsInfos = configurationInterface.getAllEMSInfo();
35                 while(isRun() && emsInfos.size() == 0){
36                         emsInfos = configurationInterface.getAllEMSInfo();
37                         if(emsInfos.size() == 0){
38                                 try {
39                                         Thread.sleep(1000);
40                                         log.debug("config is not load");
41                                 } catch (InterruptedException e) {
42                                 }
43                         }
44                 }
45                 List<CollectVo> collectVos = new ArrayList<CollectVo>();
46                 for(EMSInfo emsInfo : emsInfos){
47                         //alarm
48                         CollectVo CollectVo = emsInfo.getCollectVoByType(Constant.COLLECT_TYPE_ALARM);
49                         if(CollectVo != null){
50                                 CollectVo.setEmsName(emsInfo.getName());
51                                 collectVos.add(CollectVo);
52                         }
53                 }
54                 
55                 for(CollectVo collectVo : collectVos){
56                         AlarmTaskThread alarm = new AlarmTaskThread(collectVo);
57                         alarm.setName(collectVo.getIP()+collectVo.getPort());
58                         alarm.start();
59                 }
60                 
61         }
62
63         /**
64          * @return the configurationInterface
65          */
66         public ConfigurationInterface getConfigurationInterface() {
67                 return configurationInterface;
68         }
69
70         /**
71          * @param configurationInterface the configurationInterface to set
72          */
73         public void setConfigurationInterface(
74                         ConfigurationInterface configurationInterface) {
75                 this.configurationInterface = configurationInterface;
76         }
77         
78         
79
80 }