Skip to content

Commit f85506f

Browse files
bharathvGuanghao Zhang
authored andcommitted
HBASE-23575 Remove dead code in AsyncRegistry (apache#940)
Removes a bunch of dead code and fixes some checkstyle nits. (cherry picked from commit efa4fe9) 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 b3c5740 commit f85506f

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
@@ -323,10 +323,4 @@ HRegionLocation getRegionLocation(TableName tableName, byte[] row, boolean reloa
323323
* supports cell blocks.
324324
*/
325325
boolean hasCellBlockSupport();
326-
327-
/**
328-
* @return the number of region servers that are currently running
329-
* @throws IOException if a remote or network exception occurs
330-
*/
331-
int getCurrentNrHRS() throws IOException;
332326
}

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
@@ -2077,11 +2077,6 @@ public boolean isAborted(){
20772077
return this.aborted;
20782078
}
20792079

2080-
@Override
2081-
public int getCurrentNrHRS() throws IOException {
2082-
return get(this.registry.getCurrentNrHRS());
2083-
}
2084-
20852080
@Override
20862081
public void close() {
20872082
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 com.xiaomi.infra.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 {
@@ -212,11 +209,6 @@ public CompletableFuture<RegionLocations> getMetaRegionLocation() {
212209
return future;
213210
}
214211

215-
@Override
216-
public CompletableFuture<Integer> getCurrentNrHRS() {
217-
return zk.exists(znodePaths.rsZNode).thenApply(s -> s != null ? s.getNumChildren() : 0);
218-
}
219-
220212
private static ZooKeeperProtos.Master getMasterProto(byte[] data) throws IOException {
221213
if (data == null || data.length == 0) {
222214
return null;
@@ -239,12 +231,6 @@ public CompletableFuture<ServerName> getMasterAddress() {
239231
});
240232
}
241233

242-
@Override
243-
public CompletableFuture<Integer> getMasterInfoPort() {
244-
return getAndConvert(znodePaths.masterAddressZNode, ZKAsyncRegistry::getMasterProto)
245-
.thenApply(proto -> proto != null ? proto.getInfoPort() : 0);
246-
}
247-
248234
@Override
249235
public void close() {
250236
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
@@ -787,6 +787,13 @@ public void compact(TableName tableName, boolean major) throws IOException {
787787
}
788788
}
789789

790+
/**
791+
* @return Number of live region servers in the cluster currently.
792+
*/
793+
public int getNumLiveRegionServers() {
794+
return this.hbaseCluster.getLiveRegionServers().size();
795+
}
796+
790797
/**
791798
* @return List of region server threads. Does not return the master even though it is also
792799
* a region server.

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ public void testCreateTableWithRegions() throws IOException, InterruptedExceptio
215215
assertTrue(Bytes.equals(hri.getStartKey(), splitKeys[8]));
216216
assertTrue(hri.getEndKey() == null || hri.getEndKey().length == 0);
217217

218-
verifyRoundRobinDistribution(conn, l, expectedRegions);
218+
verifyRoundRobinDistribution(l, expectedRegions);
219219
}
220220

221221
// Now test using start/end with a number of regions
@@ -272,7 +272,7 @@ public void testCreateTableWithRegions() throws IOException, InterruptedExceptio
272272
assertTrue(Bytes.equals(hri.getStartKey(), new byte[] { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9 }));
273273
assertTrue(hri.getEndKey() == null || hri.getEndKey().length == 0);
274274

275-
verifyRoundRobinDistribution(conn, l, expectedRegions);
275+
verifyRoundRobinDistribution(l, expectedRegions);
276276
}
277277

278278
// Try once more with something that divides into something infinite
@@ -293,7 +293,7 @@ public void testCreateTableWithRegions() throws IOException, InterruptedExceptio
293293
expectedRegions, regions.size());
294294
System.err.println("Found " + regions.size() + " regions");
295295

296-
verifyRoundRobinDistribution(conn, l, expectedRegions);
296+
verifyRoundRobinDistribution(l, expectedRegions);
297297
}
298298

299299
// Try an invalid case where there are duplicate split keys
@@ -342,9 +342,9 @@ public void testCreateTableWithEmptyRowInTheSplitKeys() throws IOException {
342342
}
343343
}
344344

345-
private void verifyRoundRobinDistribution(ClusterConnection c, RegionLocator regionLocator,
346-
int expectedRegions) throws IOException {
347-
int numRS = c.getCurrentNrHRS();
345+
private void verifyRoundRobinDistribution(RegionLocator regionLocator, int expectedRegions)
346+
throws IOException {
347+
int numRS = TEST_UTIL.getMiniHBaseCluster().getNumLiveRegionServers();
348348
List<HRegionLocation> regions = regionLocator.getAllRegionLocations();
349349
Map<ServerName, List<RegionInfo>> server2Regions = new HashMap<>();
350350
for (HRegionLocation loc : regions) {

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)