hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From la...@apache.org
Subject svn commit: r1496201 - in /hbase/branches/0.95/hbase-server/src: main/jamon/org/apache/hadoop/hbase/tmpl/master/ main/java/org/apache/hadoop/hbase/master/ test/java/org/apache/hadoop/hbase/master/
Date Mon, 24 Jun 2013 20:31:33 GMT
Author: larsh
Date: Mon Jun 24 20:31:33 2013
New Revision: 1496201

URL: http://svn.apache.org/r1496201
Log:
HBASE-5083 Backup HMaster should have http infoport open with link to the active master (Cody
Marcel)

Modified:
    hbase/branches/0.95/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/BackupMasterListTmpl.jamon
    hbase/branches/0.95/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/MasterStatusTmpl.jamon
    hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ActiveMasterManager.java
    hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
    hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterStatusServlet.java
    hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterStatusServlet.java

Modified: hbase/branches/0.95/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/BackupMasterListTmpl.jamon
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/BackupMasterListTmpl.jamon?rev=1496201&r1=1496200&r2=1496201&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/BackupMasterListTmpl.jamon
(original)
+++ hbase/branches/0.95/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/BackupMasterListTmpl.jamon
Mon Jun 24 20:31:33 2013
@@ -1,69 +0,0 @@
-<%doc>
-Copyright The Apache Software Foundation
-
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
- </%doc>
-
-<%args>
-HMaster master;
-</%args>
-
-<%import>
-        java.util.*;
-        org.apache.hadoop.util.StringUtils;
-        org.apache.hadoop.hbase.util.Bytes;
-        org.apache.hadoop.hbase.master.HMaster;
-        org.apache.hadoop.hbase.HConstants;
-        org.apache.hadoop.hbase.ServerName;
-        org.apache.hadoop.hbase.ClusterStatus;
-</%import>
-
-<%java>
-Collection<ServerName> backupMasters = null;
-if (master.isActiveMaster()) {
-    ClusterStatus status = master.getClusterStatus();
-    backupMasters = status.getBackupMasters();
-}
-</%java>
-
-<table class="table table-striped">
-<%if (backupMasters != null && backupMasters.size() > 0)%>
-<tr>
-    <th>ServerName</th>
-    <th>Port</th>
-    <th>Start Time</th>
-</tr>
-<%java>
-    ServerName [] serverNames = backupMasters.toArray(new ServerName[backupMasters.size()]);
-    Arrays.sort(serverNames);
-    for (ServerName serverName: serverNames) {
-</%java>
-<tr>
-    <td><% serverName.getHostname() %></td>
-    <td><% serverName.getPort() %></td>
-    <td><% new Date(serverName.getStartcode()) %></td>
-</tr>
-<%java>
-    }
-</%java>
-</%if>
-<tr><td>Total:<% (backupMasters != null) ? backupMasters.size() : 0 %></td>
-</table>
-
-
-
-

Modified: hbase/branches/0.95/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/MasterStatusTmpl.jamon
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/MasterStatusTmpl.jamon?rev=1496201&r1=1496200&r2=1496201&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/MasterStatusTmpl.jamon
(original)
+++ hbase/branches/0.95/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/MasterStatusTmpl.jamon
Mon Jun 24 20:31:33 2013
@@ -26,6 +26,8 @@ Set<ServerName> deadServers = null;
 boolean catalogJanitorEnabled = true;
 String filter = "general";
 String format = "html";
+ServerManager serverManager = null;
+AssignmentManager assignmentManager = null;
 </%args>
 <%import>
 java.util.*;
@@ -34,6 +36,8 @@ org.apache.hadoop.hbase.util.Bytes;
 org.apache.hadoop.hbase.util.JvmVersion;
 org.apache.hadoop.hbase.util.FSUtils;
 org.apache.hadoop.hbase.master.HMaster;
+org.apache.hadoop.hbase.master.AssignmentManager;
+org.apache.hadoop.hbase.master.ServerManager;
 org.apache.hadoop.hbase.HConstants;
 org.apache.hadoop.hbase.ServerLoad;
 org.apache.hadoop.hbase.ServerName;
@@ -47,6 +51,11 @@ org.apache.hadoop.hbase.protobuf.generat
   <& ../common/TaskMonitorTmpl; filter = filter; format = "json" &>
   <%java return; %>
 </%if>
+<%java>
+ServerManager serverManager = master.getServerManager();
+AssignmentManager assignmentManager = master.getAssignmentManager();
+</%java>
+
 <!--[if IE]>
 <!DOCTYPE html>
 <![endif]-->
@@ -94,6 +103,7 @@ org.apache.hadoop.hbase.protobuf.generat
     </div>
 
     <div class="container">
+	<%if master.isActiveMaster() %>
         <div class="row inner_header">
             <div class="page-header">
                 <h1>Master <small><% master.getServerName().getHostname()
%> </small></h1>
@@ -125,12 +135,9 @@ org.apache.hadoop.hbase.protobuf.generat
                 <& deadRegionServers &>
             </%if>
         </section>
-
         <section>
-            <h2>Backup Masters</h2>
-            <& BackupMasterListTmpl; master = master &>
+            <& BackupMasterStatusTmpl; master = master &>
         </section>
-
         <section>
             <h2>Tables</h2>
             <div class="tabbable">
@@ -162,8 +169,13 @@ org.apache.hadoop.hbase.protobuf.generat
                 </div>
             </div>
         </section>
-
         <& AssignmentManagerStatusTmpl; assignmentManager=master.getAssignmentManager()&>
+	<%else>
+        <section>
+            <& BackupMasterStatusTmpl; master = master &>
+        </section>
+	</%if>    
+
 
         <section>
             <& ../common/TaskMonitorTmpl; filter = filter &>
@@ -197,47 +209,49 @@ org.apache.hadoop.hbase.protobuf.generat
                     <td>When Hadoop version was compiled and by whom</td>
                 </tr>
                 <tr>
-                    <td>HBase Root Directory</td>
-                    <td><% FSUtils.getRootDir(master.getConfiguration()).toString()
%></td>
-                    <td>Location of HBase home directory</td>
-                </tr>
-                <tr>
-                    <td>HBase Cluster ID</td>
-                    <td><% master.getClusterId() != null ? master.getClusterId()
: "Not set" %></td>
-                    <td>Unique identifier generated for each HBase cluster</td>
-                </tr>
-                <tr>
-                    <td>Load average</td>
-                    <td><% StringUtils.limitDecimalTo2(master.getServerManager().getAverageLoad())
%></td>
-                    <td>Average number of regions per regionserver. Naive computation.</td>
-                </tr>
-                <%if frags != null %>
-                <tr>
-                    <td>Fragmentation</td>
-                    <td><% frags.get("-TOTAL-") != null ? frags.get("-TOTAL-").intValue()
+ "%" : "n/a" %></td>
-                    <td>Overall fragmentation of all tables, including .META.</td>
-                </tr>
-                </%if>
-                <tr>
                     <td>Zookeeper Quorum</td>
                     <td><% master.getZooKeeperWatcher().getQuorum() %></td>
                     <td>Addresses of all registered ZK servers. For more, see <a
href="/zk.jsp">zk dump</a>.</td>
                 </tr>
                 <tr>
-                    <td>Coprocessors</td>
-                    <td><% java.util.Arrays.toString(master.getCoprocessors()) %></td>
-                    <td>Coprocessors currently loaded by the master</td>
+                    <td>HBase Root Directory</td>
+                    <td><% FSUtils.getRootDir(master.getConfiguration()).toString()
%></td>
+                    <td>Location of HBase home directory</td>
                 </tr>
                 <tr>
                     <td>HMaster Start Time</td>
                     <td><% new Date(master.getMasterStartTime()) %></td>
                     <td>Date stamp of when this HMaster was started</td>
                 </tr>
-                <tr>
-                    <td>HMaster Active Time</td>
-                    <td><% new Date(master.getMasterActiveTime()) %></td>
-                    <td>Date stamp of when this HMaster became active</td>
-                </tr>
+                <%if master.isActiveMaster() %>
+	                <tr>
+	                    <td>HMaster Active Time</td>
+	                    <td><% new Date(master.getMasterActiveTime()) %></td>
+	                    <td>Date stamp of when this HMaster became active</td>
+	                </tr>
+	                <tr>
+	                    <td>HBase Cluster ID</td>
+	                    <td><% master.getClusterId() != null ? master.getClusterId()
: "Not set" %></td>
+	                    <td>Unique identifier generated for each HBase cluster</td>
+	                </tr>
+	                <tr>
+	                    <td>Load average</td>
+	                    <td><% StringUtils.limitDecimalTo2(master.getServerManager().getAverageLoad())
%></td>
+	                    <td>Average number of regions per regionserver. Naive computation.</td>
+	                </tr>
+	                <%if frags != null %>
+	                <tr>
+	                    <td>Fragmentation</td>
+	                    <td><% frags.get("-TOTAL-") != null ? frags.get("-TOTAL-").intValue()
+ "%" : "n/a" %></td>
+	                    <td>Overall fragmentation of all tables, including .META.</td>
+	                </tr>
+	                </%if>
+	                <tr>
+	                    <td>Coprocessors</td>
+	                    <td><% java.util.Arrays.toString(master.getCoprocessors())
%></td>
+	                    <td>Coprocessors currently loaded by the master</td>
+	                </tr>
+                </%if>
             </table>
         </section>
         </div>

Modified: hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ActiveMasterManager.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ActiveMasterManager.java?rev=1496201&r1=1496200&r2=1496201&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ActiveMasterManager.java
(original)
+++ hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ActiveMasterManager.java
Mon Jun 24 20:31:33 2013
@@ -49,7 +49,7 @@ import org.apache.zookeeper.KeeperExcept
  * the active master of the cluster.
  */
 @InterfaceAudience.Private
-class ActiveMasterManager extends ZooKeeperListener {
+public class ActiveMasterManager extends ZooKeeperListener {
   private static final Log LOG = LogFactory.getLog(ActiveMasterManager.class);
 
   final AtomicBoolean clusterHasActiveMaster = new AtomicBoolean(false);

Modified: hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java?rev=1496201&r1=1496200&r2=1496201&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
(original)
+++ hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
Mon Jun 24 20:31:33 2013
@@ -197,6 +197,7 @@ import org.apache.hadoop.hbase.util.Vers
 import org.apache.hadoop.hbase.zookeeper.ClusterStatusTracker;
 import org.apache.hadoop.hbase.zookeeper.DrainingServerTracker;
 import org.apache.hadoop.hbase.zookeeper.LoadBalancerTracker;
+import org.apache.hadoop.hbase.zookeeper.MasterAddressTracker;
 import org.apache.hadoop.hbase.zookeeper.RegionServerTracker;
 import org.apache.hadoop.hbase.zookeeper.ZKClusterId;
 import org.apache.hadoop.hbase.zookeeper.ZKUtil;
@@ -258,6 +259,8 @@ MasterServices, Server {
   private DrainingServerTracker drainingServerTracker;
   // Tracker for load balancer state
   private LoadBalancerTracker loadBalancerTracker;
+  // master address manager and watcher
+  private MasterAddressTracker masterAddressManager;
 
   // RPC server for the HMaster
   private final RpcServerInterface rpcServer;
@@ -528,6 +531,20 @@ MasterServices, Server {
     masterStartTime = System.currentTimeMillis();
     try {
       this.registeredZKListenersBeforeRecovery = this.zooKeeper.getListeners();
+      this.masterAddressManager = new MasterAddressTracker(getZooKeeperWatcher(), this);
+      this.masterAddressManager.start();
+
+      // Put up info server.
+      int port = this.conf.getInt("hbase.master.info.port", 60010);
+      if (port >= 0) {
+        String a = this.conf.get("hbase.master.info.bindAddress", "0.0.0.0");
+        this.infoServer = new InfoServer(MASTER, a, port, false, this.conf);
+        this.infoServer.addServlet("status", "/master-status", MasterStatusServlet.class);
+        this.infoServer.addServlet("dump", "/dump", MasterDumpServlet.class);
+        this.infoServer.setAttribute(MASTER, this);
+        this.infoServer.start();
+      }
+
       /*
        * Block on becoming the active master.
        *
@@ -1057,6 +1074,14 @@ MasterServices, Server {
     return this.zooKeeper;
   }
 
+  public ActiveMasterManager getActiveMasterManager() {
+    return this.activeMasterManager;
+  }
+  
+  public MasterAddressTracker getMasterAddressManager() {
+    return this.masterAddressManager;
+  }
+  
   /*
    * Start up all services. If any of these threads gets an unhandled exception
    * then they just die with a logged message.  This should be fine because
@@ -1095,17 +1120,6 @@ MasterServices, Server {
         .getFileSystem(), archiveDir);
     Threads.setDaemonThreadRunning(hfileCleaner.getThread(), n + ".archivedHFileCleaner");
 
-   // Put up info server.
-   int port = this.conf.getInt(HConstants.MASTER_INFO_PORT, 60010);
-   if (port >= 0) {
-     String a = this.conf.get("hbase.master.info.bindAddress", "0.0.0.0");
-     this.infoServer = new InfoServer(MASTER, a, port, false, this.conf);
-     this.infoServer.addServlet("status", "/master-status", MasterStatusServlet.class);
-     this.infoServer.addServlet("dump", "/dump", MasterDumpServlet.class);
-     this.infoServer.setAttribute(MASTER, this);
-     this.infoServer.start();
-    }
-
     // Start the health checker
     if (this.healthCheckChore != null) {
       Threads.setDaemonThreadRunning(this.healthCheckChore.getThread(), n + ".healthChecker");

Modified: hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterStatusServlet.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterStatusServlet.java?rev=1496201&r1=1496200&r2=1496201&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterStatusServlet.java
(original)
+++ hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterStatusServlet.java
Mon Jun 24 20:31:33 2013
@@ -59,12 +59,17 @@ public class MasterStatusServlet extends
     HBaseAdmin admin = new HBaseAdmin(conf);
 
     Map<String, Integer> frags = getFragmentationInfo(master, conf);
-
-    ServerName metaLocation = getMetaLocationOrNull(master);
-    //ServerName metaLocation = master.getCatalogTracker().getMetaLocation();
-    List<ServerName> servers = master.getServerManager().getOnlineServersList();
-    Set<ServerName> deadServers = master.getServerManager().getDeadServers().copyServerNames();
-
+    ServerName metaLocation = null;
+    List<ServerName> servers = null;
+    Set<ServerName> deadServers = null;
+    
+    if(master.isActiveMaster()){
+      metaLocation = getMetaLocationOrNull(master);
+      //ServerName metaLocation = master.getCatalogTracker().getMetaLocation();
+      servers = master.getServerManager().getOnlineServersList();
+      deadServers = master.getServerManager().getDeadServers().copyServerNames();
+    }
+    
     response.setContentType("text/html");
     MasterStatusTmpl tmpl;
     try {
@@ -76,6 +81,7 @@ public class MasterStatusServlet extends
       .setCatalogJanitorEnabled(master.isCatalogJanitorEnabled(null,
           RequestConverter.buildIsCatalogJanitorEnabledRequest()).getValue());
     } catch (ServiceException s) {
+      admin.close();
       throw new IOException(s);
     }
     if (request.getParameter("filter") != null)
@@ -88,7 +94,7 @@ public class MasterStatusServlet extends
 
   private ServerName getMetaLocationOrNull(HMaster master) {
     try {
-      return master.getCatalogTracker().getMetaLocation();
+      return (master.getCatalogTracker() == null) ? null : master.getCatalogTracker().getMetaLocation();
     } catch (InterruptedException e) {
       LOG.warn("Unable to get meta location", e);
       return null;

Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterStatusServlet.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterStatusServlet.java?rev=1496201&r1=1496200&r2=1496201&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterStatusServlet.java
(original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterStatusServlet.java
Mon Jun 24 20:31:33 2013
@@ -33,6 +33,7 @@ import org.apache.hadoop.conf.Configurat
 import org.apache.hadoop.hbase.*;
 import org.apache.hadoop.hbase.client.HBaseAdmin;
 import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.zookeeper.MasterAddressTracker;
 import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
 import org.apache.hadoop.hbase.tmpl.master.AssignmentManagerStatusTmpl;
 import org.apache.hadoop.hbase.tmpl.master.MasterStatusTmpl;
@@ -90,6 +91,11 @@ public class TestMasterStatusServlet {
     Mockito.doReturn("fakequorum").when(zkw).getQuorum();
     Mockito.doReturn(zkw).when(master).getZooKeeperWatcher();
 
+    // Fake MasterAddressTracker
+    MasterAddressTracker tracker = Mockito.mock(MasterAddressTracker.class);
+    Mockito.doReturn(tracker).when(master).getMasterAddressManager();
+    Mockito.doReturn(FAKE_HOST).when(tracker).getMasterAddress();
+
     // Mock admin
     admin = Mockito.mock(HBaseAdmin.class); 
   }



Mime
View raw message