HBASE-19141 [compat 1-2] getClusterStatus always return empty ClusterStatus

Signed-off-by: Chia-Ping Tsai <chia7712@gmail.com>
This commit is contained in:
Chia-Ping Tsai 2017-11-01 07:41:15 +08:00
parent 39e8c16fa8
commit 261cb8a7e4
2 changed files with 10 additions and 19 deletions

View File

@ -2436,6 +2436,12 @@ public class HMaster extends HRegionServer implements MasterServices {
*/ */
public ClusterStatus getClusterStatus(EnumSet<Option> options) throws InterruptedIOException { public ClusterStatus getClusterStatus(EnumSet<Option> options) throws InterruptedIOException {
ClusterStatus.Builder builder = ClusterStatus.newBuilder(); ClusterStatus.Builder builder = ClusterStatus.newBuilder();
// given that hbase1 can't submit the request with Option,
// we return all information to client if the list of Option is empty.
if (options.isEmpty()) {
options = EnumSet.allOf(Option.class);
}
for (Option opt : options) { for (Option opt : options) {
switch (opt) { switch (opt) {
case HBASE_VERSION: builder.setHBaseVersion(VersionInfo.getVersion()); break; case HBASE_VERSION: builder.setHBaseVersion(VersionInfo.getVersion()); break;

View File

@ -20,11 +20,10 @@ package org.apache.hadoop.hbase.client;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.List; import java.util.List;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.ClusterStatus; import org.apache.hadoop.hbase.ClusterStatus;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.ClusterStatus.Option; import org.apache.hadoop.hbase.ClusterStatus.Option;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.MiniHBaseCluster; import org.apache.hadoop.hbase.MiniHBaseCluster;
import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.ServerName;
@ -87,23 +86,9 @@ public class TestClientClusterStatus {
@Test @Test
public void testNone() throws Exception { public void testNone() throws Exception {
ClusterStatus status = ADMIN.getClusterStatus(EnumSet.noneOf(Option.class)); ClusterStatus status0 = ADMIN.getClusterStatus(EnumSet.allOf(Option.class));
// Other cluster status info should be either null or empty. ClusterStatus status1 = ADMIN.getClusterStatus(EnumSet.noneOf(Option.class));
Assert.assertTrue(status.getMasterCoprocessors().length == 0); Assert.assertEquals(status0, status1);
Assert.assertNull(status.getHBaseVersion());
Assert.assertTrue(status.getBackupMasters().isEmpty());
Assert.assertNull(status.getBalancerOn());
Assert.assertNull(status.getClusterId());
Assert.assertTrue(status.getServers().isEmpty());
Assert.assertTrue(status.getDeadServerNames().isEmpty());
Assert.assertNull(status.getMaster());
Assert.assertTrue(status.getBackupMasters().isEmpty());
Assert.assertEquals(-1, status.getMasterInfoPort());
// No npe thrown is expected
Assert.assertNotNull(status.hashCode());
ClusterStatus nullEqualsCheck =
ADMIN.getClusterStatus(EnumSet.noneOf(Option.class));
Assert.assertTrue(status.equals(nullEqualsCheck));
} }
@Test @Test