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;
18 import org.onap.vfc.nfvo.emsdriver.commons.constant.Constant;
19 import org.onap.vfc.nfvo.emsdriver.commons.model.CollectMsg;
20 import org.onap.vfc.nfvo.emsdriver.commons.utils.DriverThread;
21 import org.onap.vfc.nfvo.emsdriver.messagemgr.MessageChannel;
22 import org.onap.vfc.nfvo.emsdriver.messagemgr.MessageChannelFactory;
24 public class CollectMsgReceiverThread extends DriverThread {
26 private long timeStamp = System.currentTimeMillis();
28 private MessageChannel collectChannel;
30 private TaskThreadService taskService;
32 private int threadMaxNum = 100;
36 public void dispose() {
37 collectChannel = MessageChannelFactory.getMessageChannel(Constant.COLLECT_CHANNEL_KEY);
39 taskService = TaskThreadService.getInstance(threadMaxNum);
45 if (System.currentTimeMillis() - timeStamp > Constant.ONEMINUTE) {
46 timeStamp = System.currentTimeMillis();
48 log.debug("COLLECT_CHANNEL Msg size :" + collectChannel.size());
51 Object obj = collectChannel.poll();
56 if (obj instanceof CollectMsg) {
57 CollectMsg collectMsg = (CollectMsg) obj;
58 taskService.add(collectMsg);
59 log.debug("receive a CollectMsg id = " + collectMsg.getId());
61 log.error("receive Objcet not CollectMsg " + obj);
64 } catch (Exception e) {
65 log.error("dispatch alarm exception", e);
74 * @return the threadMaxNum
76 public int getThreadMaxNum() {
82 * @param threadMaxNum the threadMaxNum to set
84 public void setThreadMaxNum(int threadMaxNum) {
85 this.threadMaxNum = threadMaxNum;
90 * @return the taskService
92 public TaskThreadService getTaskService() {