From commits-return-1443-apmail-rocketmq-commits-archive=rocketmq.apache.org@rocketmq.incubator.apache.org Tue Jun 6 03:38:33 2017 Return-Path: X-Original-To: apmail-rocketmq-commits-archive@minotaur.apache.org Delivered-To: apmail-rocketmq-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 24EBB191AD for ; Tue, 6 Jun 2017 03:38:33 +0000 (UTC) Received: (qmail 9139 invoked by uid 500); 6 Jun 2017 03:38:33 -0000 Delivered-To: apmail-rocketmq-commits-archive@rocketmq.apache.org Received: (qmail 9100 invoked by uid 500); 6 Jun 2017 03:38:33 -0000 Mailing-List: contact commits-help@rocketmq.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@rocketmq.incubator.apache.org Delivered-To: mailing list commits@rocketmq.incubator.apache.org Received: (qmail 9086 invoked by uid 99); 6 Jun 2017 03:38:33 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Jun 2017 03:38:33 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 969A2CF7BA for ; Tue, 6 Jun 2017 03:38:32 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -3.721 X-Spam-Level: X-Spam-Status: No, score=-3.721 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_NUMSUBJECT=0.5, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id oeODAYSJHqfY for ; Tue, 6 Jun 2017 03:38:31 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id 9044960D7D for ; Tue, 6 Jun 2017 03:38:29 +0000 (UTC) Received: (qmail 6316 invoked by uid 99); 6 Jun 2017 03:38:23 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Jun 2017 03:38:23 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id F0BF2E9645; Tue, 6 Jun 2017 03:38:22 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: dongeforever@apache.org To: commits@rocketmq.incubator.apache.org Date: Tue, 06 Jun 2017 03:39:09 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [49/51] [abbrv] incubator-rocketmq git commit: [ROCKETMQ-160]SendHeartBeat may not be logged in the expected period closes apache/incubator-rocketmq#86 [ROCKETMQ-160]SendHeartBeat may not be logged in the expected period closes apache/incubator-rocketmq#86 Project: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/commit/1f4b893c Tree: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/tree/1f4b893c Diff: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/diff/1f4b893c Branch: refs/heads/master Commit: 1f4b893ce70c615daa0c8fce948cef776c108d92 Parents: 787d128 Author: Jaskey Authored: Sat May 27 12:38:00 2017 +0800 Committer: dongeforever Committed: Tue Jun 6 11:37:29 2017 +0800 ---------------------------------------------------------------------- .../client/impl/factory/MQClientInstance.java | 66 ++++++++++---------- 1 file changed, 34 insertions(+), 32 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/1f4b893c/client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java ---------------------------------------------------------------------- diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java b/client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java index a8c65b2..1b075ee 100644 --- a/client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java +++ b/client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java @@ -112,7 +112,7 @@ public class MQClientInstance { private final RebalanceService rebalanceService; private final DefaultMQProducer defaultMQProducer; private final ConsumerStatsManager consumerStatsManager; - private final AtomicLong storeTimesTotal = new AtomicLong(0); + private final AtomicLong sendHeartbeatTimesTotal = new AtomicLong(0); private ServiceState serviceState = ServiceState.CREATE_JUST; private DatagramSocket datagramSocket; private Random random = new Random(); @@ -517,38 +517,40 @@ public class MQClientInstance { return; } - long times = this.storeTimesTotal.getAndIncrement(); - Iterator>> it = this.brokerAddrTable.entrySet().iterator(); - while (it.hasNext()) { - Entry> entry = it.next(); - String brokerName = entry.getKey(); - HashMap oneTable = entry.getValue(); - if (oneTable != null) { - for (Map.Entry entry1 : oneTable.entrySet()) { - Long id = entry1.getKey(); - String addr = entry1.getValue(); - if (addr != null) { - if (consumerEmpty) { - if (id != MixAll.MASTER_ID) - continue; - } - - try { - int version = this.mQClientAPIImpl.sendHearbeat(addr, heartbeatData, 3000); - if (!this.brokerVersionTable.containsKey(brokerName)) { - this.brokerVersionTable.put(brokerName, new HashMap(4)); - } - this.brokerVersionTable.get(brokerName).put(addr, version); - if (times % 20 == 0) { - log.info("send heart beat to broker[{} {} {}] success", brokerName, id, addr); - log.info(heartbeatData.toString()); + if (!this.brokerAddrTable.isEmpty()) { + long times = this.sendHeartbeatTimesTotal.getAndIncrement(); + Iterator>> it = this.brokerAddrTable.entrySet().iterator(); + while (it.hasNext()) { + Entry> entry = it.next(); + String brokerName = entry.getKey(); + HashMap oneTable = entry.getValue(); + if (oneTable != null) { + for (Map.Entry entry1 : oneTable.entrySet()) { + Long id = entry1.getKey(); + String addr = entry1.getValue(); + if (addr != null) { + if (consumerEmpty) { + if (id != MixAll.MASTER_ID) + continue; } - } 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); + + try { + int version = this.mQClientAPIImpl.sendHearbeat(addr, heartbeatData, 3000); + if (!this.brokerVersionTable.containsKey(brokerName)) { + this.brokerVersionTable.put(brokerName, new HashMap(4)); + } + this.brokerVersionTable.get(brokerName).put(addr, version); + if (times % 20 == 0) { + log.info("send heart beat to broker[{} {} {}] success", brokerName, id, addr); + log.info(heartbeatData.toString()); + } + } catch (Exception e) { + if (this.isBrokerInNameServer(addr)) { + log.info("send heart beat to broker[{} {} {}] failed", brokerName, id, addr); + } else { + log.info("send heart beat to broker[{} {} {}] exception, because the broker not up, forget it", brokerName, + id, addr); + } } } }