HBASE-672 Sort regions in the regionserver UI

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@664288 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2008-06-07 06:23:44 +00:00
parent 9e2352ae39
commit 5582a05745
2 changed files with 17 additions and 3 deletions

View File

@ -37,6 +37,7 @@ import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.concurrent.BlockingQueue;
@ -1308,6 +1309,19 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
return Collections.unmodifiableCollection(onlineRegions.values());
}
/**
* @return The HRegionInfos from online regions sorted
*/
public SortedSet<HRegionInfo> getSortedOnlineRegionInfos() {
SortedSet<HRegionInfo> result = new TreeSet<HRegionInfo>();
synchronized(this.onlineRegions) {
for (HRegion r: this.onlineRegions.values()) {
result.add(r.getRegionInfo());
}
}
return result;
}
/**
* @return A new Map of online regions sorted by region size with the first
* entry being the biggest.

View File

@ -9,7 +9,7 @@
import="org.apache.hadoop.hbase.HRegionInfo" %><%
HRegionServer regionServer = (HRegionServer)getServletContext().getAttribute(HRegionServer.REGIONSERVER);
HServerInfo serverInfo = regionServer.getServerInfo();
Collection<HRegion> onlineRegions = regionServer.getOnlineRegions();
Collection<HRegionInfo> onlineRegions = regionServer.getSortedOnlineRegionInfos();
int interval = regionServer.getConfiguration().getInt("hbase.regionserver.msginterval", 3000)/1000;
%><?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
@ -38,8 +38,8 @@
<% if (onlineRegions != null && onlineRegions.size() > 0) { %>
<table>
<tr><th>Region Name</th><th>Encoded Name</th><th>Start Key</th><th>End Key</th></tr>
<% for (HRegion r: onlineRegions) { %>
<tr><td><%= Bytes.toString(r.getRegionName()) %></td><td><%= r.getRegionInfo().getEncodedName() %></td>
<% for (HRegionInfo r: onlineRegions) { %>
<tr><td><%= r.getRegionNameAsString() %></td><td><%= r.getEncodedName() %></td>
<td><%= Bytes.toString(r.getStartKey()) %></td><td><%= Bytes.toString(r.getEndKey()) %></td></tr>
<% } %>
</table>