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 e4305330b67..32c73d65321 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 @@ -18,6 +18,7 @@ package org.apache.hadoop.hbase.regionserver; +import java.util.List; import org.apache.yetus.audience.InterfaceAudience; /** @@ -80,6 +81,11 @@ public interface MetricsRegionServerWrapper { */ long getWALFileSize(); + /** + * Get the excluded datanodes in the cache of this region server. + */ + List getWALExcludeDNs(); + /** * Get the number of WAL files with slow appends for this region server. */ 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 c86689235bd..806415e989c 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 @@ -149,11 +149,17 @@ MetricsRegionServerWrapper mWrap; Num. WAL Files Size. WAL Files + WAL exclude DNs <% mWrap.getNumWALFiles() %> <% TraditionalBinaryPrefix.long2String(mWrap.getWALFileSize(), "B", 1) %> + + <%for String exclude: mWrap.getWALExcludeDNs() %> + <% exclude %>
+ + 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 c33807a683d..8802715248c 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 @@ -20,6 +20,7 @@ package org.apache.hadoop.hbase.regionserver; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.OptionalDouble; @@ -27,6 +28,7 @@ import java.util.OptionalLong; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; import org.apache.commons.lang3.StringUtils; import org.apache.hadoop.hbase.CompatibilitySingletonFactory; import org.apache.hadoop.hbase.HConstants; @@ -35,6 +37,7 @@ import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.client.RegionInfo; import org.apache.hadoop.hbase.io.ByteBuffAllocator; import org.apache.hadoop.hbase.io.FSDataInputStreamWrapper; +import org.apache.hadoop.hbase.io.asyncfs.monitor.ExcludeDatanodeManager; import org.apache.hadoop.hbase.io.hfile.BlockCache; import org.apache.hadoop.hbase.io.hfile.CacheStats; import org.apache.hadoop.hbase.io.hfile.CombinedBlockCache; @@ -130,10 +133,13 @@ class MetricsRegionServerWrapperImpl */ private DFSHedgedReadMetrics dfsHedgedReadMetrics; + private final ExcludeDatanodeManager excludeDatanodeManager; + public MetricsRegionServerWrapperImpl(final HRegionServer regionServer) { this.regionServer = regionServer; initBlockCache(); initMobFileCache(); + this.excludeDatanodeManager = this.regionServer.getWalFactory().getExcludeDatanodeManager(); this.period = regionServer.getConfiguration().getLong(HConstants.REGIONSERVER_METRICS_PERIOD, HConstants.DEFAULT_REGIONSERVER_METRICS_PERIOD); @@ -398,6 +404,17 @@ class MetricsRegionServerWrapperImpl return walFileSize; } + @Override + public List getWALExcludeDNs() { + if (excludeDatanodeManager == null) { + return Collections.emptyList(); + } + return excludeDatanodeManager.getExcludeDNs().entrySet() + .stream() + .map(e -> e.getKey().toString() + ", " + e.getValue()) + .collect(Collectors.toList()); + } + @Override public long getNumWALSlowAppend() { return metricsWALSource.getSlowAppendCount(); 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 ac361997bb1..ae9666dd303 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 @@ -18,6 +18,9 @@ package org.apache.hadoop.hbase.regionserver; +import java.util.Collections; +import java.util.List; + public class MetricsRegionServerWrapperStub implements MetricsRegionServerWrapper { @Override @@ -375,6 +378,11 @@ public class MetricsRegionServerWrapperStub implements MetricsRegionServerWrappe return 1024000; } + @Override + public List getWALExcludeDNs() { + return Collections.emptyList(); + } + @Override public long getNumWALSlowAppend() { return 0;