1 <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>CollectMsgReceiverThread.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">vfc-nfvo-driver-ems-ems-boco</a> > <a href="index.source.html" class="el_package">org.onap.vfc.nfvo.emsdriver.collector</a> > <span class="el_source">CollectMsgReceiverThread.java</span></div><h1>CollectMsgReceiverThread.java</h1><pre class="source lang-java linenums">/**
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 <span class="fc" id="L24">public class CollectMsgReceiverThread extends DriverThread{</span>
26 <span class="fc" id="L26"> private long timeStamp = System.currentTimeMillis();</span>
28 private MessageChannel collectChannel;
30 private TaskThreadService taskService;
32 <span class="fc" id="L32"> private int thread_max_num = 100;</span>
37 public void dispose() {
38 <span class="fc" id="L38"> collectChannel = MessageChannelFactory.getMessageChannel(Constant.COLLECT_CHANNEL_KEY);</span>
40 <span class="fc" id="L40"> taskService = TaskThreadService.getInstance(thread_max_num);</span>
41 <span class="fc" id="L41"> taskService.start();</span>
43 <span class="fc bfc" id="L43" title="All 2 branches covered."> while (isRun()) {</span>
46 <span class="pc bpc" id="L46" title="1 of 2 branches missed."> if(System.currentTimeMillis() - timeStamp > Constant.ONEMINUTE){</span>
47 <span class="nc" id="L47"> timeStamp = System.currentTimeMillis();</span>
49 <span class="nc" id="L49"> log.debug("COLLECT_CHANNEL Msg size :"+collectChannel.size());</span>
52 <span class="fc" id="L52"> Object obj = collectChannel.poll();</span>
53 <span class="pc bpc" id="L53" title="1 of 2 branches missed."> if(obj == null){</span>
54 <span class="fc" id="L54"> Thread.sleep(10);</span>
55 <span class="fc" id="L55"> continue;</span>
57 <span class="nc bnc" id="L57" title="All 4 branches missed."> if(obj != null && obj instanceof CollectMsg){</span>
58 <span class="nc" id="L58"> CollectMsg collectMsg = (CollectMsg)obj;</span>
59 <span class="nc" id="L59"> taskService.add(collectMsg);</span>
60 <span class="nc" id="L60"> log.debug("receive a CollectMsg id = "+collectMsg.getId());</span>
61 <span class="nc" id="L61"> }else{</span>
62 <span class="nc" id="L62"> log.error("receive Objcet not CollectMsg "+obj);</span>
65 <span class="nc" id="L65"> } catch (Exception e) {</span>
66 <span class="nc" id="L66"> log.error("dispatch alarm exception",e);</span>
68 <span class="nc" id="L68"> }</span>
71 <span class="fc" id="L71"> }</span>
76 * @return the thread_max_num
78 public int getThread_max_num() {
79 <span class="fc" id="L79"> return thread_max_num;</span>
85 * @param thread_max_num the thread_max_num to set
87 public void setThread_max_num(int thread_max_num) {
88 <span class="fc" id="L88"> this.thread_max_num = thread_max_num;</span>
89 <span class="fc" id="L89"> }</span>
94 * @return the taskService
96 public TaskThreadService getTaskService() {
97 <span class="fc" id="L97"> return taskService;</span>
104 </pre><div class="footer"><span class="right">Created with <a href="http://www.eclemma.org/jacoco">JaCoCo</a> 0.7.7.201606060606</span></div></body></html>