From 654edc5fa586a4b9c3e225a17836a6acc1d32928 Mon Sep 17 00:00:00 2001 From: Chia-Ping Tsai Date: Thu, 4 Jan 2018 12:40:09 +0800 Subject: [PATCH] HBASE-19596 RegionMetrics/ServerMetrics/ClusterMetrics should apply to all public classes --- .../hadoop/hbase/RegionMetricsBuilder.java | 8 + .../org/apache/hadoop/hbase/client/Admin.java | 119 ++--- .../hadoop/hbase/client/AsyncAdmin.java | 44 +- .../hadoop/hbase/client/AsyncHBaseAdmin.java | 20 +- .../hbase/client/ClusterStatusListener.java | 13 +- .../hadoop/hbase/client/HBaseAdmin.java | 48 +- .../hbase/client/RawAsyncHBaseAdmin.java | 49 +- .../hbase/shaded/protobuf/ProtobufUtil.java | 27 -- .../hbase/client/TestInterfaceAlign.java | 3 +- .../hadoop/hbase/DistributedHBaseCluster.java | 56 +-- .../hadoop/hbase/IntegrationTestIngest.java | 6 +- .../hbase/IntegrationTestLazyCfLoading.java | 10 +- ...tegrationTestRegionReplicaReplication.java | 7 +- .../hbase/IntegrationTestingUtility.java | 7 +- ...tripeCompactionsPerformanceEvaluation.java | 10 +- .../hadoop/hbase/chaos/actions/Action.java | 38 +- .../chaos/actions/BatchRestartRsAction.java | 5 +- .../actions/DumpClusterStatusAction.java | 2 +- .../actions/MoveRegionsOfTableAction.java | 2 +- .../actions/RestartActiveMasterAction.java | 2 +- .../actions/RestartRsHoldingMetaAction.java | 6 +- .../UnbalanceKillAndRebalanceAction.java | 7 +- .../chaos/actions/UnbalanceRegionsAction.java | 7 +- .../mapreduce/IntegrationTestBulkLoad.java | 5 +- .../hbase/mttr/IntegrationTestMTTR.java | 4 +- .../test/IntegrationTestBigLinkedList.java | 7 +- ...TimeBoundedRequestsWithRegionReplicas.java | 5 +- .../hbase/mapreduce/RegionSizeCalculator.java | 15 +- .../mapreduce/TestRegionSizeCalculator.java | 56 ++- .../rest/StorageClusterStatusResource.java | 48 +- .../rest/StorageClusterVersionResource.java | 2 +- .../rsgroup/RSGroupBasedLoadBalancer.java | 11 +- .../hbase/rsgroup/TestRSGroupsBase.java | 57 +-- .../tmpl/master/BackupMasterStatusTmpl.jamon | 4 +- .../hbase/coprocessor/MasterObserver.java | 9 +- .../hbase/master/ClusterStatusPublisher.java | 33 +- .../apache/hadoop/hbase/master/HMaster.java | 36 +- .../hadoop/hbase/master/LoadBalancer.java | 8 +- .../hbase/master/MasterCoprocessorHost.java | 14 +- .../hbase/master/MasterRpcServices.java | 3 +- .../master/RegionPlacementMaintainer.java | 447 +++++++++--------- .../master/balancer/BalancerRegionLoad.java | 17 +- .../master/balancer/BaseLoadBalancer.java | 8 +- .../master/balancer/ClusterStatusChore.java | 2 +- .../master/balancer/RegionLocationFinder.java | 10 +- .../balancer/StochasticLoadBalancer.java | 35 +- .../security/access/AccessController.java | 2 - .../org/apache/hadoop/hbase/tool/Canary.java | 17 +- .../apache/hadoop/hbase/util/HBaseFsck.java | 20 +- .../hadoop/hbase/util/HBaseFsckRepair.java | 2 +- .../apache/hadoop/hbase/util/RegionMover.java | 4 +- .../hadoop/hbase/util/RegionSplitter.java | 6 +- .../org/apache/hadoop/hbase/HBaseCluster.java | 24 +- .../hadoop/hbase/HBaseTestingUtility.java | 5 +- .../apache/hadoop/hbase/MiniHBaseCluster.java | 31 +- .../hbase/TestClientClusterMetrics.java | 29 +- .../hadoop/hbase/TestClientClusterStatus.java | 51 +- .../apache/hadoop/hbase/TestRegionLoad.java | 21 +- .../hadoop/hbase/TestRegionMetrics.java | 14 +- .../TestStochasticBalancerJmxMetrics.java | 17 +- .../hadoop/hbase/client/TestAdmin2.java | 3 +- .../client/TestAsyncClusterAdminApi.java | 45 +- .../client/TestAsyncDecommissionAdminApi.java | 3 +- .../hbase/client/TestFromClientSide.java | 7 +- .../hbase/client/TestMetaWithReplicas.java | 10 +- .../hbase/client/TestMultiParallel.java | 2 +- .../hbase/coprocessor/TestMasterObserver.java | 4 +- .../hbase/master/TestMasterFailover.java | 29 +- ...TestMasterFailoverBalancerPersistence.java | 25 +- ...TestMasterOperationsForRegionReplicas.java | 6 +- .../hbase/master/TestMasterShutdown.java | 8 +- .../TestFavoredStochasticBalancerPickers.java | 8 +- .../TestFavoredStochasticLoadBalancer.java | 27 +- .../balancer/TestRegionLocationFinder.java | 3 +- .../balancer/TestStochasticLoadBalancer.java | 32 +- .../TestRegionServerReadRequestMetrics.java | 10 +- .../TestSplitTransactionOnCluster.java | 6 +- .../replication/TestMasterReplication.java | 9 +- .../replication/TestReplicationStatus.java | 5 +- .../security/access/TestAccessController.java | 7 +- .../hbase/snapshot/SnapshotTestingUtils.java | 9 +- .../hadoop/hbase/util/BaseTestHBaseFsck.java | 8 +- .../util/TestMiniClusterLoadSequential.java | 4 +- 83 files changed, 907 insertions(+), 938 deletions(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionMetricsBuilder.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionMetricsBuilder.java index b5d8048e0f9..f2a549aa3a0 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionMetricsBuilder.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionMetricsBuilder.java @@ -29,12 +29,20 @@ import org.apache.yetus.audience.InterfaceAudience; import org.apache.hbase.thirdparty.com.google.common.base.Preconditions; import org.apache.hbase.thirdparty.com.google.protobuf.UnsafeByteOperations; + +import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos; import org.apache.hadoop.hbase.shaded.protobuf.generated.ClusterStatusProtos; import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos; @InterfaceAudience.Private public final class RegionMetricsBuilder { + public static List toRegionMetrics( + AdminProtos.GetRegionLoadResponse regionLoadResponse) { + return regionLoadResponse.getRegionLoadsList().stream() + .map(RegionMetricsBuilder::toRegionMetrics).collect(Collectors.toList()); + } + public static RegionMetrics toRegionMetrics(ClusterStatusProtos.RegionLoad regionLoadPB) { return RegionMetricsBuilder .newBuilder(regionLoadPB.getRegionSpecifier().getValue().toByteArray()) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java index a94593c23fa..f61b32ef612 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java @@ -25,19 +25,19 @@ import java.util.EnumSet; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.TreeMap; import java.util.concurrent.Future; import java.util.regex.Pattern; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.Abortable; import org.apache.hadoop.hbase.CacheEvictionStats; +import org.apache.hadoop.hbase.ClusterMetrics; import org.apache.hadoop.hbase.ClusterMetrics.Option; import org.apache.hadoop.hbase.ClusterStatus; import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.NamespaceDescriptor; import org.apache.hadoop.hbase.NamespaceNotFoundException; -import org.apache.hadoop.hbase.RegionLoad; +import org.apache.hadoop.hbase.RegionMetrics; import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.TableExistsException; import org.apache.hadoop.hbase.TableName; @@ -56,7 +56,6 @@ import org.apache.hadoop.hbase.snapshot.HBaseSnapshotException; import org.apache.hadoop.hbase.snapshot.RestoreSnapshotException; import org.apache.hadoop.hbase.snapshot.SnapshotCreationException; import org.apache.hadoop.hbase.snapshot.UnknownSnapshotException; -import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Pair; import org.apache.yetus.audience.InterfaceAudience; @@ -1452,22 +1451,45 @@ public interface Admin extends Abortable, Closeable { * * @return cluster status * @throws IOException if a remote or network exception occurs + * @deprecated since 2.0 version and will be removed in 3.0 version. + * use {@link #getClusterMetrics()} */ - ClusterStatus getClusterStatus() throws IOException; + @Deprecated + default ClusterStatus getClusterStatus() throws IOException { + return new ClusterStatus(getClusterMetrics()); + } + + /** + * Get whole cluster metrics, containing status about: + *
+   * hbase version
+   * cluster id
+   * primary/backup master(s)
+   * master's coprocessors
+   * live/dead regionservers
+   * balancer
+   * regions in transition
+   * 
+ * @return cluster metrics + * @throws IOException if a remote or network exception occurs + */ + default ClusterMetrics getClusterMetrics() throws IOException { + return getClusterMetrics(EnumSet.allOf(ClusterMetrics.Option.class)); + } /** * Get cluster status with a set of {@link Option} to get desired status. * @return cluster status * @throws IOException if a remote or network exception occurs */ - ClusterStatus getClusterStatus(EnumSet