HBASE-23575 Remove dead code in AsyncRegistry (#929)
Removes a bunch of dead code and fixes some checkstyle nits. Signed-off-by: Viraj Jasani <virajjasani007@gmail.com> Signed-off-by: Sean Busbey <busbey@apache.org>
This commit is contained in:
parent
2d76457577
commit
efa4fe901a
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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() {
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
@ -39,21 +39,11 @@ public class DummyAsyncRegistry implements AsyncRegistry {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Integer> getCurrentNrHRS() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<ServerName> getMasterAddress() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Integer> getMasterInfoPort() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue