[ 
https://issues.apache.org/jira/browse/ROCKETMQ-160?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15952112#comment-15952112
 ] 

ASF GitHub Bot commented on ROCKETMQ-160:
-----------------------------------------

GitHub user Jaskey opened a pull request:

    https://github.com/apache/incubator-rocketmq/pull/86

    [ROCKETMQ-160]SendHeartBeat may not be logged in the expected period

    JIRA:https://issues.apache.org/jira/browse/ROCKETMQ-160

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/Jaskey/incubator-rocketmq 
ROCKETMQ-160-heartbeat-log

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-rocketmq/pull/86.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #86
    
----
commit fab38018a89ace83a079f0f39c233dff91735e14
Author: Jaskey <[email protected]>
Date:   2017-04-01T07:38:49Z

    ROCKETMQ-160-SendHeartBeart log may not be triggered in the same expected 
period

----


> SendHeartBeart log may not be triggered in the same expected period
> -------------------------------------------------------------------
>
>                 Key: ROCKETMQ-160
>                 URL: https://issues.apache.org/jira/browse/ROCKETMQ-160
>             Project: Apache RocketMQ
>          Issue Type: Improvement
>          Components: rocketmq-client
>            Reporter: Jaskey Lam
>            Assignee: Jaskey Lam
>            Priority: Minor
>
> {code}
>     private void sendHeartbeatToAllBroker() {
>         final HeartbeatData heartbeatData = this.prepareHeartbeatData();
>         final boolean producerEmpty = 
> heartbeatData.getProducerDataSet().isEmpty();
>         final boolean consumerEmpty = 
> heartbeatData.getConsumerDataSet().isEmpty();
>         if (producerEmpty && consumerEmpty) {
>             log.warn("sending heartbeat, but no consumer and no producer");
>             return;
>         }
>         long times = this.storeTimesTotal.getAndIncrement();//here every time 
> when the method is call, the times will increase even though acatully no 
> heartbeat is sent
>         Iterator<Entry<String, HashMap<Long, String>>> it = 
> this.brokerAddrTable.entrySet().iterator();
>         while (it.hasNext()) {
>             Entry<String, HashMap<Long, String>> entry = it.next();
>             String brokerName = entry.getKey();
>             HashMap<Long, String> oneTable = entry.getValue();
>             if (oneTable != null) {
>                 for (Map.Entry<Long, String> entry1 : oneTable.entrySet()) {
>                     Long id = entry1.getKey();
>                     String addr = entry1.getValue();
>                     if (addr != null) {
>                         if (consumerEmpty) {
>                             if (id != MixAll.MASTER_ID)
>                                 continue;
>                         }
>                         try {
>                             this.mQClientAPIImpl.sendHearbeat(addr, 
> heartbeatData, 3000);
>                             if (times % 20 == 0) {//since the first call is 
> times !=1, the heart beat log for the first heart beat could be missed
>                                 log.info("send heart beat to broker[{} {} {}] 
> success", brokerName, id, addr);
>                                 log.info(heartbeatData.toString());
>                             }
>                         } catch (Exception e) {
>                             if (this.isBrokerInNameServer(addr)) {
>                                 log.error("send heart beat to broker 
> exception", e);
>                             } else {
>                                 log.info("send heart beat to broker[{} {} {}] 
> exception, because the broker not up, forget it", brokerName,
>                                     id, addr);
>                             }
>                         }
>                     }
>                 }
>             }
>         }
>     }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to