HBASE-14591 Region with reference hfile may split after a forced split in IncreasingToUpperBoundRegionSplitPolicy
This commit is contained in:
parent
4754e583f9
commit
0e41dc18c0
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -61,6 +61,34 @@ public class TestRegionSplitPolicy {
|
|||
Mockito.doReturn(stores).when(mockRegion).getStores();
|
||||
}
|
||||
|
||||
@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
|
||||
|
|
Loading…
Reference in New Issue