HBASE-26397 Display the excluded datanodes on regionserver UI (#3990)

Signed-off-by: Duo Zhang <zhangduo@apache.org>
This commit is contained in:
Xiaolin Ha 2022-01-10 12:53:05 +08:00 committed by GitHub
parent 3ec3df5887
commit 803afee777
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 0 deletions

View File

@ -18,6 +18,7 @@
package org.apache.hadoop.hbase.regionserver; package org.apache.hadoop.hbase.regionserver;
import java.util.List;
import org.apache.yetus.audience.InterfaceAudience; import org.apache.yetus.audience.InterfaceAudience;
/** /**
@ -80,6 +81,11 @@ public interface MetricsRegionServerWrapper {
*/ */
long getWALFileSize(); long getWALFileSize();
/**
* Get the excluded datanodes in the cache of this region server.
*/
List<String> getWALExcludeDNs();
/** /**
* Get the number of WAL files with slow appends for this region server. * Get the number of WAL files with slow appends for this region server.
*/ */

View File

@ -149,11 +149,17 @@ MetricsRegionServerWrapper mWrap;
<tr> <tr>
<th>Num. WAL Files</th> <th>Num. WAL Files</th>
<th>Size. WAL Files</th> <th>Size. WAL Files</th>
<th>WAL exclude DNs</th>
</tr> </tr>
</tr> </tr>
<tr> <tr>
<td><% mWrap.getNumWALFiles() %></td> <td><% mWrap.getNumWALFiles() %></td>
<td><% TraditionalBinaryPrefix.long2String(mWrap.getWALFileSize(), "B", 1) %></td> <td><% TraditionalBinaryPrefix.long2String(mWrap.getWALFileSize(), "B", 1) %></td>
<td>
<%for String exclude: mWrap.getWALExcludeDNs() %>
<% exclude %><br>
</%for>
</td>
</tr> </tr>
</table> </table>
</%def> </%def>

View File

@ -20,6 +20,7 @@ package org.apache.hadoop.hbase.regionserver;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.OptionalDouble; import java.util.OptionalDouble;
@ -27,6 +28,7 @@ import java.util.OptionalLong;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.hadoop.hbase.CompatibilitySingletonFactory; import org.apache.hadoop.hbase.CompatibilitySingletonFactory;
import org.apache.hadoop.hbase.HConstants; 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.client.RegionInfo;
import org.apache.hadoop.hbase.io.ByteBuffAllocator; import org.apache.hadoop.hbase.io.ByteBuffAllocator;
import org.apache.hadoop.hbase.io.FSDataInputStreamWrapper; 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.BlockCache;
import org.apache.hadoop.hbase.io.hfile.CacheStats; import org.apache.hadoop.hbase.io.hfile.CacheStats;
import org.apache.hadoop.hbase.io.hfile.CombinedBlockCache; import org.apache.hadoop.hbase.io.hfile.CombinedBlockCache;
@ -130,10 +133,13 @@ class MetricsRegionServerWrapperImpl
*/ */
private DFSHedgedReadMetrics dfsHedgedReadMetrics; private DFSHedgedReadMetrics dfsHedgedReadMetrics;
private final ExcludeDatanodeManager excludeDatanodeManager;
public MetricsRegionServerWrapperImpl(final HRegionServer regionServer) { public MetricsRegionServerWrapperImpl(final HRegionServer regionServer) {
this.regionServer = regionServer; this.regionServer = regionServer;
initBlockCache(); initBlockCache();
initMobFileCache(); initMobFileCache();
this.excludeDatanodeManager = this.regionServer.getWalFactory().getExcludeDatanodeManager();
this.period = regionServer.getConfiguration().getLong(HConstants.REGIONSERVER_METRICS_PERIOD, this.period = regionServer.getConfiguration().getLong(HConstants.REGIONSERVER_METRICS_PERIOD,
HConstants.DEFAULT_REGIONSERVER_METRICS_PERIOD); HConstants.DEFAULT_REGIONSERVER_METRICS_PERIOD);
@ -398,6 +404,17 @@ class MetricsRegionServerWrapperImpl
return walFileSize; return walFileSize;
} }
@Override
public List<String> getWALExcludeDNs() {
if (excludeDatanodeManager == null) {
return Collections.emptyList();
}
return excludeDatanodeManager.getExcludeDNs().entrySet()
.stream()
.map(e -> e.getKey().toString() + ", " + e.getValue())
.collect(Collectors.toList());
}
@Override @Override
public long getNumWALSlowAppend() { public long getNumWALSlowAppend() {
return metricsWALSource.getSlowAppendCount(); return metricsWALSource.getSlowAppendCount();

View File

@ -18,6 +18,9 @@
package org.apache.hadoop.hbase.regionserver; package org.apache.hadoop.hbase.regionserver;
import java.util.Collections;
import java.util.List;
public class MetricsRegionServerWrapperStub implements MetricsRegionServerWrapper { public class MetricsRegionServerWrapperStub implements MetricsRegionServerWrapper {
@Override @Override
@ -375,6 +378,11 @@ public class MetricsRegionServerWrapperStub implements MetricsRegionServerWrappe
return 1024000; return 1024000;
} }
@Override
public List<String> getWALExcludeDNs() {
return Collections.emptyList();
}
@Override @Override
public long getNumWALSlowAppend() { public long getNumWALSlowAppend() {
return 0; return 0;