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.taskscheduler;
18 import java.util.ArrayList;
19 import java.util.List;
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.quartz.Job;
29 public class CollectManager extends DriverThread{
31 private ConfigurationInterface configurationInterface;
32 public void dispose() {
33 if(configurationInterface != null){
34 List<EMSInfo> emsInfos = configurationInterface.getAllEMSInfo();
35 while(isRun() && emsInfos.size() == 0){
37 emsInfos = configurationInterface.getAllEMSInfo();
38 if(emsInfos.size() == 0){
41 } catch (InterruptedException e) {
47 List<CollectVo> collectVos = new ArrayList<CollectVo>();
48 for(EMSInfo emsInfo : emsInfos){
50 CollectVo CollectVoCm = emsInfo.getCollectVoByType(Constant.COLLECT_TYPE_CM);
51 if(CollectVoCm != null){
52 CollectVoCm.setEmsName(emsInfo.getName());
53 collectVos.add(CollectVoCm);
57 CollectVo CollectVoPm = emsInfo.getCollectVoByType(Constant.COLLECT_TYPE_PM);
58 if(CollectVoPm != null){
59 CollectVoPm.setEmsName(emsInfo.getName());
60 collectVos.add(CollectVoPm);
64 if(collectVos.size() > 0){
65 this.addCollectJob(collectVos);
66 log.info("1 addCollectJob is OK ");
68 log.error("collectVos size is 0");
72 log.error("configurationInterface = null,check spring.xml");
76 private void addCollectJob(List<CollectVo> collectVos) {
77 for(CollectVo collectVo : collectVos){
79 String jobName = collectVo.getEmsName()+"_"+collectVo.getType()+collectVo.getIP();
80 Job job = new CollectOderJob();
81 String jobClass = job.getClass().getName();
82 String time = collectVo.getCrontab();
83 if(time != null && !"".equals(time)){
84 QuartzManager.addJob(jobName, jobClass, time,collectVo);
86 log.error("type =["+collectVo.getType()+"]ip=["+collectVo.getIP()+"] crontab is null,check EMSInfo.xml");
89 } catch (Exception e) {
90 log.error("addJob is error",e);
96 * @return the configurationInterface
98 public ConfigurationInterface getConfigurationInterface() {
99 return configurationInterface;
103 * @param configurationInterface the configurationInterface to set
105 public void setConfigurationInterface(
106 ConfigurationInterface configurationInterface) {
107 this.configurationInterface = configurationInterface;