Skip to content

Commit 9686438

Browse files
bharathvbusbey
authored andcommitted
HBASE-23575 Remove dead code in AsyncRegistry (#940)
Removes a bunch of dead code and fixes some checkstyle nits. (cherry picked from commit efa4fe9) (cherry picked from commit a3fcc8b) (cherry picked from commit 60889cd) Signed-off-by: Jan Hentschel <janh@apache.org> Signed-off-by: Xu Cang <xucang@apache.org> Signed-off-by: Sean Busbey <busbey@apache.org> Signed-off-by: Viraj Jasani <virajjasani007@gmail.com>
1 parent 2d1ceb2 commit 9686438

11 files changed

Lines changed: 21 additions & 80 deletions

File tree

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

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* Licensed to the Apache Software Foundation (ASF) under one
33
* or more contributor license agreements. See the NOTICE file
44
* distributed with this work for additional information
@@ -19,15 +19,12 @@
1919

2020
import java.io.Closeable;
2121
import java.util.concurrent.CompletableFuture;
22-
2322
import org.apache.hadoop.hbase.RegionLocations;
2423
import org.apache.hadoop.hbase.ServerName;
2524
import org.apache.yetus.audience.InterfaceAudience;
2625

2726
/**
2827
* Implementations hold cluster information such as this cluster's id, location of hbase:meta, etc..
29-
* All stuffs that may be related to zookeeper at client side are placed here.
30-
* <p>
3128
* Internal use only.
3229
*/
3330
@InterfaceAudience.Private
@@ -45,21 +42,11 @@ interface AsyncRegistry extends Closeable {
4542
*/
4643
CompletableFuture<String> getClusterId();
4744

48-
/**
49-
* Get the number of 'running' regionservers.
50-
*/
51-
CompletableFuture<Integer> getCurrentNrHRS();
52-
5345
/**
5446
* Get the address of HMaster.
5547
*/
5648
CompletableFuture<ServerName> getMasterAddress();
5749

58-
/**
59-
* Get the info port of HMaster.
60-
*/
61-
CompletableFuture<Integer> getMasterInfoPort();
62-
6350
/**
6451
* Closes this instance and releases any system resources associated with it
6552
*/

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -321,12 +321,6 @@ HRegionLocation getRegionLocation(TableName tableName, byte[] row, boolean reloa
321321
*/
322322
boolean hasCellBlockSupport();
323323

324-
/**
325-
* @return the number of region servers that are currently running
326-
* @throws IOException if a remote or network exception occurs
327-
*/
328-
int getCurrentNrHRS() throws IOException;
329-
330324
/**
331325
* Retrieve an Hbck implementation to fix an HBase cluster.
332326
* The returned Hbck is not guaranteed to be thread-safe. A new instance should be created by

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1923,11 +1923,6 @@ public boolean isAborted(){
19231923
return this.aborted;
19241924
}
19251925

1926-
@Override
1927-
public int getCurrentNrHRS() throws IOException {
1928-
return get(this.registry.getCurrentNrHRS());
1929-
}
1930-
19311926
@Override
19321927
public void close() {
19331928
if (this.closed) {

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

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* Licensed to the Apache Software Foundation (ASF) under one
33
* or more contributor license agreements. See the NOTICE file
44
* distributed with this work for additional information
@@ -24,7 +24,6 @@
2424
import static org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil.lengthOfPBMagic;
2525
import static org.apache.hadoop.hbase.util.FutureUtils.addListener;
2626
import static org.apache.hadoop.hbase.zookeeper.ZKMetadata.removeMetaData;
27-
2827
import java.io.IOException;
2928
import java.util.List;
3029
import java.util.concurrent.CompletableFuture;
@@ -43,14 +42,12 @@
4342
import org.apache.yetus.audience.InterfaceAudience;
4443
import org.slf4j.Logger;
4544
import org.slf4j.LoggerFactory;
46-
4745
import org.apache.hbase.thirdparty.com.google.common.annotations.VisibleForTesting;
48-
4946
import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos;
5047
import org.apache.hadoop.hbase.shaded.protobuf.generated.ZooKeeperProtos;
5148

5249
/**
53-
* Fetch the registry data from zookeeper.
50+
* Zookeeper based registry implementation.
5451
*/
5552
@InterfaceAudience.Private
5653
class ZKAsyncRegistry implements AsyncRegistry {
@@ -210,11 +207,6 @@ public CompletableFuture<RegionLocations> getMetaRegionLocation() {
210207
return future;
211208
}
212209

213-
@Override
214-
public CompletableFuture<Integer> getCurrentNrHRS() {
215-
return zk.exists(znodePaths.rsZNode).thenApply(s -> s != null ? s.getNumChildren() : 0);
216-
}
217-
218210
private static ZooKeeperProtos.Master getMasterProto(byte[] data) throws IOException {
219211
if (data == null || data.length == 0) {
220212
return null;
@@ -237,12 +229,6 @@ public CompletableFuture<ServerName> getMasterAddress() {
237229
});
238230
}
239231

240-
@Override
241-
public CompletableFuture<Integer> getMasterInfoPort() {
242-
return getAndConvert(znodePaths.masterAddressZNode, ZKAsyncRegistry::getMasterProto)
243-
.thenApply(proto -> proto != null ? proto.getInfoPort() : 0);
244-
}
245-
246232
@Override
247233
public void close() {
248234
zk.close();

hbase-client/src/test/java/org/apache/hadoop/hbase/client/DoNothingAsyncRegistry.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* Licensed to the Apache Software Foundation (ASF) under one
33
* or more contributor license agreements. See the NOTICE file
44
* distributed with this work for additional information
@@ -18,7 +18,6 @@
1818
package org.apache.hadoop.hbase.client;
1919

2020
import java.util.concurrent.CompletableFuture;
21-
2221
import org.apache.hadoop.conf.Configuration;
2322
import org.apache.hadoop.hbase.RegionLocations;
2423
import org.apache.hadoop.hbase.ServerName;
@@ -43,21 +42,11 @@ public CompletableFuture<String> getClusterId() {
4342
return CompletableFuture.completedFuture(null);
4443
}
4544

46-
@Override
47-
public CompletableFuture<Integer> getCurrentNrHRS() {
48-
return CompletableFuture.completedFuture(0);
49-
}
50-
5145
@Override
5246
public CompletableFuture<ServerName> getMasterAddress() {
5347
return CompletableFuture.completedFuture(null);
5448
}
5549

56-
@Override
57-
public CompletableFuture<Integer> getMasterInfoPort() {
58-
return CompletableFuture.completedFuture(0);
59-
}
60-
6150
@Override
6251
public void close() {
6352
}

hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncProcess.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -472,11 +472,6 @@ public TestRegistry(Configuration conf) {
472472
public CompletableFuture<String> getClusterId() {
473473
return CompletableFuture.completedFuture("testClusterId");
474474
}
475-
476-
@Override
477-
public CompletableFuture<Integer> getCurrentNrHRS() {
478-
return CompletableFuture.completedFuture(1);
479-
}
480475
}
481476

482477
final AtomicInteger nbThreads = new AtomicInteger(0);

hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestClientNoCluster.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,6 @@ public CompletableFuture<RegionLocations> getMetaRegionLocation() {
144144
public CompletableFuture<String> getClusterId() {
145145
return CompletableFuture.completedFuture(HConstants.CLUSTER_ID_DEFAULT);
146146
}
147-
148-
@Override
149-
public CompletableFuture<Integer> getCurrentNrHRS() {
150-
return CompletableFuture.completedFuture(1);
151-
}
152147
}
153148

154149
/**

hbase-server/src/test/java/org/apache/hadoop/hbase/MiniHBaseCluster.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,13 @@ public void compact(TableName tableName, boolean major) throws IOException {
718718
}
719719
}
720720

721+
/**
722+
* @return Number of live region servers in the cluster currently.
723+
*/
724+
public int getNumLiveRegionServers() {
725+
return this.hbaseCluster.getLiveRegionServers().size();
726+
}
727+
721728
/**
722729
* @return List of region server threads. Does not return the master even though it is also
723730
* a region server.

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -632,9 +632,9 @@ public void testOnlineChangeTableSchema() throws IOException, InterruptedExcepti
632632
assertFalse(this.admin.tableExists(tableName));
633633
}
634634

635-
protected void verifyRoundRobinDistribution(ClusterConnection c, RegionLocator regionLocator, int
636-
expectedRegions) throws IOException {
637-
int numRS = c.getCurrentNrHRS();
635+
private void verifyRoundRobinDistribution(RegionLocator regionLocator, int expectedRegions)
636+
throws IOException {
637+
int numRS = TEST_UTIL.getMiniHBaseCluster().getNumLiveRegionServers();
638638
List<HRegionLocation> regions = regionLocator.getAllRegionLocations();
639639
Map<ServerName, List<RegionInfo>> server2Regions = new HashMap<>();
640640
for (HRegionLocation loc : regions) {
@@ -779,7 +779,7 @@ public void testCreateTableWithRegions() throws IOException, InterruptedExceptio
779779
assertTrue(Bytes.equals(hri.getStartKey(), splitKeys[8]));
780780
assertTrue(hri.getEndKey() == null || hri.getEndKey().length == 0);
781781

782-
verifyRoundRobinDistribution(conn, l, expectedRegions);
782+
verifyRoundRobinDistribution(l, expectedRegions);
783783
}
784784

785785

@@ -840,7 +840,7 @@ public void testCreateTableWithRegions() throws IOException, InterruptedExceptio
840840
assertTrue(Bytes.equals(hri.getStartKey(), new byte[] { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9 }));
841841
assertTrue(hri.getEndKey() == null || hri.getEndKey().length == 0);
842842

843-
verifyRoundRobinDistribution(conn, l, expectedRegions);
843+
verifyRoundRobinDistribution(l, expectedRegions);
844844
}
845845

846846
// Try once more with something that divides into something infinite
@@ -864,7 +864,7 @@ public void testCreateTableWithRegions() throws IOException, InterruptedExceptio
864864
"but only found " + regions.size(), expectedRegions, regions.size());
865865
System.err.println("Found " + regions.size() + " regions");
866866

867-
verifyRoundRobinDistribution(conn, l, expectedRegions);
867+
verifyRoundRobinDistribution(l, expectedRegions);
868868
}
869869

870870

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
import static org.junit.Assert.assertFalse;
2323
import static org.junit.Assert.assertTrue;
2424
import static org.junit.Assert.fail;
25-
26-
import java.io.IOException;
2725
import java.util.ArrayList;
2826
import java.util.HashMap;
2927
import java.util.Iterator;
@@ -52,7 +50,7 @@
5250
/**
5351
* Class to test asynchronous table admin operations.
5452
* @see TestAsyncTableAdminApi2 This test and it used to be joined it was taking longer than our
55-
* ten minute timeout so they were split.
53+
* ten minute timeout so they were split.
5654
* @see TestAsyncTableAdminApi3 Another split out from this class so each runs under ten minutes.
5755
*/
5856
@RunWith(Parameterized.class)
@@ -268,9 +266,8 @@ public void testCreateTableWithRegions() throws Exception {
268266
}
269267
}
270268

271-
private void verifyRoundRobinDistribution(List<HRegionLocation> regions, int expectedRegions)
272-
throws IOException {
273-
int numRS = ((ClusterConnection) TEST_UTIL.getConnection()).getCurrentNrHRS();
269+
private void verifyRoundRobinDistribution(List<HRegionLocation> regions, int expectedRegions) {
270+
int numRS = TEST_UTIL.getMiniHBaseCluster().getNumLiveRegionServers();
274271

275272
Map<ServerName, List<RegionInfo>> server2Regions = new HashMap<>();
276273
regions.stream().forEach((loc) -> {

0 commit comments

Comments
 (0)