You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ap...@apache.org on 2009/03/26 02:14:17 UTC

svn commit: r758491 - in /hadoop/hbase/trunk: CHANGES.txt src/java/org/apache/hadoop/hbase/master/HMaster.java src/java/org/apache/hadoop/hbase/master/ServerManager.java src/webapps/master/table.jsp

Author: apurtell
Date: Thu Mar 26 01:14:15 2009
New Revision: 758491

URL: http://svn.apache.org/viewvc?rev=758491&view=rev
Log:
HBASE-1290 table.jsp either 500s out or doesnt list the regions

Modified:
    hadoop/hbase/trunk/CHANGES.txt
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/HMaster.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/ServerManager.java
    hadoop/hbase/trunk/src/webapps/master/table.jsp

Modified: hadoop/hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=758491&r1=758490&r2=758491&view=diff
==============================================================================
--- hadoop/hbase/trunk/CHANGES.txt (original)
+++ hadoop/hbase/trunk/CHANGES.txt Thu Mar 26 01:14:15 2009
@@ -61,6 +61,8 @@
    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

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/HMaster.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/HMaster.java?rev=758491&r1=758490&r2=758491&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/HMaster.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/HMaster.java Thu Mar 26 01:14:15 2009
@@ -320,6 +320,10 @@
     return serverManager.getServersToServerInfo();
   }
 
+  public Map<HServerAddress, HServerInfo> getServerAddressToServerInfo() {
+    return serverManager.getServerAddressToServerInfo();
+  }
+
   /**
    * @return Read-only map of servers to load.
    */

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/ServerManager.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/ServerManager.java?rev=758491&r1=758490&r2=758491&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/ServerManager.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/ServerManager.java Thu Mar 26 01:14:15 2009
@@ -69,6 +69,9 @@
   /** 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 @@
         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 @@
     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 @@
       }
 
       synchronized (serversToServerInfo) {
-        removeServerInfo(info.getServerName());
+        removeServerInfo(info.getServerName(), info.getServerAddress());
         serversToServerInfo.notifyAll();
       }
       
@@ -271,7 +275,8 @@
     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 @@
   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 @@
   }
   
   /** 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 @@
     }
   }
 
+  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 @@
   /** 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) {

Modified: hadoop/hbase/trunk/src/webapps/master/table.jsp
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/webapps/master/table.jsp?rev=758491&r1=758490&r2=758491&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/webapps/master/table.jsp (original)
+++ hadoop/hbase/trunk/src/webapps/master/table.jsp Thu Mar 26 01:14:15 2009
@@ -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 @@
 <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: