From 98245ca6e4b6b8cffe22534f32e825c912de2ed3 Mon Sep 17 00:00:00 2001 From: tedyu Date: Fri, 22 Jun 2018 00:26:14 -0700 Subject: [PATCH] HBASE-20740 StochasticLoadBalancer should consider CoprocessorService request factor when computing cost (chenxu) --- .../org/apache/hadoop/hbase/RegionLoad.java | 5 ++ .../apache/hadoop/hbase/RegionMetrics.java | 10 ++- .../hadoop/hbase/RegionMetricsBuilder.java | 18 ++++ .../org/apache/hadoop/hbase/ServerLoad.java | 19 +++- .../hadoop/hbase/ServerMetricsBuilder.java | 3 + .../MetricsRegionServerSource.java | 3 + .../MetricsRegionServerWrapper.java | 5 ++ .../regionserver/MetricsRegionWrapper.java | 5 ++ .../regionserver/MetricsTableSource.java | 2 + .../MetricsTableWrapperAggregate.java | 5 ++ .../MetricsRegionServerSourceImpl.java | 2 + .../regionserver/MetricsRegionSourceImpl.java | 4 + .../regionserver/MetricsTableSourceImpl.java | 3 + .../TestMetricsRegionSourceImpl.java | 5 ++ .../TestMetricsTableSourceImpl.java | 5 ++ .../src/main/protobuf/ClusterStatus.proto | 3 + .../src/main/protobuf/ClusterStatus.proto | 3 + .../rest/StorageClusterStatusResource.java | 1 + .../rest/model/StorageClusterStatusModel.java | 32 +++++-- .../StorageClusterStatusMessage.proto | 1 + .../model/TestStorageClusterStatusModel.java | 25 +++--- .../master/balancer/BalancerRegionLoad.java | 6 ++ .../balancer/StochasticLoadBalancer.java | 25 ++++++ .../hadoop/hbase/regionserver/HRegion.java | 11 ++- .../hbase/regionserver/HRegionServer.java | 1 + .../MetricsRegionServerWrapperImpl.java | 10 ++- .../MetricsRegionWrapperImpl.java | 5 ++ .../MetricsTableWrapperAggregateImpl.java | 53 ++++++++--- .../hadoop/hbase/regionserver/Region.java | 3 + .../hadoop/hbase/TestServerMetrics.java | 3 + .../balancer/TestStochasticLoadBalancer.java | 87 +++++++++++++++++++ .../MetricsRegionServerWrapperStub.java | 5 ++ .../MetricsRegionWrapperStub.java | 5 ++ .../regionserver/MetricsTableWrapperStub.java | 5 ++ .../hbase/regionserver/TestMetricsRegion.java | 6 ++ .../regionserver/TestMetricsRegionServer.java | 1 + .../TestMetricsTableAggregate.java | 3 +- 37 files changed, 349 insertions(+), 39 deletions(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLoad.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLoad.java index 242e5ea6fdc..ef92291aff5 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLoad.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLoad.java @@ -93,6 +93,11 @@ public class RegionLoad implements RegionMetrics { return metrics.getReadRequestCount(); } + @Override + public long getCpRequestCount() { + return metrics.getCpRequestCount(); + } + @Override public long getFilteredReadRequestCount() { return metrics.getFilteredReadRequestCount(); diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionMetrics.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionMetrics.java index e73683f4833..a75ddba7e53 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionMetrics.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionMetrics.java @@ -66,10 +66,16 @@ public interface RegionMetrics { long getWriteRequestCount(); /** - * @return the number of write requests and read requests made to region + * @return the number of coprocessor service requests made to region + */ + public long getCpRequestCount(); + + /** + * @return the number of write requests and read requests and coprocessor + * service requests made to region */ default long getRequestCount() { - return getReadRequestCount() + getWriteRequestCount(); + return getReadRequestCount() + getWriteRequestCount() + getCpRequestCount(); } /** 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 f2a549aa3a0..9011c2a1b67 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 @@ -57,6 +57,7 @@ public final class RegionMetricsBuilder { .setLastMajorCompactionTimestamp(regionLoadPB.getLastMajorCompactionTs()) .setMemStoreSize(new Size(regionLoadPB.getMemStoreSizeMB(), Size.Unit.MEGABYTE)) .setReadRequestCount(regionLoadPB.getReadRequestsCount()) + .setCpRequestCount(regionLoadPB.getCpRequestsCount()) .setWriteRequestCount(regionLoadPB.getWriteRequestsCount()) .setStoreFileIndexSize(new Size(regionLoadPB.getStorefileIndexSizeKB(), Size.Unit.KILOBYTE)) @@ -102,6 +103,7 @@ public final class RegionMetricsBuilder { .setLastMajorCompactionTs(regionMetrics.getLastMajorCompactionTimestamp()) .setMemStoreSizeMB((int) regionMetrics.getMemStoreSize().get(Size.Unit.MEGABYTE)) .setReadRequestsCount(regionMetrics.getReadRequestCount()) + .setCpRequestsCount(regionMetrics.getCpRequestCount()) .setWriteRequestsCount(regionMetrics.getWriteRequestCount()) .setStorefileIndexSizeKB((long) regionMetrics.getStoreFileIndexSize() .get(Size.Unit.KILOBYTE)) @@ -134,6 +136,7 @@ public final class RegionMetricsBuilder { private Size uncompressedStoreFileSize = Size.ZERO; private long writeRequestCount; private long readRequestCount; + private long cpRequestCount; private long filteredReadRequestCount; private long completedSequenceId; private Map storeSequenceIds = Collections.emptyMap(); @@ -195,6 +198,10 @@ public final class RegionMetricsBuilder { this.readRequestCount = value; return this; } + public RegionMetricsBuilder setCpRequestCount(long value) { + this.cpRequestCount = value; + return this; + } public RegionMetricsBuilder setFilteredReadRequestCount(long value) { this.filteredReadRequestCount = value; return this; @@ -231,6 +238,7 @@ public final class RegionMetricsBuilder { uncompressedStoreFileSize, writeRequestCount, readRequestCount, + cpRequestCount, filteredReadRequestCount, completedSequenceId, storeSequenceIds, @@ -253,6 +261,7 @@ public final class RegionMetricsBuilder { private final Size uncompressedStoreFileSize; private final long writeRequestCount; private final long readRequestCount; + private final long cpRequestCount; private final long filteredReadRequestCount; private final long completedSequenceId; private final Map storeSequenceIds; @@ -272,6 +281,7 @@ public final class RegionMetricsBuilder { Size uncompressedStoreFileSize, long writeRequestCount, long readRequestCount, + long cpRequestCount, long filteredReadRequestCount, long completedSequenceId, Map storeSequenceIds, @@ -291,6 +301,7 @@ public final class RegionMetricsBuilder { this.uncompressedStoreFileSize = Preconditions.checkNotNull(uncompressedStoreFileSize); this.writeRequestCount = writeRequestCount; this.readRequestCount = readRequestCount; + this.cpRequestCount = cpRequestCount; this.filteredReadRequestCount = filteredReadRequestCount; this.completedSequenceId = completedSequenceId; this.storeSequenceIds = Preconditions.checkNotNull(storeSequenceIds); @@ -328,6 +339,11 @@ public final class RegionMetricsBuilder { return readRequestCount; } + @Override + public long getCpRequestCount() { + return cpRequestCount; + } + @Override public long getFilteredReadRequestCount() { return filteredReadRequestCount; @@ -415,6 +431,8 @@ public final class RegionMetricsBuilder { this.getMemStoreSize()); Strings.appendKeyValue(sb, "readRequestCount", this.getReadRequestCount()); + Strings.appendKeyValue(sb, "cpRequestCount", + this.getCpRequestCount()); Strings.appendKeyValue(sb, "writeRequestCount", this.getWriteRequestCount()); Strings.appendKeyValue(sb, "rootLevelIndexSize", diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/ServerLoad.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/ServerLoad.java index 7a1019aacab..dbf00700b00 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/ServerLoad.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/ServerLoad.java @@ -52,6 +52,7 @@ public class ServerLoad implements ServerMetrics { private int memstoreSizeMB = 0; private long storefileIndexSizeKB = 0; private long readRequestsCount = 0; + private long cpRequestsCount = 0; private long filteredReadRequestsCount = 0; private long writeRequestsCount = 0; private int rootIndexSizeKB = 0; @@ -86,6 +87,7 @@ public class ServerLoad implements ServerMetrics { storefileSizeMB += rl.getStoreFileSize().get(Size.Unit.MEGABYTE); memstoreSizeMB += rl.getMemStoreSize().get(Size.Unit.MEGABYTE); readRequestsCount += rl.getReadRequestCount(); + cpRequestsCount += rl.getCpRequestCount(); filteredReadRequestsCount += rl.getFilteredReadRequestCount(); writeRequestsCount += rl.getWriteRequestCount(); storefileIndexSizeKB += rl.getStoreFileIndexSize().get(Size.Unit.KILOBYTE); @@ -278,6 +280,15 @@ public class ServerLoad implements ServerMetrics { return readRequestsCount; } + /** + * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0 + * Use {@link #getRegionMetrics} instead. + */ + @Deprecated + public long getCpRequestsCount() { + return cpRequestsCount; + } + /** * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0 * Use {@link #getRegionMetrics} instead. @@ -501,6 +512,7 @@ public class ServerLoad implements ServerMetrics { Strings.appendKeyValue(sb, "storefileIndexSizeKB", Long.valueOf(this.storefileIndexSizeKB)); Strings.appendKeyValue(sb, "readRequestsCount", Long.valueOf(this.readRequestsCount)); + Strings.appendKeyValue(sb, "cpRequestsCount", Long.valueOf(this.cpRequestsCount)); Strings.appendKeyValue(sb, "filteredReadRequestsCount", Long.valueOf(this.filteredReadRequestsCount)); Strings.appendKeyValue(sb, "writeRequestsCount", Long.valueOf(this.writeRequestsCount)); @@ -547,9 +559,9 @@ public class ServerLoad implements ServerMetrics { public int hashCode() { return Objects .hashCode(stores, storefiles, storeUncompressedSizeMB, storefileSizeMB, memstoreSizeMB, - storefileIndexSizeKB, readRequestsCount, filteredReadRequestsCount, writeRequestsCount, - rootIndexSizeKB, totalStaticIndexSizeKB, totalStaticBloomSizeKB, totalCompactingKVs, - currentCompactedKVs); + storefileIndexSizeKB, readRequestsCount, cpRequestsCount, filteredReadRequestsCount, + writeRequestsCount, rootIndexSizeKB, totalStaticIndexSizeKB, totalStaticBloomSizeKB, + totalCompactingKVs, currentCompactedKVs); } @Override @@ -562,6 +574,7 @@ public class ServerLoad implements ServerMetrics { && storefileSizeMB == sl.storefileSizeMB && memstoreSizeMB == sl.memstoreSizeMB && storefileIndexSizeKB == sl.storefileIndexSizeKB && readRequestsCount == sl.readRequestsCount + && cpRequestsCount == sl.cpRequestsCount && filteredReadRequestsCount == sl.filteredReadRequestsCount && writeRequestsCount == sl.writeRequestsCount && rootIndexSizeKB == sl.rootIndexSizeKB && totalStaticIndexSizeKB == sl.totalStaticIndexSizeKB diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/ServerMetricsBuilder.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/ServerMetricsBuilder.java index 50addf6bddf..96ead7bcc68 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/ServerMetricsBuilder.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/ServerMetricsBuilder.java @@ -324,6 +324,7 @@ public final class ServerMetricsBuilder { long storefileIndexSizeKB = 0; long rootLevelIndexSizeKB = 0; long readRequestsCount = 0; + long cpRequestsCount = 0; long writeRequestsCount = 0; long filteredReadRequestsCount = 0; long bloomFilterSizeMB = 0; @@ -337,6 +338,7 @@ public final class ServerMetricsBuilder { memStoreSizeMB += r.getMemStoreSize().get(Size.Unit.MEGABYTE); storefileIndexSizeKB += r.getStoreFileUncompressedDataIndexSize().get(Size.Unit.KILOBYTE); readRequestsCount += r.getReadRequestCount(); + cpRequestsCount += r.getCpRequestCount(); writeRequestsCount += r.getWriteRequestCount(); filteredReadRequestsCount += r.getFilteredReadRequestCount(); rootLevelIndexSizeKB += r.getStoreFileRootLevelIndexSize().get(Size.Unit.KILOBYTE); @@ -360,6 +362,7 @@ public final class ServerMetricsBuilder { } Strings.appendKeyValue(sb, "memstoreSizeMB", memStoreSizeMB); Strings.appendKeyValue(sb, "readRequestsCount", readRequestsCount); + Strings.appendKeyValue(sb, "cpRequestsCount", cpRequestsCount); Strings.appendKeyValue(sb, "filteredReadRequestsCount", filteredReadRequestsCount); Strings.appendKeyValue(sb, "writeRequestsCount", writeRequestsCount); Strings.appendKeyValue(sb, "rootIndexSizeKB", rootLevelIndexSizeKB); diff --git a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSource.java b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSource.java index 4636fe0536e..2ae26e154ea 100644 --- a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSource.java +++ b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSource.java @@ -256,6 +256,9 @@ public interface MetricsRegionServerSource extends BaseSource, JvmPauseMonitorSo String READ_REQUEST_COUNT = "readRequestCount"; String READ_REQUEST_COUNT_DESC = "Number of read requests with non-empty Results that this RegionServer has answered."; + String CP_REQUEST_COUNT = "cpRequestCount"; + String CP_REQUEST_COUNT_DESC = + "Number of coprocessor service requests this region server has answered."; String FILTERED_READ_REQUEST_COUNT = "filteredReadRequestCount"; String FILTERED_READ_REQUEST_COUNT_DESC = "Number of filtered read requests this RegionServer has answered."; diff --git a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapper.java b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapper.java index 83a8339c20a..02c78c780ff 100644 --- a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapper.java +++ b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapper.java @@ -135,6 +135,11 @@ public interface MetricsRegionServerWrapper { */ long getReadRequestsCount(); + /** + * Get the number of coprocessor requests to regions hosted on this region server. + */ + long getCpRequestsCount(); + /** * Get the number of filtered read requests to regions hosted on this region server. */ diff --git a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionWrapper.java b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionWrapper.java index 9b2aba1d903..268f31f65e0 100644 --- a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionWrapper.java +++ b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionWrapper.java @@ -72,6 +72,11 @@ public interface MetricsRegionWrapper { */ long getReadRequestCount(); + /** + * Get the total number of CoprocessorService requests that have been issued against this region + */ + long getCpRequestCount(); + /** * Get the total number of filtered read requests that have been issued against this region */ diff --git a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsTableSource.java b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsTableSource.java index b8476bf1c46..c58fa01bbf0 100644 --- a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsTableSource.java +++ b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsTableSource.java @@ -29,6 +29,8 @@ public interface MetricsTableSource extends Comparable { String READ_REQUEST_COUNT = "readRequestCount"; String READ_REQUEST_COUNT_DESC = "Number of read requests"; + String CP_REQUEST_COUNT = "cpRequestCount"; + String CP_REQUEST_COUNT_DESC = "Number of coprocessor service requests"; String WRITE_REQUEST_COUNT = "writeRequestCount"; String WRITE_REQUEST_COUNT_DESC = "Number of write requests"; String TOTAL_REQUEST_COUNT = "totalRequestCount"; diff --git a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsTableWrapperAggregate.java b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsTableWrapperAggregate.java index e1d2ab2a74c..aaa2460e6d0 100644 --- a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsTableWrapperAggregate.java +++ b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsTableWrapperAggregate.java @@ -32,6 +32,11 @@ public interface MetricsTableWrapperAggregate { */ long getReadRequestsCount(String table); + /** + * Get the number of CoprocessorService requests that have been issued against this table + */ + long getCpRequestsCount(String table); + /** * Get the number of write requests that have been issued against this table */ diff --git a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSourceImpl.java b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSourceImpl.java index 94b8389fc7f..e6f2e93eaf0 100644 --- a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSourceImpl.java +++ b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSourceImpl.java @@ -340,6 +340,8 @@ public class MetricsRegionServerSourceImpl TOTAL_ROW_ACTION_REQUEST_COUNT_DESC), rsWrap.getTotalRowActionRequestCount()) .addCounter(Interns.info(READ_REQUEST_COUNT, READ_REQUEST_COUNT_DESC), rsWrap.getReadRequestsCount()) + .addCounter(Interns.info(CP_REQUEST_COUNT, CP_REQUEST_COUNT_DESC), + rsWrap.getCpRequestsCount()) .addCounter(Interns.info(FILTERED_READ_REQUEST_COUNT, FILTERED_READ_REQUEST_COUNT_DESC), rsWrap.getFilteredReadRequestsCount()) .addCounter(Interns.info(WRITE_REQUEST_COUNT, WRITE_REQUEST_COUNT_DESC), diff --git a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionSourceImpl.java b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionSourceImpl.java index ff1f42d4e40..1831062c288 100644 --- a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionSourceImpl.java +++ b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionSourceImpl.java @@ -261,6 +261,10 @@ public class MetricsRegionSourceImpl implements MetricsRegionSource { regionNamePrefix + MetricsRegionServerSource.READ_REQUEST_COUNT, MetricsRegionServerSource.READ_REQUEST_COUNT_DESC), this.regionWrapper.getReadRequestCount()); + mrb.addCounter(Interns.info( + regionNamePrefix + MetricsRegionServerSource.CP_REQUEST_COUNT, + MetricsRegionServerSource.CP_REQUEST_COUNT_DESC), + this.regionWrapper.getCpRequestCount()); mrb.addCounter(Interns.info( regionNamePrefix + MetricsRegionServerSource.FILTERED_READ_REQUEST_COUNT, MetricsRegionServerSource.FILTERED_READ_REQUEST_COUNT_DESC), diff --git a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsTableSourceImpl.java b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsTableSourceImpl.java index 37653cd38c5..0733179f8c3 100644 --- a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsTableSourceImpl.java +++ b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsTableSourceImpl.java @@ -125,6 +125,9 @@ public class MetricsTableSourceImpl implements MetricsTableSource { mrb.addCounter(Interns.info(tableNamePrefix + MetricsTableSource.READ_REQUEST_COUNT, MetricsTableSource.READ_REQUEST_COUNT_DESC), tableWrapperAgg.getReadRequestsCount(tableName.getNameAsString())); + mrb.addCounter(Interns.info(tableNamePrefix + MetricsTableSource.CP_REQUEST_COUNT, + MetricsTableSource.CP_REQUEST_COUNT_DESC), + tableWrapperAgg.getCpRequestsCount(tableName.getNameAsString())); mrb.addCounter(Interns.info(tableNamePrefix + MetricsTableSource.WRITE_REQUEST_COUNT, MetricsTableSource.WRITE_REQUEST_COUNT_DESC), tableWrapperAgg.getWriteRequestsCount(tableName.getNameAsString())); diff --git a/hbase-hadoop2-compat/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsRegionSourceImpl.java b/hbase-hadoop2-compat/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsRegionSourceImpl.java index a22c7a54e2f..4953b62ef70 100644 --- a/hbase-hadoop2-compat/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsRegionSourceImpl.java +++ b/hbase-hadoop2-compat/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsRegionSourceImpl.java @@ -134,6 +134,11 @@ public class TestMetricsRegionSourceImpl { return 0; } + @Override + public long getCpRequestCount() { + return 0; + } + @Override public long getWriteRequestCount() { return 0; diff --git a/hbase-hadoop2-compat/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsTableSourceImpl.java b/hbase-hadoop2-compat/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsTableSourceImpl.java index 25fe5324a8a..4c2b40c9d19 100644 --- a/hbase-hadoop2-compat/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsTableSourceImpl.java +++ b/hbase-hadoop2-compat/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsTableSourceImpl.java @@ -86,6 +86,11 @@ public class TestMetricsTableSourceImpl { return 10; } + @Override + public long getCpRequestsCount(String table) { + return 15; + } + @Override public long getWriteRequestsCount(String table) { return 20; diff --git a/hbase-protocol-shaded/src/main/protobuf/ClusterStatus.proto b/hbase-protocol-shaded/src/main/protobuf/ClusterStatus.proto index 9fd5f044134..399ff5ea966 100644 --- a/hbase-protocol-shaded/src/main/protobuf/ClusterStatus.proto +++ b/hbase-protocol-shaded/src/main/protobuf/ClusterStatus.proto @@ -139,6 +139,9 @@ message RegionLoad { /** the current total filtered read requests made to region */ optional uint64 filtered_read_requests_count = 19; + + /** the current total coprocessor requests made to region */ + optional uint64 cp_requests_count = 20; } /* Server-level protobufs */ diff --git a/hbase-protocol/src/main/protobuf/ClusterStatus.proto b/hbase-protocol/src/main/protobuf/ClusterStatus.proto index b172db55c30..009d172c366 100644 --- a/hbase-protocol/src/main/protobuf/ClusterStatus.proto +++ b/hbase-protocol/src/main/protobuf/ClusterStatus.proto @@ -139,6 +139,9 @@ message RegionLoad { /** the current total filtered read requests made to region */ optional uint64 filtered_read_requests_count = 19; + + /** the current total coprocessor requests made to region */ + optional uint64 cp_requests_count = 20; } /* Server-level protobufs */ diff --git a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/StorageClusterStatusResource.java b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/StorageClusterStatusResource.java index 2323bf3374b..bbdbf7434e4 100644 --- a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/StorageClusterStatusResource.java +++ b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/StorageClusterStatusResource.java @@ -92,6 +92,7 @@ public class StorageClusterStatusResource extends ResourceBase { (int) region.getMemStoreSize().get(Size.Unit.MEGABYTE), (long) region.getStoreFileIndexSize().get(Size.Unit.KILOBYTE), region.getReadRequestCount(), + region.getCpRequestCount(), region.getWriteRequestCount(), (int) region.getStoreFileRootLevelIndexSize().get(Size.Unit.KILOBYTE), (int) region.getStoreFileUncompressedDataIndexSize().get(Size.Unit.KILOBYTE), diff --git a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/StorageClusterStatusModel.java b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/StorageClusterStatusModel.java index a20a40565ea..8dfebe172a9 100644 --- a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/StorageClusterStatusModel.java +++ b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/StorageClusterStatusModel.java @@ -85,6 +85,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; * <attribute name="memstoreSizeMB" type="int"></attribute> * <attribute name="storefileIndexSizeMB" type="int"></attribute> * <attribute name="readRequestsCount" type="int"></attribute> + * <attribute name="cpRequestsCount" type="int"></attribute> * <attribute name="writeRequestsCount" type="int"></attribute> * <attribute name="rootIndexSizeKB" type="int"></attribute> * <attribute name="totalStaticIndexSizeKB" type="int"></attribute> @@ -119,6 +120,7 @@ public class StorageClusterStatusModel private int memstoreSizeMB; private long storefileIndexSizeKB; private long readRequestsCount; + private long cpRequestsCount; private long writeRequestsCount; private int rootIndexSizeKB; private int totalStaticIndexSizeKB; @@ -151,8 +153,8 @@ public class StorageClusterStatusModel */ public Region(byte[] name, int stores, int storefiles, int storefileSizeMB, int memstoreSizeMB, long storefileIndexSizeKB, - long readRequestsCount, long writeRequestsCount, int rootIndexSizeKB, - int totalStaticIndexSizeKB, int totalStaticBloomSizeKB, + long readRequestsCount, long cpRequestsCount, long writeRequestsCount, + int rootIndexSizeKB, int totalStaticIndexSizeKB, int totalStaticBloomSizeKB, long totalCompactingKVs, long currentCompactedKVs) { this.name = name; this.stores = stores; @@ -161,6 +163,7 @@ public class StorageClusterStatusModel this.memstoreSizeMB = memstoreSizeMB; this.storefileIndexSizeKB = storefileIndexSizeKB; this.readRequestsCount = readRequestsCount; + this.cpRequestsCount = cpRequestsCount; this.writeRequestsCount = writeRequestsCount; this.rootIndexSizeKB = rootIndexSizeKB; this.totalStaticIndexSizeKB = totalStaticIndexSizeKB; @@ -225,6 +228,14 @@ public class StorageClusterStatusModel return readRequestsCount; } + /** + * @return the current total read requests made to region + */ + @XmlAttribute + public long getCpRequestsCount() { + return cpRequestsCount; + } + /** * @return the current total write requests made to region */ @@ -280,6 +291,13 @@ public class StorageClusterStatusModel this.readRequestsCount = readRequestsCount; } + /** + * @param cpRequestsCount The current total read requests made to region + */ + public void setCpRequestsCount(long cpRequestsCount) { + this.cpRequestsCount = cpRequestsCount; + } + /** * @param rootIndexSizeKB The current total size of root-level indexes * for the region, in KB @@ -383,11 +401,11 @@ public class StorageClusterStatusModel */ public void addRegion(byte[] name, int stores, int storefiles, int storefileSizeMB, int memstoreSizeMB, long storefileIndexSizeKB, - long readRequestsCount, long writeRequestsCount, int rootIndexSizeKB, - int totalStaticIndexSizeKB, int totalStaticBloomSizeKB, + long readRequestsCount, long cpRequestsCount, long writeRequestsCount, + int rootIndexSizeKB, int totalStaticIndexSizeKB, int totalStaticBloomSizeKB, long totalCompactingKVs, long currentCompactedKVs) { regions.add(new Region(name, stores, storefiles, storefileSizeMB, - memstoreSizeMB, storefileIndexSizeKB, readRequestsCount, + memstoreSizeMB, storefileIndexSizeKB, readRequestsCount, cpRequestsCount, writeRequestsCount, rootIndexSizeKB, totalStaticIndexSizeKB, totalStaticBloomSizeKB, totalCompactingKVs, currentCompactedKVs)); } @@ -683,6 +701,8 @@ public class StorageClusterStatusModel sb.append(region.storefileIndexSizeKB); sb.append("\n readRequestsCount="); sb.append(region.readRequestsCount); + sb.append("\n cpRequestsCount="); + sb.append(region.cpRequestsCount); sb.append("\n writeRequestsCount="); sb.append(region.writeRequestsCount); sb.append("\n rootIndexSizeKB="); @@ -737,6 +757,7 @@ public class StorageClusterStatusModel regionBuilder.setMemStoreSizeMB(region.memstoreSizeMB); regionBuilder.setStorefileIndexSizeKB(region.storefileIndexSizeKB); regionBuilder.setReadRequestsCount(region.readRequestsCount); + regionBuilder.setCpRequestsCount(region.cpRequestsCount); regionBuilder.setWriteRequestsCount(region.writeRequestsCount); regionBuilder.setRootIndexSizeKB(region.rootIndexSizeKB); regionBuilder.setTotalStaticIndexSizeKB(region.totalStaticIndexSizeKB); @@ -783,6 +804,7 @@ public class StorageClusterStatusModel region.getMemStoreSizeMB(), region.getStorefileIndexSizeKB(), region.getReadRequestsCount(), + region.getCpRequestsCount(), region.getWriteRequestsCount(), region.getRootIndexSizeKB(), region.getTotalStaticIndexSizeKB(), diff --git a/hbase-rest/src/main/protobuf/StorageClusterStatusMessage.proto b/hbase-rest/src/main/protobuf/StorageClusterStatusMessage.proto index f03a6bc3997..e073110d752 100644 --- a/hbase-rest/src/main/protobuf/StorageClusterStatusMessage.proto +++ b/hbase-rest/src/main/protobuf/StorageClusterStatusMessage.proto @@ -32,6 +32,7 @@ message StorageClusterStatus { optional int32 totalStaticBloomSizeKB = 11; optional int64 totalCompactingKVs = 12; optional int64 currentCompactedKVs = 13; + optional int64 cpRequestsCount = 14; } message Node { required string name = 1; // name:port diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestStorageClusterStatusModel.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestStorageClusterStatusModel.java index 77ca7614b1f..957f97558d7 100644 --- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestStorageClusterStatusModel.java +++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestStorageClusterStatusModel.java @@ -68,16 +68,17 @@ public class TestStorageClusterStatusModel extends TestModelBase entry : localMetricsTableMap.entrySet()) { @@ -108,55 +110,71 @@ public class MetricsTableWrapperAggregateImpl implements MetricsTableWrapperAggr @Override public long getReadRequestsCount(String table) { MetricsTableValues metricsTable = metricsTableMap.get(TableName.valueOf(table)); - if (metricsTable == null) + if (metricsTable == null) { return 0; - else + } else { return metricsTable.getReadRequestsCount(); + } + } + + @Override + public long getCpRequestsCount(String table) { + MetricsTableValues metricsTable = metricsTableMap.get(TableName.valueOf(table)); + if (metricsTable == null) { + return 0; + } else { + return metricsTable.getCpRequestsCount(); + } } @Override public long getWriteRequestsCount(String table) { MetricsTableValues metricsTable = metricsTableMap.get(TableName.valueOf(table)); - if (metricsTable == null) + if (metricsTable == null) { return 0; - else + } else { return metricsTable.getWriteRequestsCount(); + } } @Override public long getTotalRequestsCount(String table) { MetricsTableValues metricsTable = metricsTableMap.get(TableName.valueOf(table)); - if (metricsTable == null) + if (metricsTable == null) { return 0; - else + } else { return metricsTable.getTotalRequestsCount(); + } } @Override public long getMemStoresSize(String table) { MetricsTableValues metricsTable = metricsTableMap.get(TableName.valueOf(table)); - if (metricsTable == null) + if (metricsTable == null) { return 0; - else + } else { return metricsTable.getMemStoresSize(); + } } @Override public long getStoreFilesSize(String table) { MetricsTableValues metricsTable = metricsTableMap.get(TableName.valueOf(table)); - if (metricsTable == null) + if (metricsTable == null) { return 0; - else + } else { return metricsTable.getStoreFilesSize(); + } } @Override public long getTableSize(String table) { MetricsTableValues metricsTable = metricsTableMap.get(TableName.valueOf(table)); - if (metricsTable == null) + if (metricsTable == null) { return 0; - else + } else { return metricsTable.getTableSize(); + } } @Override @@ -168,6 +186,7 @@ public class MetricsTableWrapperAggregateImpl implements MetricsTableWrapperAggr private long totalRequestsCount; private long readRequestsCount; + private long cpRequestsCount; private long writeRequestsCount; private long memstoresSize; private long storeFilesSize; @@ -189,6 +208,14 @@ public class MetricsTableWrapperAggregateImpl implements MetricsTableWrapperAggr this.readRequestsCount = readRequestsCount; } + public long getCpRequestsCount() { + return cpRequestsCount; + } + + public void setCpRequestsCount(long cpRequestsCount) { + this.cpRequestsCount = cpRequestsCount; + } + public long getWriteRequestsCount() { return writeRequestsCount; } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/Region.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/Region.java index 80b18b8ae2a..7070ef2ad22 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/Region.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/Region.java @@ -140,6 +140,9 @@ public interface Region extends ConfigurationObserver { /** @return read requests count for this region */ long getReadRequestsCount(); + /** @return coprocessor requests count for this region */ + long getCpRequestsCount(); + /** @return filtered read requests count for this region */ long getFilteredReadRequestsCount(); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestServerMetrics.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestServerMetrics.java index b3c903c7730..4016a68130a 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestServerMetrics.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestServerMetrics.java @@ -56,6 +56,8 @@ public class TestServerMetrics { .mapToDouble(v -> v.getStoreFileIndexSize().get(Size.Unit.KILOBYTE)).sum(), 0); assertEquals(((long) Integer.MAX_VALUE) * 2, metrics.getRegionMetrics().values().stream().mapToLong(v -> v.getReadRequestCount()).sum()); + assertEquals(100, + metrics.getRegionMetrics().values().stream().mapToLong(v -> v.getCpRequestCount()).sum()); assertEquals(300, metrics.getRegionMetrics().values().stream().mapToLong(v -> v.getFilteredReadRequestCount()) .sum()); @@ -106,6 +108,7 @@ public class TestServerMetrics { .setStorefiles(13).setStoreUncompressedSizeMB(23).setStorefileSizeMB(300) .setFilteredReadRequestsCount(200).setStorefileIndexSizeKB(40).setRootIndexSizeKB(303) .setReadRequestsCount(Integer.MAX_VALUE).setWriteRequestsCount(Integer.MAX_VALUE) + .setCpRequestsCount(100) .build(); ClusterStatusProtos.ServerLoad sl = diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestStochasticLoadBalancer.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestStochasticLoadBalancer.java index 149bf681d09..d25f92478b5 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestStochasticLoadBalancer.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestStochasticLoadBalancer.java @@ -25,10 +25,14 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Queue; +import java.util.Set; import java.util.TreeMap; + import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.ClusterMetrics; import org.apache.hadoop.hbase.HBaseClassTestRule; @@ -116,6 +120,81 @@ public class TestStochasticLoadBalancer extends BalancerTestBase { }, }; + private ServerMetrics mockServerMetricsWithCpRequests(ServerName server, + List regionsOnServer, long cpRequestCount) { + ServerMetrics serverMetrics = mock(ServerMetrics.class); + Map regionLoadMap = new TreeMap<>(Bytes.BYTES_COMPARATOR); + for(RegionInfo info : regionsOnServer){ + RegionMetrics rl = mock(RegionMetrics.class); + when(rl.getReadRequestCount()).thenReturn(0L); + when(rl.getCpRequestCount()).thenReturn(cpRequestCount); + when(rl.getWriteRequestCount()).thenReturn(0L); + when(rl.getMemStoreSize()).thenReturn(Size.ZERO); + when(rl.getStoreFileSize()).thenReturn(Size.ZERO); + regionLoadMap.put(info.getEncodedNameAsBytes(), rl); + } + when(serverMetrics.getRegionMetrics()).thenReturn(regionLoadMap); + return serverMetrics; + } + + @Test + public void testCPRequestCost() { + // in order to pass needsBalance judgement + conf.setFloat("hbase.master.balancer.stochastic.cpRequestCost", 10000f); + loadBalancer.setConf(conf); + // mock cluster State + Map> clusterState = new HashMap>(); + ServerName serverA = randomServer(3).getServerName(); + ServerName serverB = randomServer(3).getServerName(); + ServerName serverC = randomServer(3).getServerName(); + List regionsOnServerA = randomRegions(3); + List regionsOnServerB = randomRegions(3); + List regionsOnServerC = randomRegions(3); + clusterState.put(serverA, regionsOnServerA); + clusterState.put(serverB, regionsOnServerB); + clusterState.put(serverC, regionsOnServerC); + // mock ClusterMetrics + Map serverMetricsMap = new TreeMap<>(); + serverMetricsMap.put(serverA, mockServerMetricsWithCpRequests(serverA, regionsOnServerA, 0)); + serverMetricsMap.put(serverB, mockServerMetricsWithCpRequests(serverB, regionsOnServerB, 0)); + serverMetricsMap.put(serverC, mockServerMetricsWithCpRequests(serverC, regionsOnServerC, 0)); + ClusterMetrics clusterStatus = mock(ClusterMetrics.class); + when(clusterStatus.getLiveServerMetrics()).thenReturn(serverMetricsMap); + loadBalancer.setClusterMetrics(clusterStatus); + + // CPRequestCostFunction are Rate based, So doing setClusterMetrics again + // this time, regions on serverA with more cpRequestCount load + // serverA : 1000,1000,1000 + // serverB : 0,0,0 + // serverC : 0,0,0 + // so should move two regions from serverA to serverB & serverC + serverMetricsMap = new TreeMap<>(); + serverMetricsMap.put(serverA, mockServerMetricsWithCpRequests(serverA, + regionsOnServerA, 1000)); + serverMetricsMap.put(serverB, mockServerMetricsWithCpRequests(serverB, regionsOnServerB, 0)); + serverMetricsMap.put(serverC, mockServerMetricsWithCpRequests(serverC, regionsOnServerC, 0)); + clusterStatus = mock(ClusterMetrics.class); + when(clusterStatus.getLiveServerMetrics()).thenReturn(serverMetricsMap); + loadBalancer.setClusterMetrics(clusterStatus); + + List plans = loadBalancer.balanceCluster(clusterState); + Set regionsMoveFromServerA = new HashSet<>(); + Set targetServers = new HashSet<>(); + for(RegionPlan plan : plans) { + if(plan.getSource().equals(serverA)) { + regionsMoveFromServerA.add(plan.getRegionInfo()); + targetServers.add(plan.getDestination()); + } + } + // should move 2 regions from serverA, one moves to serverB, the other moves to serverC + assertEquals(2, regionsMoveFromServerA.size()); + assertEquals(2, targetServers.size()); + assertTrue(regionsOnServerA.containsAll(regionsMoveFromServerA)); + // reset config + conf.setFloat("hbase.master.balancer.stochastic.cpRequestCost", 5f); + loadBalancer.setConf(conf); + } + @Test public void testKeepRegionLoad() throws Exception { @@ -126,6 +205,7 @@ public class TestStochasticLoadBalancer extends BalancerTestBase { RegionMetrics rl = mock(RegionMetrics.class); when(rl.getReadRequestCount()).thenReturn(0L); + when(rl.getCpRequestCount()).thenReturn(0L); when(rl.getWriteRequestCount()).thenReturn(0L); when(rl.getMemStoreSize()).thenReturn(Size.ZERO); when(rl.getStoreFileSize()).thenReturn(new Size(i, Size.Unit.MEGABYTE)); @@ -291,6 +371,7 @@ public class TestStochasticLoadBalancer extends BalancerTestBase { for (int i = 1; i < 5; i++) { BalancerRegionLoad regionLoad = mock(BalancerRegionLoad.class); when(regionLoad.getReadRequestsCount()).thenReturn(new Long(i)); + when(regionLoad.getCpRequestsCount()).thenReturn(new Long(i)); when(regionLoad.getStorefileSizeMB()).thenReturn(i); regionLoads.add(regionLoad); } @@ -302,6 +383,12 @@ public class TestStochasticLoadBalancer extends BalancerTestBase { // read requests are treated as a rate so the average rate here is simply 1 assertEquals(1, rateResult, 0.01); + StochasticLoadBalancer.CPRequestCostFunction cpCostFunction = + new StochasticLoadBalancer.CPRequestCostFunction(conf); + rateResult = cpCostFunction.getRegionLoadCost(regionLoads); + // coprocessor requests are treated as a rate so the average rate here is simply 1 + assertEquals(1, rateResult, 0.01); + StochasticLoadBalancer.StoreFileCostFunction storeFileCostFunction = new StochasticLoadBalancer.StoreFileCostFunction(conf); double result = storeFileCostFunction.getRegionLoadCost(regionLoads); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperStub.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperStub.java index d56823e0ddb..6537ec325ac 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperStub.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperStub.java @@ -110,6 +110,11 @@ public class MetricsRegionServerWrapperStub implements MetricsRegionServerWrappe return 997; } + @Override + public long getCpRequestsCount() { + return 998; + } + @Override public long getFilteredReadRequestsCount() { return 1997; diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/MetricsRegionWrapperStub.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/MetricsRegionWrapperStub.java index 524d03b8b50..b15ffc2bd9e 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/MetricsRegionWrapperStub.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/MetricsRegionWrapperStub.java @@ -100,6 +100,11 @@ public class MetricsRegionWrapperStub implements MetricsRegionWrapper { return 2; } + @Override + public long getCpRequestCount() { + return 108; + } + @Override public long getWriteRequestCount() { return 106; diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/MetricsTableWrapperStub.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/MetricsTableWrapperStub.java index ba333a5bb85..785115b2cbf 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/MetricsTableWrapperStub.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/MetricsTableWrapperStub.java @@ -31,6 +31,11 @@ public class MetricsTableWrapperStub implements MetricsTableWrapperAggregate { return 10; } + @Override + public long getCpRequestsCount(String table) { + return 15; + } + @Override public long getWriteRequestsCount(String table) { return 20; diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsRegion.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsRegion.java index 2119b911e7d..06b885e3495 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsRegion.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsRegion.java @@ -62,6 +62,9 @@ public class TestMetricsRegion { HELPER.assertGauge( "namespace_TestNS_table_MetricsRegionWrapperStub_region_DEADBEEF001_metric_memstoreSize", 103, agg); + HELPER.assertCounter( + "namespace_TestNS_table_MetricsRegionWrapperStub_region_DEADBEEF001_metric_cpRequestCount", + 108, agg); HELPER.assertCounter( "namespace_TestNS_table_MetricsRegionWrapperStub_region_DEADBEEF001_metric_" + "filteredReadRequestCount", @@ -83,6 +86,9 @@ public class TestMetricsRegion { HELPER.assertGauge( "namespace_TestNS_table_MetricsRegionWrapperStub_region_DEADBEEF001_metric_memstoreSize", 103, agg); + HELPER.assertCounter( + "namespace_TestNS_table_MetricsRegionWrapperStub_region_DEADBEEF001_metric_cpRequestCount", + 108, agg); HELPER.assertCounter( "namespace_TestNS_table_MetricsRegionWrapperStub_region_DEADBEEF001_metric_" + "filteredReadRequestCount", diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsRegionServer.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsRegionServer.java index bfc0b63572f..369c2068fcb 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsRegionServer.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsRegionServer.java @@ -84,6 +84,7 @@ public class TestMetricsRegionServer { + HELPER.getCounter("writeRequestCount", serverSource), serverSource); HELPER.assertCounter("readRequestCount", 997, serverSource); + HELPER.assertCounter("cpRequestCount", 998, serverSource); HELPER.assertCounter("filteredReadRequestCount", 1997, serverSource); HELPER.assertCounter("writeRequestCount", 707, serverSource); HELPER.assertCounter("checkMutateFailedCount", 401, serverSource); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsTableAggregate.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsTableAggregate.java index e3bac65b1e1..969358d275d 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsTableAggregate.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsTableAggregate.java @@ -43,11 +43,12 @@ public class TestMetricsTableAggregate { String tableName = "testTableMetrics"; MetricsTableWrapperStub tableWrapper = new MetricsTableWrapperStub(tableName); CompatibilitySingletonFactory.getInstance(MetricsRegionServerSourceFactory.class) - .createTable(tableName, tableWrapper); + .createTable(tableName, tableWrapper); MetricsTableAggregateSource agg = CompatibilitySingletonFactory .getInstance(MetricsRegionServerSourceFactory.class).getTableAggregate(); HELPER.assertCounter("Namespace_default_table_testTableMetrics_metric_readRequestCount", 10, agg); + HELPER.assertCounter("Namespace_default_table_testTableMetrics_metric_cpRequestCount", 15, agg); HELPER.assertCounter("Namespace_default_table_testTableMetrics_metric_writeRequestCount", 20, agg); HELPER.assertCounter("Namespace_default_table_testTableMetrics_metric_totalRequestCount", 30, agg);