HBASE-1290 table.jsp either 500s out or doesnt list the regions

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@758491 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andrew Kyle Purtell 2009-03-26 01:14:15 +00:00
parent 18f891cde5
commit f73bd2ce23
4 changed files with 93 additions and 42 deletions

View File

@ -61,6 +61,8 @@ Release 0.20.0 - Unreleased
HBASE-1283 thrift's package descrpition needs to update for start/stop HBASE-1283 thrift's package descrpition needs to update for start/stop
procedure (Rong-en Fan via Stack) procedure (Rong-en Fan via Stack)
HBASE-1284 drop table drops all disabled tables HBASE-1284 drop table drops all disabled tables
HBASE-1290 table.jsp either 500s out or doesnt list the regions (Ryan
Rawson via Andrew Purtell)
IMPROVEMENTS IMPROVEMENTS
HBASE-1089 Add count of regions on filesystem to master UI; add percentage HBASE-1089 Add count of regions on filesystem to master UI; add percentage

View File

@ -320,6 +320,10 @@ public class HMaster extends Thread implements HConstants, HMasterInterface,
return serverManager.getServersToServerInfo(); return serverManager.getServersToServerInfo();
} }
public Map<HServerAddress, HServerInfo> getServerAddressToServerInfo() {
return serverManager.getServerAddressToServerInfo();
}
/** /**
* @return Read-only map of servers to load. * @return Read-only map of servers to load.
*/ */

View File

@ -70,6 +70,9 @@ class ServerManager implements HConstants {
final Map<String, HServerInfo> serversToServerInfo = final Map<String, HServerInfo> serversToServerInfo =
new ConcurrentHashMap<String, HServerInfo>(); new ConcurrentHashMap<String, HServerInfo>();
final Map<HServerAddress, HServerInfo> serverAddressToServerInfo =
new ConcurrentHashMap<HServerAddress, HServerInfo>();
/** /**
* Set of known dead servers. On znode expiration, servers are added here. * Set of known dead servers. On znode expiration, servers are added here.
* This is needed in case of a network partitioning where the server's lease * This is needed in case of a network partitioning where the server's lease
@ -124,7 +127,7 @@ class ServerManager implements HConstants {
deadServers.contains(serverName)) { deadServers.contains(serverName)) {
throw new Leases.LeaseStillHeldException(serverName); throw new Leases.LeaseStillHeldException(serverName);
} }
Watcher watcher = new ServerExpirer(serverName); Watcher watcher = new ServerExpirer(serverName, info.getServerAddress());
zooKeeperWrapper.updateRSLocationGetWatch(info, watcher); zooKeeperWrapper.updateRSLocationGetWatch(info, watcher);
LOG.info("Received start message from: " + serverName); LOG.info("Received start message from: " + serverName);
@ -162,6 +165,7 @@ class ServerManager implements HConstants {
load = new HServerLoad(); load = new HServerLoad();
info.setLoad(load); info.setLoad(load);
serversToServerInfo.put(serverName, info); serversToServerInfo.put(serverName, info);
serverAddressToServerInfo.put(info.getServerAddress(), info);
serversToLoad.put(serverName, load); serversToLoad.put(serverName, load);
synchronized (loadToServers) { synchronized (loadToServers) {
Set<String> servers = loadToServers.get(load); Set<String> servers = loadToServers.get(load);
@ -256,7 +260,7 @@ class ServerManager implements HConstants {
} }
synchronized (serversToServerInfo) { synchronized (serversToServerInfo) {
removeServerInfo(info.getServerName()); removeServerInfo(info.getServerName(), info.getServerAddress());
serversToServerInfo.notifyAll(); serversToServerInfo.notifyAll();
} }
@ -271,7 +275,8 @@ class ServerManager implements HConstants {
synchronized (serversToServerInfo) { synchronized (serversToServerInfo) {
try { try {
// HRegionServer is shutting down. // HRegionServer is shutting down.
if (removeServerInfo(serverInfo.getServerName())) { if (removeServerInfo(serverInfo.getServerName(),
serverInfo.getServerAddress())) {
// Only process the exit message if the server still has registered info. // Only process the exit message if the server still has registered info.
// Otherwise we could end up processing the server exit twice. // Otherwise we could end up processing the server exit twice.
LOG.info("Region server " + serverInfo.getServerName() + LOG.info("Region server " + serverInfo.getServerName() +
@ -321,6 +326,7 @@ class ServerManager implements HConstants {
throws IOException { throws IOException {
// Refresh the info object and the load information // Refresh the info object and the load information
serverAddressToServerInfo.put(serverInfo.getServerAddress(), serverInfo);
serversToServerInfo.put(serverInfo.getServerName(), serverInfo); serversToServerInfo.put(serverInfo.getServerName(), serverInfo);
HServerLoad load = serversToLoad.get(serverInfo.getServerName()); HServerLoad load = serversToLoad.get(serverInfo.getServerName());
@ -568,8 +574,10 @@ class ServerManager implements HConstants {
} }
/** Update a server load information because it's shutting down*/ /** Update a server load information because it's shutting down*/
private boolean removeServerInfo(final String serverName) { private boolean removeServerInfo(final String serverName,
final HServerAddress serverAddress) {
boolean infoUpdated = false; boolean infoUpdated = false;
serverAddressToServerInfo.remove(serverAddress);
HServerInfo info = serversToServerInfo.remove(serverName); HServerInfo info = serversToServerInfo.remove(serverName);
// Only update load information once. // Only update load information once.
// This method can be called a couple of times during shutdown. // This method can be called a couple of times during shutdown.
@ -646,6 +654,13 @@ class ServerManager implements HConstants {
} }
} }
public Map<HServerAddress, HServerInfo> getServerAddressToServerInfo() {
// we use this one because all the puts to this map are parallel/synced with the other map.
synchronized (serversToServerInfo) {
return Collections.unmodifiableMap(serverAddressToServerInfo);
}
}
/** /**
* @return Read-only map of servers to load. * @return Read-only map of servers to load.
*/ */
@ -692,15 +707,18 @@ class ServerManager implements HConstants {
/** Watcher triggered when a RS znode is deleted */ /** Watcher triggered when a RS znode is deleted */
private class ServerExpirer implements Watcher { private class ServerExpirer implements Watcher {
private String server; private String server;
private HServerAddress serverAddress;
ServerExpirer(String server) { ServerExpirer(String server, HServerAddress serverAddress) {
this.server = server; this.server = server;
this.serverAddress = serverAddress;
} }
public void process(WatchedEvent event) { public void process(WatchedEvent event) {
if(event.getType().equals(EventType.NodeDeleted)) { if(event.getType().equals(EventType.NodeDeleted)) {
LOG.info(server + " znode expired"); LOG.info(server + " znode expired");
// Remove the server from the known servers list and update load info // Remove the server from the known servers list and update load info
serverAddressToServerInfo.remove(serverAddress);
HServerInfo info = serversToServerInfo.remove(server); HServerInfo info = serversToServerInfo.remove(server);
boolean rootServer = false; boolean rootServer = false;
if (info != null) { if (info != null) {

View File

@ -20,8 +20,8 @@
HBaseAdmin hbadmin = new HBaseAdmin(conf); HBaseAdmin hbadmin = new HBaseAdmin(conf);
String tableName = request.getParameter("name"); String tableName = request.getParameter("name");
HTable table = new HTable(conf, tableName); HTable table = new HTable(conf, tableName);
Map<String, HServerInfo> serverToServerInfos = Map<HServerAddress, HServerInfo> serverAddressToServerInfos =
master.getServersToServerInfo(); master.getServerAddressToServerInfo();
String tableHeader = "<h2>Table Regions</h2><table><tr><th>Name</th><th>Region Server</th><th>Encoded Name</th><th>Start Key</th><th>End Key</th></tr>"; String tableHeader = "<h2>Table Regions</h2><table><tr><th>Name</th><th>Region Server</th><th>Encoded Name</th><th>Start Key</th><th>End Key</th></tr>";
HServerAddress rootLocation = master.getRootRegionLocation(); HServerAddress rootLocation = master.getRootRegionLocation();
%> %>
@ -32,9 +32,9 @@
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<% <%
String action = request.getParameter("action"); String action = request.getParameter("action");
String key = request.getParameter("key"); String key = request.getParameter("key");
if ( action != null ) { if ( action != null ) {
%> %>
<head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/> <head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
<meta http-equiv="refresh" content="5; url=/"/> <meta http-equiv="refresh" content="5; url=/"/>
@ -80,49 +80,76 @@ if ( action != null ) {
<h1 id="page_title">Table: <%= tableName %></h1> <h1 id="page_title">Table: <%= tableName %></h1>
<p id="links_menu"><a href="/master.jsp">Master</a>, <a href="/logs/">Local logs</a>, <a href="/stacks">Thread Dump</a>, <a href="/logLevel">Log Level</a></p> <p id="links_menu"><a href="/master.jsp">Master</a>, <a href="/logs/">Local logs</a>, <a href="/stacks">Thread Dump</a>, <a href="/logLevel">Log Level</a></p>
<hr id="head_rule" /> <hr id="head_rule" />
<%if(tableName.equals(Bytes.toString(HConstants.ROOT_TABLE_NAME))) {%> <%
if(tableName.equals(Bytes.toString(HConstants.ROOT_TABLE_NAME))) {
%>
<%= tableHeader %> <%= tableHeader %>
<% int infoPort = serverToServerInfos.get(rootLocation.getBindAddress()+":"+rootLocation.getPort()).getInfoPort(); <%
String url = "http://" + rootLocation.getHostname() + ":" + infoPort + "/";%> int infoPort = serverAddressToServerInfos.get(rootLocation).getInfoPort();
<tr><td><%= tableName %></td><td><a href="<%= url %>"><%= rootLocation.getHostname() %>:<%= rootLocation.getPort() %></a></td><td>-</td><td></td><td>-</td></tr> String url = "http://" + rootLocation.getHostname() + ":" + infoPort + "/";
%>
<tr>
<td><%= tableName %></td>
<td><a href="<%= url %>"><%= rootLocation.getHostname() %>:<%= rootLocation.getPort() %></a></td>
<td>-</td>
<td></td>
<td>-</td>
</tr>
</table> </table>
<%} else if(tableName.equals(Bytes.toString(HConstants.META_TABLE_NAME))) { %> <%
} else if(tableName.equals(Bytes.toString(HConstants.META_TABLE_NAME))) {
%>
<%= tableHeader %> <%= tableHeader %>
<% Map<byte [], MetaRegion> onlineRegions = master.getOnlineMetaRegions(); <%
Map<byte [], MetaRegion> onlineRegions = master.getOnlineMetaRegions();
for (MetaRegion meta: onlineRegions.values()) { for (MetaRegion meta: onlineRegions.values()) {
int infoPort = serverToServerInfos.get(meta.getServer().getBindAddress()+":"+meta.getServer().getPort()).getInfoPort(); int infoPort = serverAddressToServerInfos.get(meta.getServer()).getInfoPort();
String url = "http://" + meta.getServer().getHostname() + ":" + infoPort + "/";%> String url = "http://" + meta.getServer().getHostname() + ":" + infoPort + "/";
<tr><td><%= Bytes.toString(meta.getRegionName()) %></td> %>
<td><a href="<%= url %>"><%= meta.getServer().getHostname() %>:<%= meta.getServer().getPort() %></a></td> <tr>
<td>-</td><td><%= Bytes.toString(meta.getStartKey()) %></td><td>-</td></tr> <td><%= Bytes.toString(meta.getRegionName()) %></td>
<td><a href="<%= url %>"><%= meta.getServer().toString() %></a></td>
<td>-</td><td><%= Bytes.toString(meta.getStartKey()) %></td><td>-</td>
</tr>
<% } %> <% } %>
</table> </table>
<%} else { <%} else {
try { %> try { %>
<h2>Table Attributes</h2> <h2>Table Attributes</h2>
<table> <table>
<tr><th>Attribute Name</th><th>Value</th><th>Description</th></tr> <tr><th>Attribute Name</th><th>Value</th><th>Description</th></tr>
<tr><td>Enabled</td><td><%= hbadmin.isTableEnabled(table.getTableName()) %></td><td>Is the table enabled</td></tr> <tr><td>Enabled</td><td><%= hbadmin.isTableEnabled(table.getTableName()) %></td><td>Is the table enabled</td></tr>
</table> </table>
<% Map<HRegionInfo, HServerAddress> regions = table.getRegionsInfo(); <%
Map<HRegionInfo, HServerAddress> regions = table.getRegionsInfo();
if(regions != null && regions.size() > 0) { %> if(regions != null && regions.size() > 0) { %>
<%= tableHeader %> <%= tableHeader %>
<% for(Map.Entry<HRegionInfo, HServerAddress> hriEntry : regions.entrySet()) { %> <%
<% int infoPort = serverToServerInfos.get(hriEntry.getValue().getBindAddress()+":"+hriEntry.getValue().getPort()).getInfoPort(); for(Map.Entry<HRegionInfo, HServerAddress> hriEntry : regions.entrySet()) {
String urlRegionHistorian = "/regionhistorian.jsp?regionname="+hriEntry.getKey().getRegionNameAsString();
String urlRegionServer = "http://" + hriEntry.getValue().getHostname().toString() + ":" + infoPort + "/"; %> int infoPort = serverAddressToServerInfos.get(
<tr><td><a href="<%= urlRegionHistorian %>"><%= hriEntry.getKey().getRegionNameAsString()%></a></td> hriEntry.getValue()).getInfoPort();
<td><a href="<%= urlRegionServer %>"><%= hriEntry.getValue().getHostname() %>:<%= hriEntry.getValue().getPort() %></a></td>
String urlRegionHistorian =
"/regionhistorian.jsp?regionname="+hriEntry.getKey().getRegionNameAsString();
String urlRegionServer =
"http://" + hriEntry.getValue().getHostname().toString() + ":" + infoPort + "/";
%>
<tr>
<td><a href="<%= urlRegionHistorian %>"><%= hriEntry.getKey().getRegionNameAsString()%></a></td>
<td><a href="<%= urlRegionServer %>"><%= hriEntry.getValue().toString() %></a></td>
<td><%= hriEntry.getKey().getEncodedName()%></td> <td><%= Bytes.toString(hriEntry.getKey().getStartKey())%></td> <td><%= hriEntry.getKey().getEncodedName()%></td> <td><%= Bytes.toString(hriEntry.getKey().getStartKey())%></td>
<td><%= Bytes.toString(hriEntry.getKey().getEndKey())%></td></tr> <td><%= Bytes.toString(hriEntry.getKey().getEndKey())%></td>
</tr>
<% } %> <% } %>
</table> </table>
<% } <% }
} } catch(Exception ex) {
catch(Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
}%> } // end else
%>
<p><hr><p> <p><hr><p>
Actions: Actions: