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 69212225e69..02dec8d8583 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
@@ -70,16 +70,21 @@ public interface MetricsRegionServerWrapper {
/**
* Get the number of WAL files of this region server.
*/
- public long getNumWALFiles();
+ long getNumWALFiles();
/**
* Get the size of WAL files of this region server.
*/
- public long getWALFileSize();
-
+ long getWALFileSize();
+
/**
- * Get the number of store files hosted on this region server.
+ * Get the number of WAL files with slow appends for this region server.
*/
+ long getNumWALSlowAppend();
+
+ /**
+ * Get the number of store files hosted on this region server.
+ */
long getNumStoreFiles();
/**
diff --git a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/wal/MetricsWALSource.java b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/wal/MetricsWALSource.java
index f8c746fff16..c6dc731c823 100644
--- a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/wal/MetricsWALSource.java
+++ b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/wal/MetricsWALSource.java
@@ -92,4 +92,5 @@ public interface MetricsWALSource extends BaseSource {
void incrementLowReplicationLogRoll();
+ long getSlowAppendCount();
}
diff --git a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/wal/MetricsWALSourceImpl.java b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/wal/MetricsWALSourceImpl.java
index 36c357109bd..758378023c2 100644
--- a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/wal/MetricsWALSourceImpl.java
+++ b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/wal/MetricsWALSourceImpl.java
@@ -98,4 +98,9 @@ public class MetricsWALSourceImpl extends BaseSourceImpl implements MetricsWALSo
public void incrementLowReplicationLogRoll() {
lowReplicationLogRollRequested.incr();
}
+
+ @Override
+ public long getSlowAppendCount() {
+ return slowAppendCount.value();
+ }
}
diff --git a/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/ServerMetricsTmpl.jamon b/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/ServerMetricsTmpl.jamon
index a86a4ea1cf4..113bee1aa68 100644
--- a/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/ServerMetricsTmpl.jamon
+++ b/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/ServerMetricsTmpl.jamon
@@ -84,7 +84,7 @@ java.lang.management.ManagementFactory;
<% mWrap.getNumOnlineRegions() %> |
<% mWrap.getPercentFileLocal() %> |
<% mWrap.getPercentFileLocalSecondaryRegions() %> |
- <% 0 %> |
+ <% mWrap.getNumWALSlowAppend() %> |
%def>
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 108ca6cfd57..f3e89163cb5 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
@@ -37,6 +37,7 @@ import org.apache.hadoop.hbase.io.hfile.CacheConfig;
import org.apache.hadoop.hbase.io.hfile.CacheStats;
import org.apache.hadoop.hbase.mob.MobCacheConfig;
import org.apache.hadoop.hbase.mob.MobFileCache;
+import org.apache.hadoop.hbase.regionserver.wal.MetricsWALSource;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.util.FSUtils;
import org.apache.hadoop.hbase.wal.WALProvider;
@@ -54,6 +55,7 @@ class MetricsRegionServerWrapperImpl
private static final Log LOG = LogFactory.getLog(MetricsRegionServerWrapperImpl.class);
private final HRegionServer regionServer;
+ private final MetricsWALSource metricsWALSource;
private BlockCache blockCache;
private MobFileCache mobFileCache;
@@ -121,6 +123,7 @@ class MetricsRegionServerWrapperImpl
this.runnable = new RegionServerMetricsWrapperRunnable();
this.executor.scheduleWithFixedDelay(this.runnable, this.period, this.period,
TimeUnit.MILLISECONDS);
+ this.metricsWALSource = CompatibilitySingletonFactory.getInstance(MetricsWALSource.class);
try {
this.dfsHedgedReadMetrics = FSUtils.getDFSHedgedReadMetrics(regionServer.getConfiguration());
@@ -374,6 +377,11 @@ class MetricsRegionServerWrapperImpl
public long getWALFileSize() {
return walFileSize;
}
+
+ @Override
+ public long getNumWALSlowAppend() {
+ return metricsWALSource.getSlowAppendCount();
+ }
@Override
public long getNumStoreFiles() {
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 f450f0157fc..0d932841b2c 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
@@ -235,6 +235,11 @@ public class MetricsRegionServerWrapperStub implements MetricsRegionServerWrappe
return 1024000;
}
+ @Override
+ public long getNumWALSlowAppend() {
+ return 0;
+ }
+
@Override
public long getFlushedCellsCount() {
return 100000000;
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestMetricsWAL.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestMetricsWAL.java
index d9183d0a8cb..ba6915b636e 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestMetricsWAL.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestMetricsWAL.java
@@ -26,6 +26,7 @@ import org.junit.experimental.categories.Category;
import java.util.concurrent.TimeUnit;
+import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -53,4 +54,16 @@ public class TestMetricsWAL {
metricsWAL.postSync(nanos, 1);
verify(source, times(1)).incrementSyncTime(145);
}
+
+ @Test
+ public void testSlowAppend() throws Exception {
+ MetricsWALSource source = new MetricsWALSourceImpl();
+ MetricsWAL metricsWAL = new MetricsWAL(source);
+ // One not so slow append (< 1000)
+ metricsWAL.postAppend(1, 900);
+ // Two slow appends (> 1000)
+ metricsWAL.postAppend(1, 1010);
+ metricsWAL.postAppend(1, 2000);
+ assertEquals(2, source.getSlowAppendCount());
+ }
}
\ No newline at end of file