67
67
import org .apache .hadoop .hbase .util .EnvironmentEdgeManager ;
68
68
import org .apache .hadoop .hbase .util .Pair ;
69
69
import org .apache .hadoop .hbase .util .ServerRegionReplicaUtil ;
70
- import org .apache .hbase .thirdparty .com .google .common .collect .ImmutableList ;
71
- import org .apache .hbase .thirdparty .com .google .common .collect .ImmutableMap ;
72
70
import org .junit .After ;
73
71
import org .junit .AfterClass ;
74
72
import org .junit .Before ;
80
78
import org .junit .runners .Parameterized ;
81
79
import org .junit .runners .Parameterized .Parameter ;
82
80
81
+ import org .apache .hbase .thirdparty .com .google .common .collect .ImmutableList ;
82
+ import org .apache .hbase .thirdparty .com .google .common .collect .ImmutableMap ;
83
83
import org .apache .hbase .thirdparty .com .google .common .collect .Lists ;
84
84
import org .apache .hbase .thirdparty .com .google .common .io .Closeables ;
85
85
@@ -562,15 +562,13 @@ public void testRemoveCachedLocationForServerOnError() throws Exception {
562
562
createMultiRegionTable ();
563
563
TableName tableName2 = TableName .valueOf ("async2" );
564
564
565
- try (Table ignored = TEST_UTIL .createTable (tableName2 , FAMILY , SPLIT_KEYS )) {
565
+ try (Table ignored = TEST_UTIL .createTable (tableName2 , FAMILY , SPLIT_KEYS )) {
566
566
TEST_UTIL .waitTableAvailable (tableName2 );
567
567
568
568
List <RegionInfo > allRegions1 = TEST_UTIL .getAdmin ().getRegions (TABLE_NAME );
569
569
List <RegionInfo > allRegions2 = TEST_UTIL .getAdmin ().getRegions (tableName2 );
570
- Map <TableName , List <RegionInfo >> tableToRegions = new HashMap <>(ImmutableMap .of (
571
- TABLE_NAME , allRegions1 ,
572
- tableName2 , allRegions2
573
- ));
570
+ Map <TableName , List <RegionInfo >> tableToRegions =
571
+ new HashMap <>(ImmutableMap .of (TABLE_NAME , allRegions1 , tableName2 , allRegions2 ));
574
572
575
573
// cache all locations
576
574
for (Map .Entry <TableName , List <RegionInfo >> entry : tableToRegions .entrySet ()) {
@@ -596,8 +594,8 @@ public void testRemoveCachedLocationForServerOnError() throws Exception {
596
594
int cacheRemainedCount = 0 ;
597
595
for (Map .Entry <TableName , List <RegionInfo >> entry : tableToRegions .entrySet ()) {
598
596
for (RegionInfo region : entry .getValue ()) {
599
- RegionLocations locs = locator . getRegionLocationInCache ( entry . getKey (),
600
- region .getStartKey ());
597
+ RegionLocations locs =
598
+ locator . getRegionLocationInCache ( entry . getKey (), region .getStartKey ());
601
599
if (locs == null ) {
602
600
cacheRemovedCount ++;
603
601
continue ;
@@ -608,8 +606,7 @@ public void testRemoveCachedLocationForServerOnError() throws Exception {
608
606
cacheRemainedCount ++;
609
607
}
610
608
}
611
- assertEquals (allRegions1 .size () + allRegions2 .size (),
612
- cacheRemovedCount + cacheRemainedCount );
609
+ assertEquals (allRegions1 .size () + allRegions2 .size (), cacheRemovedCount + cacheRemainedCount );
613
610
} finally {
614
611
TEST_UTIL .deleteTableIfAny (tableName2 );
615
612
}
@@ -622,20 +619,18 @@ public void testCallRemoveServerLocationFromCache()
622
619
AsyncNonMetaRegionLocator locator = spy (new AsyncNonMetaRegionLocator (conn ));
623
620
624
621
// expectations: exception -> expected accumulated call times
625
- List <Pair <Exception , Integer >> expectations = new ArrayList <>(ImmutableList .of (
626
- Pair .newPair (new CallTimeoutException ("test1" ), 1 ),
627
- Pair .newPair (new ConnectException ("test2" ), 2 ),
628
- Pair .newPair (new NotServingRegionException ("test3" ), 2 )
629
- ));
622
+ List <Pair <Exception , Integer >> expectations =
623
+ new ArrayList <>(ImmutableList .of (Pair .newPair (new CallTimeoutException ("test1" ), 1 ),
624
+ Pair .newPair (new ConnectException ("test2" ), 2 ),
625
+ Pair .newPair (new NotServingRegionException ("test3" ), 2 )));
630
626
631
627
for (Pair <Exception , Integer > pair : expectations ) {
632
628
Exception exception = pair .getFirst ();
633
629
Integer expectedCallTimes = pair .getSecond ();
634
630
635
- HRegionLocation loc =
636
- locator .getRegionLocations (TABLE_NAME , EMPTY_START_ROW ,
637
- RegionReplicaUtil .DEFAULT_REPLICA_ID ,
638
- RegionLocateType .CURRENT , false ).get ().getDefaultRegionLocation ();
631
+ HRegionLocation loc = locator .getRegionLocations (TABLE_NAME , EMPTY_START_ROW ,
632
+ RegionReplicaUtil .DEFAULT_REPLICA_ID , RegionLocateType .CURRENT , false ).get ()
633
+ .getDefaultRegionLocation ();
639
634
640
635
locator .updateCachedLocationOnError (loc , exception );
641
636
verify (locator , times (expectedCallTimes )).removeServerLocationFromCache (any ());
0 commit comments