Skip to content

Commit 28ad0f8

Browse files
committed
resolve spotless problems
1 parent 00e248c commit 28ad0f8

File tree

4 files changed

+31
-37
lines changed

4 files changed

+31
-37
lines changed

hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncNonMetaRegionLocator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,8 +576,8 @@ private HRegionLocation getCachedLocation(HRegionLocation loc) {
576576
void updateCachedLocationOnError(HRegionLocation loc, Throwable exception) {
577577
Optional<MetricsConnection> connectionMetrics = conn.getConnectionMetrics();
578578
AsyncRegionLocatorHelper.updateCachedLocationOnError(loc, exception, this::getCachedLocation,
579-
this::addLocationToCache, this::removeLocationFromCache,
580-
this::removeServerLocationFromCache, connectionMetrics.orElse(null));
579+
this::addLocationToCache, this::removeLocationFromCache, this::removeServerLocationFromCache,
580+
connectionMetrics.orElse(null));
581581
}
582582

583583
void clearCache(TableName tableName) {

hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRegionLocatorHelper.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,11 @@ static void updateCachedLocationOnError(HRegionLocation loc, Throwable exception
8686
LOG.debug("Try updating {} with the new location {} constructed by {}", loc, newLoc,
8787
rme.toString());
8888
addToCache.accept(newLoc);
89-
} if ((cause instanceof CallTimeoutException || cause instanceof ConnectException)
90-
&& removeServerFromCache != null) {
89+
}
90+
if (
91+
(cause instanceof CallTimeoutException || cause instanceof ConnectException)
92+
&& removeServerFromCache != null
93+
) {
9194
// Clear all meta caches of the server on which hardware failure related exceptions occurred
9295
//
9396
// Those exceptions might be caused by a network or hardware issue of that server.

hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncNonMetaRegionLocator.java

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@
6767
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
6868
import org.apache.hadoop.hbase.util.Pair;
6969
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;
7270
import org.junit.After;
7371
import org.junit.AfterClass;
7472
import org.junit.Before;
@@ -80,6 +78,8 @@
8078
import org.junit.runners.Parameterized;
8179
import org.junit.runners.Parameterized.Parameter;
8280

81+
import org.apache.hbase.thirdparty.com.google.common.collect.ImmutableList;
82+
import org.apache.hbase.thirdparty.com.google.common.collect.ImmutableMap;
8383
import org.apache.hbase.thirdparty.com.google.common.collect.Lists;
8484
import org.apache.hbase.thirdparty.com.google.common.io.Closeables;
8585

@@ -562,15 +562,13 @@ public void testRemoveCachedLocationForServerOnError() throws Exception {
562562
createMultiRegionTable();
563563
TableName tableName2 = TableName.valueOf("async2");
564564

565-
try(Table ignored = TEST_UTIL.createTable(tableName2, FAMILY, SPLIT_KEYS)) {
565+
try (Table ignored = TEST_UTIL.createTable(tableName2, FAMILY, SPLIT_KEYS)) {
566566
TEST_UTIL.waitTableAvailable(tableName2);
567567

568568
List<RegionInfo> allRegions1 = TEST_UTIL.getAdmin().getRegions(TABLE_NAME);
569569
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));
574572

575573
// cache all locations
576574
for (Map.Entry<TableName, List<RegionInfo>> entry : tableToRegions.entrySet()) {
@@ -596,8 +594,8 @@ public void testRemoveCachedLocationForServerOnError() throws Exception {
596594
int cacheRemainedCount = 0;
597595
for (Map.Entry<TableName, List<RegionInfo>> entry : tableToRegions.entrySet()) {
598596
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());
601599
if (locs == null) {
602600
cacheRemovedCount++;
603601
continue;
@@ -608,8 +606,7 @@ public void testRemoveCachedLocationForServerOnError() throws Exception {
608606
cacheRemainedCount++;
609607
}
610608
}
611-
assertEquals(allRegions1.size() + allRegions2.size(),
612-
cacheRemovedCount + cacheRemainedCount);
609+
assertEquals(allRegions1.size() + allRegions2.size(), cacheRemovedCount + cacheRemainedCount);
613610
} finally {
614611
TEST_UTIL.deleteTableIfAny(tableName2);
615612
}
@@ -622,20 +619,18 @@ public void testCallRemoveServerLocationFromCache()
622619
AsyncNonMetaRegionLocator locator = spy(new AsyncNonMetaRegionLocator(conn));
623620

624621
// 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)));
630626

631627
for (Pair<Exception, Integer> pair : expectations) {
632628
Exception exception = pair.getFirst();
633629
Integer expectedCallTimes = pair.getSecond();
634630

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();
639634

640635
locator.updateCachedLocationOnError(loc, exception);
641636
verify(locator, times(expectedCallTimes)).removeServerLocationFromCache(any());

hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestConnectionImplementation.java

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@
8383
import org.apache.hadoop.hbase.util.Pair;
8484
import org.apache.hadoop.hbase.util.ReflectionUtils;
8585
import org.apache.hadoop.hbase.util.Threads;
86-
import org.apache.hbase.thirdparty.com.google.common.collect.ImmutableList;
87-
import org.apache.hbase.thirdparty.com.google.common.collect.ImmutableMap;
8886
import org.junit.After;
8987
import org.junit.AfterClass;
9088
import org.junit.Assert;
@@ -98,6 +96,8 @@
9896
import org.slf4j.Logger;
9997
import org.slf4j.LoggerFactory;
10098

99+
import org.apache.hbase.thirdparty.com.google.common.collect.ImmutableList;
100+
import org.apache.hbase.thirdparty.com.google.common.collect.ImmutableMap;
101101
import org.apache.hbase.thirdparty.com.google.common.collect.Lists;
102102
import org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder;
103103
import org.apache.hbase.thirdparty.io.netty.util.ResourceLeakDetector;
@@ -1240,10 +1240,8 @@ public void testRemoveCachedLocationForServerOnError() throws IOException {
12401240
List<HRegionLocation> allRegions1 = table1.getRegionLocator().getAllRegionLocations();
12411241
List<HRegionLocation> allRegions2 = table2.getRegionLocator().getAllRegionLocations();
12421242

1243-
Map<TableName, List<HRegionLocation>> tableToRegions = new HashMap<>(ImmutableMap.of(
1244-
TABLE_NAME1, allRegions1,
1245-
TABLE_NAME2, allRegions2
1246-
));
1243+
Map<TableName, List<HRegionLocation>> tableToRegions =
1244+
new HashMap<>(ImmutableMap.of(TABLE_NAME1, allRegions1, TABLE_NAME2, allRegions2));
12471245

12481246
// verify that all regions are cached
12491247
ConnectionImplementation conn = (ConnectionImplementation) TEST_UTIL.getConnection();
@@ -1276,8 +1274,7 @@ public void testRemoveCachedLocationForServerOnError() throws IOException {
12761274
cacheRemainedCount++;
12771275
}
12781276
}
1279-
assertEquals(allRegions1.size() + allRegions2.size(),
1280-
cacheRemovedCount + cacheRemainedCount);
1277+
assertEquals(allRegions1.size() + allRegions2.size(), cacheRemovedCount + cacheRemainedCount);
12811278
} finally {
12821279
TEST_UTIL.deleteTableIfAny(TABLE_NAME1);
12831280
TEST_UTIL.deleteTableIfAny(TABLE_NAME2);
@@ -1290,11 +1287,10 @@ public void testCallRemoveCachedLocationForServerOnError() throws IOException {
12901287
ConnectionImplementation conn = spy((ConnectionImplementation) TEST_UTIL.getConnection());
12911288

12921289
// expectations: exception -> expected accumulated call times
1293-
List<Pair<Exception, Integer>> expectations = new ArrayList<>(ImmutableList.of(
1294-
Pair.newPair(new CallTimeoutException("test1"), 1),
1295-
Pair.newPair(new ConnectException("test2"), 2),
1296-
Pair.newPair(new NotServingRegionException("test3"), 2)
1297-
));
1290+
List<Pair<Exception, Integer>> expectations =
1291+
new ArrayList<>(ImmutableList.of(Pair.newPair(new CallTimeoutException("test1"), 1),
1292+
Pair.newPair(new ConnectException("test2"), 2),
1293+
Pair.newPair(new NotServingRegionException("test3"), 2)));
12981294

12991295
for (Pair<Exception, Integer> pair : expectations) {
13001296
Exception exception = pair.getFirst();

0 commit comments

Comments
 (0)