HBASE-20672 New metrics ReadRequestRate and WriteRequestRate Signed-off-by: Andrew Purtell <apurt...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/e5618a66 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/e5618a66 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/e5618a66 Branch: refs/heads/branch-1 Commit: e5618a6674163a5fddd51064c22e67a32fd4bee5 Parents: 15ed2e8 Author: Ankit <jain.an...@salesforce.com> Authored: Thu Jun 7 15:03:03 2018 -0700 Committer: Andrew Purtell <apurt...@apache.org> Committed: Thu Jul 19 15:36:01 2018 -0700 ---------------------------------------------------------------------- .../regionserver/MetricsRegionServerSource.java | 6 ++++ .../MetricsRegionServerWrapper.java | 10 +++++++ .../MetricsRegionServerSourceImpl.java | 4 +++ .../MetricsRegionServerWrapperImpl.java | 29 ++++++++++++++++++++ .../MetricsRegionServerWrapperStub.java | 10 +++++++ 5 files changed, 59 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/e5618a66/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSource.java ---------------------------------------------------------------------- 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 b72deb8..affd267 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 @@ -253,6 +253,12 @@ public interface MetricsRegionServerSource extends BaseSource, JvmPauseMonitorSo String WRITE_REQUEST_COUNT = "writeRequestCount"; String WRITE_REQUEST_COUNT_DESC = "Number of mutation requests this region server has answered."; + String READ_REQUEST_RATE = "readRequestRate"; + String READ_REQUEST_RATE_DESC = + "Rate of answering the read requests by this region server per second."; + String WRITE_REQUEST_RATE = "writeRequestRate"; + String WRITE_REQUEST_RATE_DESC = + "Rate of answering the mutation requests by this region server per second."; String CHECK_MUTATE_FAILED_COUNT = "checkMutateFailedCount"; String CHECK_MUTATE_FAILED_COUNT_DESC = "Number of Check and Mutate calls that failed the checks."; http://git-wip-us.apache.org/repos/asf/hbase/blob/e5618a66/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapper.java ---------------------------------------------------------------------- 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 3344dce..5cbdc64 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 @@ -133,6 +133,16 @@ public interface MetricsRegionServerWrapper { long getWriteRequestsCount(); /** + * Get the rate of read requests per second to regions hosted on this region server. + */ + double getReadRequestsRate(); + + /** + * Get the rate of write requests per second to regions hosted on this region server. + */ + double getWriteRequestsRate(); + + /** * Get the number of CAS operations that failed. */ long getCheckAndMutateChecksFailed(); http://git-wip-us.apache.org/repos/asf/hbase/blob/e5618a66/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSourceImpl.java ---------------------------------------------------------------------- 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 208188e..8833026 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 @@ -352,6 +352,10 @@ public class MetricsRegionServerSourceImpl .addGauge(Interns.info(RS_START_TIME_NAME, RS_START_TIME_DESC), rsWrap.getStartCode()) .addGauge(Interns.info(AVERAGE_REGION_SIZE, AVERAGE_REGION_SIZE_DESC), rsWrap.getAverageRegionSize()) + .addGauge(Interns.info(READ_REQUEST_RATE, READ_REQUEST_RATE_DESC), + rsWrap.getReadRequestsRate()) + .addGauge(Interns.info(WRITE_REQUEST_RATE, WRITE_REQUEST_RATE_DESC), + rsWrap.getWriteRequestsRate()) .addCounter(Interns.info(TOTAL_REQUEST_COUNT, TOTAL_REQUEST_COUNT_DESC), rsWrap.getTotalRequestCount()) .addCounter(Interns.info(TOTAL_ROW_ACTION_REQUEST_COUNT, TOTAL_ROW_ACTION_REQUEST_COUNT_DESC), http://git-wip-us.apache.org/repos/asf/hbase/blob/e5618a66/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperImpl.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperImpl.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperImpl.java index 9ba6cc0..cb2e2d7 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperImpl.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperImpl.java @@ -65,6 +65,8 @@ class MetricsRegionServerWrapperImpl private volatile double requestsPerSecond = 0.0; private volatile long readRequestsCount = 0; private volatile long writeRequestsCount = 0; + private volatile double readRequestsRate = 0; + private volatile double writeRequestsRate = 0; private volatile long checkAndMutateChecksFailed = 0; private volatile long checkAndMutateChecksPassed = 0; private volatile long storefileIndexSize = 0; @@ -464,6 +466,16 @@ class MetricsRegionServerWrapperImpl } @Override + public double getReadRequestsRate() { + return readRequestsRate; + } + + @Override + public double getWriteRequestsRate() { + return writeRequestsRate; + } + + @Override public long getRpcGetRequestsCount() { return regionServer.rpcServices.rpcGetRequestCount.get(); } @@ -575,6 +587,8 @@ class MetricsRegionServerWrapperImpl private long lastRan = 0; private long lastRequestCount = 0; + private long lastReadRequestsCount = 0; + private long lastWriteRequestsCount = 0; @Override synchronized public void run() { @@ -687,6 +701,21 @@ class MetricsRegionServerWrapperImpl requestsPerSecond = (currentRequestCount - lastRequestCount) / ((currentTime - lastRan) / 1000.0); lastRequestCount = currentRequestCount; + + long intervalReadRequestsCount = tempReadRequestsCount - lastReadRequestsCount; + long intervalWriteRequestsCount = tempWriteRequestsCount - lastWriteRequestsCount; + + double readRequestsRatePerMilliSecond = ((double)intervalReadRequestsCount/ + (double)period); + double writeRequestsRatePerMilliSecond = ((double)intervalWriteRequestsCount/ + (double)period); + + readRequestsRate = readRequestsRatePerMilliSecond * 1000.0; + writeRequestsRate = writeRequestsRatePerMilliSecond * 1000.0; + + lastReadRequestsCount = tempReadRequestsCount; + lastWriteRequestsCount = tempWriteRequestsCount; + } lastRan = currentTime; http://git-wip-us.apache.org/repos/asf/hbase/blob/e5618a66/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperStub.java ---------------------------------------------------------------------- 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 21d06cf..3be2604 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 @@ -101,6 +101,11 @@ public class MetricsRegionServerWrapperStub implements MetricsRegionServerWrappe } @Override + public double getReadRequestsRate() { + return 10.0; + } + + @Override public long getTotalRowActionRequestCount() { return getReadRequestsCount() + getWriteRequestsCount(); } @@ -116,6 +121,11 @@ public class MetricsRegionServerWrapperStub implements MetricsRegionServerWrappe } @Override + public double getWriteRequestsRate() { + return 10.0; + } + + @Override public long getRpcGetRequestsCount() { return 521; }