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 this.addCollectJob(collectVos);
65 log.info("addCollectJob is OK ");
67 log.error("configurationInterface = null,check spring.xml");
71 private void addCollectJob(List<CollectVo> collectVos) {
72 for(CollectVo collectVo : collectVos){
74 String jobName = collectVo.getEmsName()+"_"+collectVo.getType()+collectVo.getIP();
75 Job job = new CollectOderJob();
76 String jobClass = job.getClass().getName();
77 String time = collectVo.getCrontab();
78 if(time != null && !"".equals(time)){
79 QuartzManager.addJob(jobName, jobClass, time,collectVo);
81 log.error("type =["+collectVo.getType()+"]ip=["+collectVo.getIP()+"] crontab is null,check EMSInfo.xml");
84 } catch (Exception e) {
85 log.error("addJob is error",e);
91 * @return the configurationInterface
93 public ConfigurationInterface getConfigurationInterface() {
94 return configurationInterface;
98 * @param configurationInterface the configurationInterface to set
100 public void setConfigurationInterface(
101 ConfigurationInterface configurationInterface) {
102 this.configurationInterface = configurationInterface;