fed44d2f70d00e3eacd68b61abaa0c4854a68b0f
[vfc/nfvo/driver/ems.git] /
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> &gt; <a href="index.source.html" class="el_package">org.onap.vfc.nfvo.emsdriver.collector</a> &gt; <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
3  *
4  * Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
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 &quot;AS IS&quot; 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;
17
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;
23
24 <span class="fc" id="L24">public class CollectMsgReceiverThread extends DriverThread{</span>
25
26 <span class="fc" id="L26">      private long timeStamp = System.currentTimeMillis();</span>
27         
28         private MessageChannel collectChannel;
29         
30         private TaskThreadService taskService;
31         
32 <span class="fc" id="L32">      private int thread_max_num = 100;</span>
33         
34         
35         
36         @Override
37         public void dispose() {
38 <span class="fc" id="L38">              collectChannel =  MessageChannelFactory.getMessageChannel(Constant.COLLECT_CHANNEL_KEY);</span>
39                 
40 <span class="fc" id="L40">              taskService = TaskThreadService.getInstance(thread_max_num);</span>
41 <span class="fc" id="L41">              taskService.start();</span>
42                 
43 <span class="fc bfc" id="L43" title="All 2 branches covered.">          while (isRun()) {</span>
44                         
45                         try {
46 <span class="pc bpc" id="L46" title="1 of 2 branches missed.">                          if(System.currentTimeMillis() - timeStamp &gt; Constant.ONEMINUTE){</span>
47 <span class="nc" id="L47">                                      timeStamp = System.currentTimeMillis();</span>
48                                         
49 <span class="nc" id="L49">                                      log.debug(&quot;COLLECT_CHANNEL Msg size :&quot;+collectChannel.size());</span>
50                                 }
51                                 
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>
56                                 }
57 <span class="nc bnc" id="L57" title="All 4 branches missed.">                           if(obj != null &amp;&amp; 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(&quot;receive a CollectMsg id = &quot;+collectMsg.getId());</span>
61 <span class="nc" id="L61">                              }else{</span>
62 <span class="nc" id="L62">                                      log.error(&quot;receive Objcet not CollectMsg &quot;+obj);</span>
63                                 }
64                                 
65 <span class="nc" id="L65">                      } catch (Exception e) {</span>
66 <span class="nc" id="L66">                              log.error(&quot;dispatch alarm exception&quot;,e);</span>
67                                 
68 <span class="nc" id="L68">                      }</span>
69                 }
70                 
71 <span class="fc" id="L71">      }</span>
72
73
74
75         /**
76          * @return the thread_max_num
77          */
78         public int getThread_max_num() {
79 <span class="fc" id="L79">              return thread_max_num;</span>
80         }
81
82
83
84         /**
85          * @param thread_max_num the thread_max_num to set
86          */
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>
90
91
92
93         /**
94          * @return the taskService
95          */
96         public TaskThreadService getTaskService() {
97 <span class="fc" id="L97">              return taskService;</span>
98         }
99
100
101
102         
103 }
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>