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
procedure (Rong-en Fan via Stack)
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
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();
}
public Map<HServerAddress, HServerInfo> getServerAddressToServerInfo() {
return serverManager.getServerAddressToServerInfo();
}
/**
* @return Read-only map of servers to load.
*/

View File

@ -69,6 +69,9 @@ class ServerManager implements HConstants {
/** The map of known server names to server info */
final Map<String, HServerInfo> serversToServerInfo =
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.
@ -124,7 +127,7 @@ class ServerManager implements HConstants {
deadServers.contains(serverName)) {
throw new Leases.LeaseStillHeldException(serverName);
}
Watcher watcher = new ServerExpirer(serverName);
Watcher watcher = new ServerExpirer(serverName, info.getServerAddress());
zooKeeperWrapper.updateRSLocationGetWatch(info, watcher);
LOG.info("Received start message from: " + serverName);
@ -162,6 +165,7 @@ class ServerManager implements HConstants {
load = new HServerLoad();
info.setLoad(load);
serversToServerInfo.put(serverName, info);
serverAddressToServerInfo.put(info.getServerAddress(), info);
serversToLoad.put(serverName, load);
synchronized (loadToServers) {
Set<String> servers = loadToServers.get(load);
@ -256,7 +260,7 @@ class ServerManager implements HConstants {
}
synchronized (serversToServerInfo) {
removeServerInfo(info.getServerName());
removeServerInfo(info.getServerName(), info.getServerAddress());
serversToServerInfo.notifyAll();
}
@ -271,7 +275,8 @@ class ServerManager implements HConstants {
synchronized (serversToServerInfo) {
try {
// 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.
// Otherwise we could end up processing the server exit twice.
LOG.info("Region server " + serverInfo.getServerName() +
@ -321,6 +326,7 @@ class ServerManager implements HConstants {
throws IOException {
// Refresh the info object and the load information
serverAddressToServerInfo.put(serverInfo.getServerAddress(), serverInfo);
serversToServerInfo.put(serverInfo.getServerName(), serverInfo);
HServerLoad load = serversToLoad.get(serverInfo.getServerName());
@ -568,8 +574,10 @@ class ServerManager implements HConstants {
}
/** 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;
serverAddressToServerInfo.remove(serverAddress);
HServerInfo info = serversToServerInfo.remove(serverName);
// Only update load information once.
// 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.
*/
@ -692,15 +707,18 @@ class ServerManager implements HConstants {
/** Watcher triggered when a RS znode is deleted */
private class ServerExpirer implements Watcher {
private String server;
private HServerAddress serverAddress;
ServerExpirer(String server) {
ServerExpirer(String server, HServerAddress serverAddress) {
this.server = server;
this.serverAddress = serverAddress;
}
public void process(WatchedEvent event) {
if(event.getType().equals(EventType.NodeDeleted)) {
LOG.info(server + " znode expired");
// Remove the server from the known servers list and update load info
serverAddressToServerInfo.remove(serverAddress);
HServerInfo info = serversToServerInfo.remove(server);
boolean rootServer = false;
if (info != null) {

View File

@ -20,8 +20,8 @@
HBaseAdmin hbadmin = new HBaseAdmin(conf);
String tableName = request.getParameter("name");
HTable table = new HTable(conf, tableName);
Map<String, HServerInfo> serverToServerInfos =
master.getServersToServerInfo();
Map<HServerAddress, HServerInfo> serverAddressToServerInfos =
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>";
HServerAddress rootLocation = master.getRootRegionLocation();
%>
@ -32,9 +32,9 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<%
String action = request.getParameter("action");
String key = request.getParameter("key");
if ( action != null ) {
String action = request.getParameter("action");
String key = request.getParameter("key");
if ( action != null ) {
%>
<head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
<meta http-equiv="refresh" content="5; url=/"/>
@ -80,49 +80,76 @@ if ( action != null ) {
<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>
<hr id="head_rule" />
<%if(tableName.equals(Bytes.toString(HConstants.ROOT_TABLE_NAME))) {%>
<%
if(tableName.equals(Bytes.toString(HConstants.ROOT_TABLE_NAME))) {
%>
<%= tableHeader %>
<% int infoPort = serverToServerInfos.get(rootLocation.getBindAddress()+":"+rootLocation.getPort()).getInfoPort();
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>
<%
int infoPort = serverAddressToServerInfos.get(rootLocation).getInfoPort();
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>
<%} else if(tableName.equals(Bytes.toString(HConstants.META_TABLE_NAME))) { %>
<%
} else if(tableName.equals(Bytes.toString(HConstants.META_TABLE_NAME))) {
%>
<%= tableHeader %>
<% Map<byte [], MetaRegion> onlineRegions = master.getOnlineMetaRegions();
for (MetaRegion meta: onlineRegions.values()) {
int infoPort = serverToServerInfos.get(meta.getServer().getBindAddress()+":"+meta.getServer().getPort()).getInfoPort();
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>
<td>-</td><td><%= Bytes.toString(meta.getStartKey()) %></td><td>-</td></tr>
<%
Map<byte [], MetaRegion> onlineRegions = master.getOnlineMetaRegions();
for (MetaRegion meta: onlineRegions.values()) {
int infoPort = serverAddressToServerInfos.get(meta.getServer()).getInfoPort();
String url = "http://" + meta.getServer().getHostname() + ":" + infoPort + "/";
%>
<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>
<%} else {
try { %>
try { %>
<h2>Table Attributes</h2>
<table>
<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><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>
</table>
<% Map<HRegionInfo, HServerAddress> regions = table.getRegionsInfo();
if(regions != null && regions.size() > 0) { %>
<%
Map<HRegionInfo, HServerAddress> regions = table.getRegionsInfo();
if(regions != null && regions.size() > 0) { %>
<%= tableHeader %>
<% for(Map.Entry<HRegionInfo, HServerAddress> hriEntry : regions.entrySet()) { %>
<% int infoPort = serverToServerInfos.get(hriEntry.getValue().getBindAddress()+":"+hriEntry.getValue().getPort()).getInfoPort();
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().getHostname() %>:<%= hriEntry.getValue().getPort() %></a></td>
<td><%= hriEntry.getKey().getEncodedName()%></td> <td><%= Bytes.toString(hriEntry.getKey().getStartKey())%></td>
<td><%= Bytes.toString(hriEntry.getKey().getEndKey())%></td></tr>
<% } %>
<%
for(Map.Entry<HRegionInfo, HServerAddress> hriEntry : regions.entrySet()) {
int infoPort = serverAddressToServerInfos.get(
hriEntry.getValue()).getInfoPort();
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><%= Bytes.toString(hriEntry.getKey().getEndKey())%></td>
</tr>
<% } %>
</table>
<% }
}
catch(Exception ex) {
ex.printStackTrace();
}
}%>
<% }
} catch(Exception ex) {
ex.printStackTrace();
}
} // end else
%>
<p><hr><p>
Actions: