HBASE-11627 guard against divide by zero in RegionSplitter logging.

Adds a test for noop rolling splits that fails prior to the addition
of the guard.

Signed-off-by: Andrew Purtell <apurtell@apache.org>
This commit is contained in:
Sean Busbey 2014-08-14 17:51:06 -07:00 committed by Andrew Purtell
parent 9936b86f70
commit e9fd2d5cae
2 changed files with 11 additions and 2 deletions

View File

@ -584,8 +584,10 @@ public class RegionSplitter {
LOG.debug("TOTAL TIME = "
+ org.apache.hadoop.util.StringUtils.formatTime(tDiff));
LOG.debug("Splits = " + splitCount);
if (0 < splitCount) {
LOG.debug("Avg Time / Split = "
+ org.apache.hadoop.util.StringUtils.formatTime(tDiff / splitCount));
}
splitOut.close();
if (table != null){

View File

@ -282,6 +282,13 @@ public class TestRegionSplitter {
verifyBounds(expectedBounds, tableName);
}
@Test
public void noopRollingSplit() throws Exception {
final List<byte[]> expectedBounds = new ArrayList<byte[]>();
expectedBounds.add(ArrayUtils.EMPTY_BYTE_ARRAY);
rollingSplitAndVerify(TestRegionSplitter.class.getSimpleName(), "UniformSplit", expectedBounds);
}
private void rollingSplitAndVerify(String tableName, String splitClass,
List<byte[]> expectedBounds) throws Exception {
final Configuration conf = UTIL.getConfiguration();