Skip to content

Commit

Permalink
HBASE-22744 Removed deprecated status and load classes in client module
Browse files Browse the repository at this point in the history
Signed-off-by: stack <[email protected]>
  • Loading branch information
HorizonNet authored Aug 27, 2019
1 parent ec68bf3 commit 5106f28
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 1,784 deletions.
400 changes: 0 additions & 400 deletions hbase-client/src/main/java/org/apache/hadoop/hbase/ClusterStatus.java

This file was deleted.

421 changes: 0 additions & 421 deletions hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLoad.java

This file was deleted.

596 changes: 0 additions & 596 deletions hbase-client/src/main/java/org/apache/hadoop/hbase/ServerLoad.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@
import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetOnlineRegionResponse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetRegionInfoRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetRegionInfoResponse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetRegionLoadResponse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetServerInfoRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetServerInfoResponse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetStoreFileRequest;
Expand Down Expand Up @@ -1734,16 +1733,6 @@ public static org.apache.hadoop.hbase.client.RegionInfo getRegionInfo(final RpcC
}
}

public static List<org.apache.hadoop.hbase.RegionLoad> getRegionLoadInfo(
GetRegionLoadResponse regionLoadResponse) {
List<org.apache.hadoop.hbase.RegionLoad> regionLoadList =
new ArrayList<>(regionLoadResponse.getRegionLoadsCount());
for (RegionLoad regionLoad : regionLoadResponse.getRegionLoadsList()) {
regionLoadList.add(new org.apache.hadoop.hbase.RegionLoad(regionLoad));
}
return regionLoadList;
}

/**
* A helper to close a region given a region name
* using admin protocol.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public static void setUpBeforeClass() throws Exception {
TEST_UTIL.waitFor(6000, new Waiter.Predicate<IOException>() {
@Override
public boolean evaluate() throws IOException {
return TEST_UTIL.getMiniHBaseCluster().getClusterStatus().getAverageLoad() > 0;
return TEST_UTIL.getMiniHBaseCluster().getClusterMetrics().getAverageLoad() > 0;
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public MiniHBaseCluster(Configuration conf, int numMasters, int numRegionServers
CompatibilityFactory.getInstance(MetricsAssertHelper.class).init();

init(numMasters, numRegionServers, rsPorts, masterClass, regionserverClass);
this.initialClusterStatus = getClusterStatus();
this.initialClusterStatus = getClusterMetrics();
}

public Configuration getConfiguration() {
Expand Down Expand Up @@ -435,9 +435,9 @@ public JVMClusterUtil.RegionServerThread startRegionServerAndWait(long timeout)
ServerName rsServerName = t.getRegionServer().getServerName();

long start = System.currentTimeMillis();
ClusterStatus clusterStatus = getClusterStatus();
ClusterMetrics clusterStatus = getClusterMetrics();
while ((System.currentTimeMillis() - start) < timeout) {
if (clusterStatus != null && clusterStatus.getServers().contains(rsServerName)) {
if (clusterStatus != null && clusterStatus.getLiveServerMetrics().containsKey(rsServerName)) {
return t;
}
Threads.sleep(100);
Expand Down Expand Up @@ -659,16 +659,6 @@ public void shutdown() throws IOException {
public void close() throws IOException {
}

/**
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0
* Use {@link #getClusterMetrics()} instead.
*/
@Deprecated
public ClusterStatus getClusterStatus() throws IOException {
HMaster master = getMaster();
return master == null ? null : new ClusterStatus(master.getClusterMetrics());
}

@Override
public ClusterMetrics getClusterMetrics() throws IOException {
HMaster master = getMaster();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ public void testNone() throws Exception {
// or more requests than expected.
Assert.assertEquals(status0.getLiveServerMetrics().size(),
status1.getLiveServerMetrics().size());
checkPbObjectNotNull(new ClusterStatus(status0));
checkPbObjectNotNull(new ClusterStatus(status1));
}

@Test
Expand All @@ -109,28 +107,26 @@ public void testLiveAndDeadServersStatus() throws Exception {
Waiter.waitFor(CLUSTER.getConfiguration(), 10 * 1000, 100, new Predicate<Exception>() {
@Override
public boolean evaluate() throws Exception {
ClusterStatus status
= new ClusterStatus(ADMIN.getClusterMetrics(EnumSet.of(Option.LIVE_SERVERS)));
ClusterMetrics status = ADMIN.getClusterMetrics(EnumSet.of(Option.LIVE_SERVERS));
Assert.assertNotNull(status);
return status.getRegionsCount() > 0;
return status.getRegionCount() > 0;
}
});
// Retrieve live servers and dead servers info.
EnumSet<Option> options =
EnumSet.of(Option.LIVE_SERVERS, Option.DEAD_SERVERS, Option.SERVERS_NAME);
ClusterStatus status = new ClusterStatus(ADMIN.getClusterMetrics(options));
checkPbObjectNotNull(status);
ClusterMetrics status = ADMIN.getClusterMetrics(options);
Assert.assertNotNull(status);
Assert.assertNotNull(status.getServers());
Assert.assertNotNull(status.getLiveServerMetrics().keySet());
// exclude a dead region server
Assert.assertEquals(SLAVES -1, numRs);
// live servers = nums of regionservers
// By default, HMaster don't carry any regions so it won't report its load.
// Hence, it won't be in the server list.
Assert.assertEquals(status.getServers().size(), numRs);
Assert.assertTrue(status.getRegionsCount() > 0);
Assert.assertEquals(status.getLiveServerMetrics().keySet().size(), numRs);
Assert.assertTrue(status.getRegionCount() > 0);
Assert.assertNotNull(status.getDeadServerNames());
Assert.assertEquals(1, status.getDeadServersSize());
Assert.assertEquals(1, status.getDeadServerNames().size());
ServerName deadServerName = status.getDeadServerNames().iterator().next();
Assert.assertEquals(DEAD.getServerName(), deadServerName);
Assert.assertNotNull(status.getServersName());
Expand Down Expand Up @@ -158,18 +154,18 @@ public void testMasterAndBackupMastersStatus() throws Exception {
Assert.assertEquals(MASTERS, masterThreads.size());
// Retrieve master and backup masters infos only.
EnumSet<Option> options = EnumSet.of(Option.MASTER, Option.BACKUP_MASTERS);
ClusterStatus status = new ClusterStatus(ADMIN.getClusterMetrics(options));
Assert.assertTrue(status.getMaster().equals(activeName));
Assert.assertEquals(MASTERS - 1, status.getBackupMastersSize());
ClusterMetrics status = ADMIN.getClusterMetrics(options);
Assert.assertTrue(status.getMasterName().equals(activeName));
Assert.assertEquals(MASTERS - 1, status.getBackupMasterNames().size());
}

@Test
public void testOtherStatusInfos() throws Exception {
EnumSet<Option> options =
EnumSet.of(Option.MASTER_COPROCESSORS, Option.HBASE_VERSION,
Option.CLUSTER_ID, Option.BALANCER_ON);
ClusterStatus status = new ClusterStatus(ADMIN.getClusterMetrics(options));
Assert.assertTrue(status.getMasterCoprocessors().length == 1);
ClusterMetrics status = ADMIN.getClusterMetrics(options);
Assert.assertTrue(status.getMasterCoprocessorNames().size() == 1);
Assert.assertNotNull(status.getHBaseVersion());
Assert.assertNotNull(status.getClusterId());
Assert.assertTrue(status.getAverageLoad() == 0.0);
Expand All @@ -192,21 +188,6 @@ public void testObserver() throws IOException {
Assert.assertEquals(postCount + 1, MyObserver.POST_COUNT.get());
}

/**
* HBASE-19496 do the refactor for ServerLoad and RegionLoad so the inner pb object is useless
* now. However, they are Public classes, and consequently we must make sure the all pb objects
* have initialized.
*/
private static void checkPbObjectNotNull(ClusterStatus status) {
for (ServerName name : status.getLiveServerMetrics().keySet()) {
ServerLoad load = status.getLoad(name);
Assert.assertNotNull(load.obtainServerLoadPB());
for (RegionLoad rl : load.getRegionsLoad().values()) {
Assert.assertNotNull(rl.regionLoadPB);
}
}
}

public static class MyObserver implements MasterCoprocessor, MasterObserver {
private static final AtomicInteger PRE_COUNT = new AtomicInteger(0);
private static final AtomicInteger POST_COUNT = new AtomicInteger(0);
Expand Down
180 changes: 0 additions & 180 deletions hbase-server/src/test/java/org/apache/hadoop/hbase/TestRegionLoad.java

This file was deleted.

Loading

0 comments on commit 5106f28

Please sign in to comment.