Return-Path: X-Original-To: apmail-hbase-commits-archive@www.apache.org Delivered-To: apmail-hbase-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B161919F5D for ; Mon, 21 Mar 2016 05:30:15 +0000 (UTC) Received: (qmail 88610 invoked by uid 500); 21 Mar 2016 05:30:15 -0000 Delivered-To: apmail-hbase-commits-archive@hbase.apache.org Received: (qmail 88567 invoked by uid 500); 21 Mar 2016 05:30:15 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 88558 invoked by uid 99); 21 Mar 2016 05:30:15 -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; Mon, 21 Mar 2016 05:30:15 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 2412DDFB7B; Mon, 21 Mar 2016 05:30:15 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: busbey@apache.org To: commits@hbase.apache.org Message-Id: <8a2f0b01e1b04301a483f09e58710d56@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: hbase git commit: HBASE-15478 add comments to syncRunnerIndex handling explaining constraints on possible values. Date: Mon, 21 Mar 2016 05:30:15 +0000 (UTC) Repository: hbase Updated Branches: refs/heads/branch-1 17815ded7 -> a3071327b HBASE-15478 add comments to syncRunnerIndex handling explaining constraints on possible values. Signed-off-by: zhangduo Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/a3071327 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/a3071327 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/a3071327 Branch: refs/heads/branch-1 Commit: a3071327b5c9d84b02a516bcaab84f8ad38b9440 Parents: 17815de Author: Sean Busbey Authored: Thu Mar 17 15:22:07 2016 -0500 Committer: Sean Busbey Committed: Mon Mar 21 00:29:52 2016 -0500 ---------------------------------------------------------------------- .../apache/hadoop/hbase/regionserver/wal/FSHLog.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/a3071327/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/FSHLog.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/FSHLog.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/FSHLog.java index e189a30..eb1cf57 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/FSHLog.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/FSHLog.java @@ -1771,10 +1771,19 @@ public class FSHLog implements WAL { // If not a batch, return to consume more events from the ring buffer before proceeding; // we want to get up a batch of syncs and appends before we go do a filesystem sync. if (!endOfBatch || this.syncFuturesCount <= 0) return; - // Below expects that the offer 'transfers' responsibility for the outstanding syncs to - // the syncRunner. We should never get an exception in here. + // syncRunnerIndex is bound to the range [0, Integer.MAX_INT - 1] as follows: + // * The maximum value possible for syncRunners.length is Integer.MAX_INT + // * syncRunnerIndex starts at 0 and is incremented only here + // * after the increment, the value is bounded by the '%' operator to [0, syncRunners.length), + // presuming the value was positive prior to the '%' operator. + // * after being bound to [0, Integer.MAX_INT - 1], the new value is stored in syncRunnerIndex + // ensuring that it can't grow without bound and overflow. + // * note that the value after the increment must be positive, because the most it could have + // been prior was Integer.MAX_INT - 1 and we only increment by 1. this.syncRunnerIndex = (this.syncRunnerIndex + 1) % this.syncRunners.length; try { + // Below expects that the offer 'transfers' responsibility for the outstanding syncs to + // the syncRunner. We should never get an exception in here. this.syncRunners[this.syncRunnerIndex].offer(sequence, this.syncFutures, this.syncFuturesCount); } catch (Exception e) {