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 b27696c1dfc..b86a8eb2a49 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 @@ -118,6 +118,16 @@ public interface MetricsRegionServerSource extends BaseSource { */ void updateSplitTime(long t); + /** + * Increment number of a requested splits + */ + void incrSplitRequest(); + + /** + * Increment number of successful splits + */ + void incrSplitSuccess(); + /** * Update the flush time histogram * @param t time it took, in milliseconds @@ -170,6 +180,8 @@ public interface MetricsRegionServerSource extends BaseSource { String PERCENT_FILES_LOCAL = "percentFilesLocal"; String PERCENT_FILES_LOCAL_DESC = "The percent of HFiles that are stored on the local hdfs data node."; + String SPLIT_QUEUE_LENGTH = "splitQueueLength"; + String SPLIT_QUEUE_LENGTH_DESC = "Length of the queue for splits."; String COMPACTION_QUEUE_LENGTH = "compactionQueueLength"; String LARGE_COMPACTION_QUEUE_LENGTH = "largeCompactionQueueLength"; String SMALL_COMPACTION_QUEUE_LENGTH = "smallCompactionQueueLength"; @@ -257,5 +269,9 @@ public interface MetricsRegionServerSource extends BaseSource { + "larger than blockingMemStoreSize"; String SPLIT_KEY = "splitTime"; + String SPLIT_REQUEST_KEY = "splitRequestCount"; + String SPLIT_REQUEST_DESC = "Number of splits requested"; + String SPLIT_SUCCESS_KEY = "splitSuccessCounnt"; + String SPLIT_SUCCESS_DESC = "Number of successfully executed splits"; String FLUSH_KEY = "flushTime"; } 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 0f62dc68188..9634be7e963 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 @@ -153,6 +153,11 @@ public interface MetricsRegionServerWrapper { */ int getPercentFileLocal(); + /** + * Get the size of the split queue + */ + int getSplitQueueSize(); + /** * Get the size of the compaction queue */ 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 4cd83382499..2c1dcd325fe 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 @@ -48,6 +48,8 @@ public class MetricsRegionServerSourceImpl private final MutableCounterLong slowGet; private final MutableCounterLong slowIncrement; private final MutableCounterLong slowAppend; + private final MutableCounterLong splitRequest; + private final MutableCounterLong splitSuccess; private final MetricHistogram splitTimeHisto; private final MetricHistogram flushTimeHisto; @@ -83,6 +85,9 @@ public class MetricsRegionServerSourceImpl splitTimeHisto = getMetricsRegistry().newHistogram(SPLIT_KEY); flushTimeHisto = getMetricsRegistry().newHistogram(FLUSH_KEY); + + splitRequest = getMetricsRegistry().newCounter(SPLIT_REQUEST_KEY, SPLIT_REQUEST_DESC, 0l); + splitSuccess = getMetricsRegistry().newCounter(SPLIT_SUCCESS_KEY, SPLIT_SUCCESS_DESC, 0l); } @Override @@ -140,6 +145,16 @@ public class MetricsRegionServerSourceImpl slowAppend.incr(); } + @Override + public void incrSplitRequest() { + splitRequest.incr(); + } + + @Override + public void incrSplitSuccess() { + splitSuccess.incr(); + } + @Override public void updateSplitTime(long t) { splitTimeHisto.add(t); @@ -198,6 +213,8 @@ public class MetricsRegionServerSourceImpl rsWrap.getDataInMemoryWithoutWAL()) .addGauge(Interns.info(PERCENT_FILES_LOCAL, PERCENT_FILES_LOCAL_DESC), rsWrap.getPercentFileLocal()) + .addGauge(Interns.info(SPLIT_QUEUE_LENGTH, SPLIT_QUEUE_LENGTH_DESC), + rsWrap.getSplitQueueSize()) .addGauge(Interns.info(COMPACTION_QUEUE_LENGTH, COMPACTION_QUEUE_LENGTH_DESC), rsWrap.getCompactionQueueSize()) .addGauge(Interns.info(FLUSH_QUEUE_LENGTH, FLUSH_QUEUE_LENGTH_DESC), diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactSplitThread.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactSplitThread.java index d9a9a846c6f..555417ae99e 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactSplitThread.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactSplitThread.java @@ -413,6 +413,9 @@ public class CompactSplitThread implements CompactionRequestor, PropagatingConfi return shortCompactions.getQueue().size(); } + public int getSplitQueueSize() { + return splits.getQueue().size(); + } private boolean shouldSplitRegion() { return (regionSplitLimit > server.getNumberOfOnlineRegions()); 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 4596edc4345..c3bf97e0708 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 @@ -99,6 +99,14 @@ public class MetricsRegionServer { serverSource.updateSplitTime(t); } + public void incrSplitRequest() { + serverSource.incrSplitRequest(); + } + + public void incrSplitSuccess() { + serverSource.incrSplitSuccess(); + } + public void updateFlushTime(long t) { serverSource.updateFlushTime(t); } 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 d8ad6fe5d89..5e5590d47be 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 @@ -178,6 +178,14 @@ class MetricsRegionServerWrapperImpl return regionServer.rpcServices.requestCount.get(); } + @Override + public int getSplitQueueSize() { + if (this.regionServer.compactSplitThread == null) { + return 0; + } + return this.regionServer.compactSplitThread.getSplitQueueSize(); + } + @Override public int getCompactionQueueSize() { //The thread could be zero. if so assume there is no queue. diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SplitRequest.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SplitRequest.java index 887b6ab7ec7..1dfe4adac4d 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SplitRequest.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SplitRequest.java @@ -62,6 +62,7 @@ class SplitRequest implements Runnable { return; } boolean success = false; + server.metricsRegionServer.incrSplitRequest(); long startTime = EnvironmentEdgeManager.currentTime(); SplitTransaction st = new SplitTransaction(parent, midKey); try { @@ -129,6 +130,7 @@ class SplitRequest implements Runnable { // Update regionserver metrics with the split transaction total running time server.metricsRegionServer.updateSplitTime(endTime - startTime); if (success) { + server.metricsRegionServer.incrSplitSuccess(); // Log success LOG.info("Region split, hbase:meta updated, and report to master. Parent=" + parent.getRegionNameAsString() + ", new regions: " 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 e936789350e..852d319e2fd 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 @@ -255,4 +255,9 @@ public class MetricsRegionServerWrapperStub implements MetricsRegionServerWrappe public long getBlockedRequestsCount() { return 0; } + + @Override + public int getSplitQueueSize() { + return 0; + } }