From 4705b4752b4046b7d1954afd6711948450515980 Mon Sep 17 00:00:00 2001 From: xijiawen <15891721997@163.com> Date: Fri, 8 Jan 2021 18:58:30 +0800 Subject: [PATCH] HBASE-25434 SlowDelete & SlowPut metric value should use updateDelete & updatePut (#2837) Signed-off-by: Zheng Wang (cherry picked from commit 7d70141b90d188d69e259ad5de435dad4eed5bf8) --- .../hbase/regionserver/MetricsRegionServer.java | 12 ++++++------ .../hbase/regionserver/TestMetricsRegionServer.java | 10 ++++++---- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServer.java index 68b08902d4b..7a765923c79 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServer.java @@ -113,9 +113,6 @@ public class MetricsRegionServer { if (tableMetrics != null && tn != null) { tableMetrics.updatePutBatch(tn, t); } - if (t > slowMetricTime) { - serverSource.incrSlowPut(); - } serverSource.updatePutBatch(t); } @@ -123,6 +120,9 @@ public class MetricsRegionServer { if (tableMetrics != null && tn != null) { tableMetrics.updatePut(tn, t); } + if (t > slowMetricTime) { + serverSource.incrSlowPut(); + } serverSource.updatePut(t); userAggregate.updatePut(t); } @@ -131,6 +131,9 @@ public class MetricsRegionServer { if (tableMetrics != null && tn != null) { tableMetrics.updateDelete(tn, t); } + if (t > slowMetricTime) { + serverSource.incrSlowDelete(); + } serverSource.updateDelete(t); userAggregate.updateDelete(t); } @@ -139,9 +142,6 @@ public class MetricsRegionServer { if (tableMetrics != null && tn != null) { tableMetrics.updateDeleteBatch(tn, t); } - if (t > slowMetricTime) { - serverSource.incrSlowDelete(); - } serverSource.updateDeleteBatch(t); } 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 276da2bcd46..e8d7bfe4d75 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 @@ -149,6 +149,8 @@ public class TestMetricsRegionServer { for (int i=0; i < 17; i ++) { rsm.updatePut(null, 17); rsm.updateDelete(null, 17); + rsm.updatePut(null, 1006); + rsm.updateDelete(null, 1003); rsm.updateCheckAndDelete(null, 17); rsm.updateCheckAndPut(null, 17); rsm.updateCheckAndMutate(null, 17); @@ -159,17 +161,17 @@ public class TestMetricsRegionServer { HELPER.assertCounter("getNumOps", 28, serverSource); HELPER.assertCounter("incrementNumOps", 30, serverSource); HELPER.assertCounter("putBatchNumOps", 32, serverSource); - HELPER.assertCounter("putNumOps", 17, serverSource); - HELPER.assertCounter("deleteNumOps", 17, serverSource); + HELPER.assertCounter("putNumOps", 34, serverSource); + HELPER.assertCounter("deleteNumOps", 34, serverSource); HELPER.assertCounter("checkAndDeleteNumOps", 17, serverSource); HELPER.assertCounter("checkAndPutNumOps", 17, serverSource); HELPER.assertCounter("checkAndMutateNumOps", 17, serverSource); HELPER.assertCounter("slowAppendCount", 12, serverSource); - HELPER.assertCounter("slowDeleteCount", 13, serverSource); + HELPER.assertCounter("slowDeleteCount", 17, serverSource); HELPER.assertCounter("slowGetCount", 14, serverSource); HELPER.assertCounter("slowIncrementCount", 15, serverSource); - HELPER.assertCounter("slowPutCount", 16, serverSource); + HELPER.assertCounter("slowPutCount", 17, serverSource); } @Test