HBASE-23575 Remove dead code in AsyncRegistry (#940)

Removes a bunch of dead code and fixes some checkstyle nits.

(cherry picked from commit efa4fe901a)
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>
This commit is contained in:
Bharath Vissapragada 2019-12-11 17:44:56 -08:00 committed by Sean Busbey
parent dcd02d1236
commit a3fcc8badb
11 changed files with 21 additions and 80 deletions

View File

@ -1,4 +1,4 @@
/**
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@ -19,15 +19,12 @@ package org.apache.hadoop.hbase.client;
import java.io.Closeable;
import java.util.concurrent.CompletableFuture;
import org.apache.hadoop.hbase.RegionLocations;
import org.apache.hadoop.hbase.ServerName;
import org.apache.yetus.audience.InterfaceAudience;
/**
* Implementations hold cluster information such as this cluster's id, location of hbase:meta, etc..
* All stuffs that may be related to zookeeper at client side are placed here.
* <p>
* Internal use only.
*/
@InterfaceAudience.Private
@ -45,21 +42,11 @@ interface AsyncRegistry extends Closeable {
*/
CompletableFuture<String> getClusterId();
/**
* Get the number of 'running' regionservers.
*/
CompletableFuture<Integer> getCurrentNrHRS();
/**
* Get the address of HMaster.
*/
CompletableFuture<ServerName> getMasterAddress();
/**
* Get the info port of HMaster.
*/
CompletableFuture<Integer> getMasterInfoPort();
/**
* Closes this instance and releases any system resources associated with it
*/

View File

@ -323,10 +323,4 @@ public interface ClusterConnection extends Connection {
* supports cell blocks.
*/
boolean hasCellBlockSupport();
/**
* @return the number of region servers that are currently running
* @throws IOException if a remote or network exception occurs
*/
int getCurrentNrHRS() throws IOException;
}

View File

@ -2011,11 +2011,6 @@ class ConnectionImplementation implements ClusterConnection, Closeable {
return this.aborted;
}
@Override
public int getCurrentNrHRS() throws IOException {
return get(this.registry.getCurrentNrHRS());
}
@Override
public void close() {
if (this.closed) {

View File

@ -1,4 +1,4 @@
/**
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@ -24,7 +24,6 @@ import static org.apache.hadoop.hbase.client.RegionReplicaUtil.getRegionInfoForR
import static org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil.lengthOfPBMagic;
import static org.apache.hadoop.hbase.util.FutureUtils.addListener;
import static org.apache.hadoop.hbase.zookeeper.ZKMetadata.removeMetaData;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.CompletableFuture;
@ -43,14 +42,12 @@ import org.apache.hadoop.hbase.zookeeper.ZNodePaths;
import org.apache.yetus.audience.InterfaceAudience;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.hbase.thirdparty.com.google.common.annotations.VisibleForTesting;
import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos;
import org.apache.hadoop.hbase.shaded.protobuf.generated.ZooKeeperProtos;
/**
* Fetch the registry data from zookeeper.
* Zookeeper based registry implementation.
*/
@InterfaceAudience.Private
class ZKAsyncRegistry implements AsyncRegistry {
@ -210,11 +207,6 @@ class ZKAsyncRegistry implements AsyncRegistry {
return future;
}
@Override
public CompletableFuture<Integer> getCurrentNrHRS() {
return zk.exists(znodePaths.rsZNode).thenApply(s -> s != null ? s.getNumChildren() : 0);
}
private static ZooKeeperProtos.Master getMasterProto(byte[] data) throws IOException {
if (data == null || data.length == 0) {
return null;
@ -237,12 +229,6 @@ class ZKAsyncRegistry implements AsyncRegistry {
});
}
@Override
public CompletableFuture<Integer> getMasterInfoPort() {
return getAndConvert(znodePaths.masterAddressZNode, ZKAsyncRegistry::getMasterProto)
.thenApply(proto -> proto != null ? proto.getInfoPort() : 0);
}
@Override
public void close() {
zk.close();

View File

@ -1,4 +1,4 @@
/**
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@ -18,7 +18,6 @@
package org.apache.hadoop.hbase.client;
import java.util.concurrent.CompletableFuture;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.RegionLocations;
import org.apache.hadoop.hbase.ServerName;
@ -43,21 +42,11 @@ class DoNothingAsyncRegistry implements AsyncRegistry {
return CompletableFuture.completedFuture(null);
}
@Override
public CompletableFuture<Integer> getCurrentNrHRS() {
return CompletableFuture.completedFuture(0);
}
@Override
public CompletableFuture<ServerName> getMasterAddress() {
return CompletableFuture.completedFuture(null);
}
@Override
public CompletableFuture<Integer> getMasterInfoPort() {
return CompletableFuture.completedFuture(0);
}
@Override
public void close() {
}

View File

@ -472,11 +472,6 @@ public class TestAsyncProcess {
public CompletableFuture<String> getClusterId() {
return CompletableFuture.completedFuture("testClusterId");
}
@Override
public CompletableFuture<Integer> getCurrentNrHRS() {
return CompletableFuture.completedFuture(1);
}
}
final AtomicInteger nbThreads = new AtomicInteger(0);

View File

@ -144,11 +144,6 @@ public class TestClientNoCluster extends Configured implements Tool {
public CompletableFuture<String> getClusterId() {
return CompletableFuture.completedFuture(HConstants.CLUSTER_ID_DEFAULT);
}
@Override
public CompletableFuture<Integer> getCurrentNrHRS() {
return CompletableFuture.completedFuture(1);
}
}
/**

View File

@ -787,6 +787,13 @@ public class MiniHBaseCluster extends HBaseCluster {
}
}
/**
* @return Number of live region servers in the cluster currently.
*/
public int getNumLiveRegionServers() {
return this.hbaseCluster.getLiveRegionServers().size();
}
/**
* @return List of region server threads. Does not return the master even though it is also
* a region server.

View File

@ -215,7 +215,7 @@ public class TestAdmin extends TestAdminBase {
assertTrue(Bytes.equals(hri.getStartKey(), splitKeys[8]));
assertTrue(hri.getEndKey() == null || hri.getEndKey().length == 0);
verifyRoundRobinDistribution(conn, l, expectedRegions);
verifyRoundRobinDistribution(l, expectedRegions);
}
// Now test using start/end with a number of regions
@ -272,7 +272,7 @@ public class TestAdmin extends TestAdminBase {
assertTrue(Bytes.equals(hri.getStartKey(), new byte[] { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9 }));
assertTrue(hri.getEndKey() == null || hri.getEndKey().length == 0);
verifyRoundRobinDistribution(conn, l, expectedRegions);
verifyRoundRobinDistribution(l, expectedRegions);
}
// Try once more with something that divides into something infinite
@ -293,7 +293,7 @@ public class TestAdmin extends TestAdminBase {
expectedRegions, regions.size());
System.err.println("Found " + regions.size() + " regions");
verifyRoundRobinDistribution(conn, l, expectedRegions);
verifyRoundRobinDistribution(l, expectedRegions);
}
// Try an invalid case where there are duplicate split keys
@ -342,9 +342,9 @@ public class TestAdmin extends TestAdminBase {
}
}
private void verifyRoundRobinDistribution(ClusterConnection c, RegionLocator regionLocator,
int expectedRegions) throws IOException {
int numRS = c.getCurrentNrHRS();
private void verifyRoundRobinDistribution(RegionLocator regionLocator, int expectedRegions)
throws IOException {
int numRS = TEST_UTIL.getMiniHBaseCluster().getNumLiveRegionServers();
List<HRegionLocation> regions = regionLocator.getAllRegionLocations();
Map<ServerName, List<RegionInfo>> server2Regions = new HashMap<>();
for (HRegionLocation loc : regions) {

View File

@ -22,8 +22,6 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@ -52,7 +50,7 @@ import org.junit.runners.Parameterized;
/**
* Class to test asynchronous table admin operations.
* @see TestAsyncTableAdminApi2 This test and it used to be joined it was taking longer than our
* ten minute timeout so they were split.
* ten minute timeout so they were split.
* @see TestAsyncTableAdminApi3 Another split out from this class so each runs under ten minutes.
*/
@RunWith(Parameterized.class)
@ -268,9 +266,8 @@ public class TestAsyncTableAdminApi extends TestAsyncAdminBase {
}
}
private void verifyRoundRobinDistribution(List<HRegionLocation> regions, int expectedRegions)
throws IOException {
int numRS = ((ClusterConnection) TEST_UTIL.getConnection()).getCurrentNrHRS();
private void verifyRoundRobinDistribution(List<HRegionLocation> regions, int expectedRegions) {
int numRS = TEST_UTIL.getMiniHBaseCluster().getNumLiveRegionServers();
Map<ServerName, List<RegionInfo>> server2Regions = new HashMap<>();
regions.stream().forEach((loc) -> {

View File

@ -1,4 +1,4 @@
/**
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@ -25,7 +25,6 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.stream.IntStream;
@ -84,11 +83,8 @@ public class TestZKAsyncRegistry {
String expectedClusterId = TEST_UTIL.getHBaseCluster().getMaster().getClusterId();
assertEquals("Expected " + expectedClusterId + ", found=" + clusterId, expectedClusterId,
clusterId);
assertEquals(TEST_UTIL.getHBaseCluster().getClusterMetrics().getLiveServerMetrics().size(),
REGISTRY.getCurrentNrHRS().get().intValue());
assertEquals(TEST_UTIL.getHBaseCluster().getMaster().getServerName(),
REGISTRY.getMasterAddress().get());
assertEquals(-1, REGISTRY.getMasterInfoPort().get().intValue());
RegionReplicaTestHelper
.waitUntilAllMetaReplicasHavingRegionLocation(TEST_UTIL.getConfiguration(), REGISTRY, 3);
RegionLocations locs = REGISTRY.getMetaRegionLocation().get();