Source:
public void testMergeRegions() throws Exception { final TableName tableName = TableName.valueOf(name.getMethodName()); TableDescriptor td = TableDescriptorBuilder.newBuilder(tableName) .setColumnFamily(ColumnFamilyDescriptorBuilder.of("d")).build(); byte[][] splitRows = new byte[2][]; splitRows[0] = new byte[] { (byte) '3' }; splitRows[1] = new byte[] { (byte) '6' }; try { TEST_UTIL.createTable(td, splitRows); TEST_UTIL.waitTableAvailable(tableName); List<RegionInfo> tableRegions; RegionInfo regionA; RegionInfo regionB; RegionInfo regionC; RegionInfo mergedChildRegion = null; tableRegions = ADMIN.getRegions(tableName); assertEquals(3, ADMIN.getRegions(tableName).size()); regionA = tableRegions.get(0); regionB = tableRegions.get(1); regionC = tableRegions.get(2); ADMIN.mergeRegionsAsync(regionA.getRegionName(), regionB.getRegionName(), false).get(60, TimeUnit.SECONDS); tableRegions = ADMIN.getRegions(tableName); assertEquals(2, tableRegions.size()); for (RegionInfo ri : tableRegions) { if (regionC.compareTo(ri) != 0) { mergedChildRegion = ri; break; } } assertTrue(mergedChildRegion != null); HMaster services = TEST_UTIL.getHBaseCluster().getMaster(); CatalogJanitor cj = services.getCatalogJanitor(); cj.cleanMergeQualifier(mergedChildRegion); while (!services.getMasterProcedureExecutor().getActiveProcIds().isEmpty()) { Thread.sleep(200); } ADMIN.mergeRegionsAsync(regionC.getEncodedNameAsBytes(), mergedChildRegion.getEncodedNameAsBytes(), false) .get(60, TimeUnit.SECONDS); assertEquals(1, ADMIN.getRegions(tableName).size()); } finally { ADMIN.disableTable(tableName); ADMIN.deleteTable(tableName); } }

Target:
public void testMergeRegions() throws Exception { final TableName tableName = TableName.valueOf(name.getMethodName()); TableDescriptor td = TableDescriptorBuilder.newBuilder(tableName) .setColumnFamily(ColumnFamilyDescriptorBuilder.of("d")).build(); byte[][] splitRows = new byte[2][]; splitRows[0] = new byte[] { (byte) '3' }; splitRows[1] = new byte[] { (byte) '6' }; try { TEST_UTIL.createTable(td, splitRows); TEST_UTIL.waitTableAvailable(tableName); List<RegionInfo> tableRegions; RegionInfo regionA; RegionInfo regionB; RegionInfo regionC; RegionInfo mergedChildRegion = null; tableRegions = ADMIN.getRegions(tableName); assertEquals(3, ADMIN.getRegions(tableName).size()); regionA = tableRegions.get(0); regionB = tableRegions.get(1); regionC = tableRegions.get(2); ADMIN.mergeRegionsAsync(regionA.getRegionName(), regionB.getRegionName(), false).get(60, TimeUnit.SECONDS); tableRegions = ADMIN.getRegions(tableName); assertEquals(2, tableRegions.size()); for (RegionInfo ri : tableRegions) { if (regionC.compareTo(ri) != 0) { mergedChildRegion = ri; break; } } assertNotNull(mergedChildRegion); HMaster services = TEST_UTIL.getHBaseCluster().getMaster(); CatalogJanitor cj = services.getCatalogJanitor(); cj.cleanMergeQualifier(mergedChildRegion); while (!services.getMasterProcedureExecutor().getActiveProcIds().isEmpty()) { Thread.sleep(200); } ADMIN.mergeRegionsAsync(regionC.getEncodedNameAsBytes(), mergedChildRegion.getEncodedNameAsBytes(), false) .get(60, TimeUnit.SECONDS); assertEquals(1, ADMIN.getRegions(tableName).size()); } finally { ADMIN.disableTable(tableName); ADMIN.deleteTable(tableName); } }