@@ -60,13 +60,23 @@ public class TestCatalogJanitorCluster {
6060 private static final TableName T1 = TableName .valueOf ("t1" );
6161 private static final TableName T2 = TableName .valueOf ("t2" );
6262 private static final TableName T3 = TableName .valueOf ("t3" );
63+ private static final TableName T4 = TableName .valueOf ("t4" );
6364
6465 @ Before
6566 public void before () throws Exception {
6667 TEST_UTIL .startMiniCluster ();
6768 TEST_UTIL .createMultiRegionTable (T1 , new byte [][] {HConstants .CATALOG_FAMILY });
6869 TEST_UTIL .createMultiRegionTable (T2 , new byte [][] {HConstants .CATALOG_FAMILY });
6970 TEST_UTIL .createMultiRegionTable (T3 , new byte [][] {HConstants .CATALOG_FAMILY });
71+
72+ final byte [][] keys = {
73+ Bytes .toBytes ("aa" ),
74+ Bytes .toBytes ("bb" ),
75+ Bytes .toBytes ("cc" ),
76+ Bytes .toBytes ("dd" )
77+ };
78+
79+ TEST_UTIL .createTable (T4 , HConstants .CATALOG_FAMILY , keys );
7080 }
7181
7282 @ After
@@ -141,7 +151,7 @@ public void testConsistency() throws IOException {
141151 emptyInfoServerPut .addColumn (MetaTableAccessor .getCatalogFamily (),
142152 MetaTableAccessor .getServerColumn (0 ), Bytes .toBytes ("" ));
143153 MetaTableAccessor .putsToMetaTable (TEST_UTIL .getConnection (), Arrays .asList (emptyInfoServerPut ));
144- gc = janitor .scan ();
154+ janitor .scan ();
145155 report = janitor .getLastReport ();
146156 assertEquals (0 , report .getUnknownServers ().size ());
147157 // Mke an empty regioninfo in t1.
@@ -150,9 +160,32 @@ public void testConsistency() throws IOException {
150160 pEmptyRI .addColumn (MetaTableAccessor .getCatalogFamily (),
151161 MetaTableAccessor .getRegionInfoColumn (), HConstants .EMPTY_BYTE_ARRAY );
152162 MetaTableAccessor .putsToMetaTable (TEST_UTIL .getConnection (), Arrays .asList (pEmptyRI ));
153- gc = janitor .scan ();
163+ janitor .scan ();
154164 report = janitor .getLastReport ();
155165 assertEquals (1 , report .getEmptyRegionInfo ().size ());
166+
167+ int holesReported = report .getHoles ().size ();
168+ int overlapsReported = report .getOverlaps ().size ();
169+
170+ // Test the case for
171+ // r1: [aa, bb), r2: [cc, dd), r3: [a, cc)
172+ // Make sure only overlaps and no holes are reported.
173+ List <RegionInfo > t4Ris = MetaTableAccessor .getTableRegions (TEST_UTIL .getConnection (), T4 );
174+ // delete the region [bb, cc)
175+ MetaTableAccessor .deleteRegionInfo (TEST_UTIL .getConnection (), t4Ris .get (2 ));
176+
177+ // add a new region [a, cc)
178+ RegionInfo newRiT4 = RegionInfoBuilder .newBuilder (T4 ).
179+ setStartKey ("a" .getBytes ()).
180+ setEndKey ("cc" .getBytes ()).build ();
181+ Put putForT4 = MetaTableAccessor .makePutFromRegionInfo (newRiT4 , System .currentTimeMillis ());
182+ MetaTableAccessor .putsToMetaTable (TEST_UTIL .getConnection (), Arrays .asList (putForT4 ));
183+
184+ janitor .scan ();
185+ report = janitor .getLastReport ();
186+ // there is no new hole reported, 2 more overLaps added.
187+ assertEquals (holesReported , report .getHoles ().size ());
188+ assertEquals (overlapsReported + 2 , report .getOverlaps ().size ());
156189 }
157190
158191 /**
0 commit comments