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 2401418C7E for ; Wed, 14 Oct 2015 02:37:20 +0000 (UTC) Received: (qmail 67744 invoked by uid 500); 14 Oct 2015 02:37:20 -0000 Delivered-To: apmail-hbase-commits-archive@hbase.apache.org Received: (qmail 67702 invoked by uid 500); 14 Oct 2015 02:37:19 -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 67691 invoked by uid 99); 14 Oct 2015 02:37:19 -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; Wed, 14 Oct 2015 02:37:19 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B34E5E03A8; Wed, 14 Oct 2015 02:37:19 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: liushaohui@apache.org To: commits@hbase.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: hbase git commit: HBASE-14591 Region with reference hfile may split after a forced split in IncreasingToUpperBoundRegionSplitPolicy Date: Wed, 14 Oct 2015 02:37:19 +0000 (UTC) Repository: hbase Updated Branches: refs/heads/branch-1 1960cb94d -> 1a163b7ab HBASE-14591 Region with reference hfile may split after a forced split in IncreasingToUpperBoundRegionSplitPolicy Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/1a163b7a Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/1a163b7a Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/1a163b7a Branch: refs/heads/branch-1 Commit: 1a163b7ab71f7e1b5958102bb4e059e9e68be729 Parents: 1960cb9 Author: Liu Shaohui Authored: Wed Oct 14 10:14:50 2015 +0800 Committer: Liu Shaohui Committed: Wed Oct 14 10:36:32 2015 +0800 ---------------------------------------------------------------------- ...IncreasingToUpperBoundRegionSplitPolicy.java | 6 ++--- .../regionserver/TestRegionSplitPolicy.java | 28 ++++++++++++++++++++ 2 files changed, 30 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/1a163b7a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/IncreasingToUpperBoundRegionSplitPolicy.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/IncreasingToUpperBoundRegionSplitPolicy.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/IncreasingToUpperBoundRegionSplitPolicy.java index 8c31f0a..7144cb8 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/IncreasingToUpperBoundRegionSplitPolicy.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/IncreasingToUpperBoundRegionSplitPolicy.java @@ -67,9 +67,7 @@ public class IncreasingToUpperBoundRegionSplitPolicy extends ConstantSizeRegionS @Override protected boolean shouldSplit() { - if (region.shouldForceSplit()) { - return true; - } + boolean force = region.shouldForceSplit(); boolean foundABigStore = false; // Get count of regions that have the same common table as this.region int tableRegionsCount = getCountOfCommonTableRegions(); @@ -93,7 +91,7 @@ public class IncreasingToUpperBoundRegionSplitPolicy extends ConstantSizeRegionS } } - return foundABigStore; + return foundABigStore | force; } /** http://git-wip-us.apache.org/repos/asf/hbase/blob/1a163b7a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionSplitPolicy.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionSplitPolicy.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionSplitPolicy.java index 3b29a46..1168a3e 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionSplitPolicy.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionSplitPolicy.java @@ -61,6 +61,34 @@ public class TestRegionSplitPolicy { } @Test + public void testForceSplitRegionWithReference() throws IOException { + htd.setMaxFileSize(1024L); + // Add a store above the requisite size. Should split. + HStore mockStore = Mockito.mock(HStore.class); + Mockito.doReturn(2000L).when(mockStore).getSize(); + // Act as if there's a reference file or some other reason it can't split. + // This should prevent splitting even though it's big enough. + Mockito.doReturn(false).when(mockStore).canSplit(); + stores.add(mockStore); + + conf.set(HConstants.HBASE_REGION_SPLIT_POLICY_KEY, + ConstantSizeRegionSplitPolicy.class.getName()); + ConstantSizeRegionSplitPolicy policy = + (ConstantSizeRegionSplitPolicy)RegionSplitPolicy.create(mockRegion, conf); + assertFalse(policy.shouldSplit()); + Mockito.doReturn(true).when(mockRegion).shouldForceSplit(); + assertFalse(policy.shouldSplit()); + + Mockito.doReturn(false).when(mockRegion).shouldForceSplit(); + conf.set(HConstants.HBASE_REGION_SPLIT_POLICY_KEY, + IncreasingToUpperBoundRegionSplitPolicy.class.getName()); + policy = (IncreasingToUpperBoundRegionSplitPolicy) RegionSplitPolicy.create(mockRegion, conf); + assertFalse(policy.shouldSplit()); + Mockito.doReturn(true).when(mockRegion).shouldForceSplit(); + assertFalse(policy.shouldSplit()); + } + + @Test public void testIncreasingToUpperBoundRegionSplitPolicy() throws IOException { // Configure IncreasingToUpperBoundRegionSplitPolicy as our split policy conf.set(HConstants.HBASE_REGION_SPLIT_POLICY_KEY,