Skip to content

Commit 9aeeecd

Browse files
committed
HBASE-23305: Remove dead code in AsyncRegistry
This is a prep change for master based async registry impl. Removes a bunch of dead code and fixes some checkstyle nits.
1 parent d0f6883 commit 9aeeecd

5 files changed

Lines changed: 6 additions & 58 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/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-server/src/test/java/org/apache/hadoop/hbase/client/DummyAsyncRegistry.java

Lines changed: 1 addition & 11 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
@@ -39,21 +39,11 @@ public CompletableFuture<String> getClusterId() {
3939
return null;
4040
}
4141

42-
@Override
43-
public CompletableFuture<Integer> getCurrentNrHRS() {
44-
return null;
45-
}
46-
4742
@Override
4843
public CompletableFuture<ServerName> getMasterAddress() {
4944
return null;
5045
}
5146

52-
@Override
53-
public CompletableFuture<Integer> getMasterInfoPort() {
54-
return null;
55-
}
56-
5747
@Override
5848
public void close() {
5949
}

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

Lines changed: 1 addition & 5 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
@@ -25,7 +25,6 @@
2525
import static org.junit.Assert.assertNotSame;
2626
import static org.junit.Assert.assertThat;
2727
import static org.junit.Assert.fail;
28-
2928
import java.io.IOException;
3029
import java.util.concurrent.ExecutionException;
3130
import java.util.stream.IntStream;
@@ -84,11 +83,8 @@ public void test() throws InterruptedException, ExecutionException, IOException
8483
String expectedClusterId = TEST_UTIL.getHBaseCluster().getMaster().getClusterId();
8584
assertEquals("Expected " + expectedClusterId + ", found=" + clusterId, expectedClusterId,
8685
clusterId);
87-
assertEquals(TEST_UTIL.getHBaseCluster().getClusterMetrics().getLiveServerMetrics().size(),
88-
REGISTRY.getCurrentNrHRS().get().intValue());
8986
assertEquals(TEST_UTIL.getHBaseCluster().getMaster().getServerName(),
9087
REGISTRY.getMasterAddress().get());
91-
assertEquals(-1, REGISTRY.getMasterInfoPort().get().intValue());
9288
RegionReplicaTestHelper
9389
.waitUntilAllMetaReplicasHavingRegionLocation(TEST_UTIL.getConfiguration(), REGISTRY, 3);
9490
RegionLocations locs = REGISTRY.getMetaRegionLocation().get();

0 commit comments

Comments
 (0)