HBASE-5083 Backup HMaster should have http infoport open with link to the active master (Cody Marcel)
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1496198 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
821342f542
commit
dfe84fb1f9
|
@ -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>
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
<%doc>
|
||||
|
||||
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.hbase.ServerName;
|
||||
org.apache.hadoop.hbase.ClusterStatus;
|
||||
org.apache.hadoop.hbase.master.HMaster;
|
||||
</%import>
|
||||
<%java>
|
||||
Collection<ServerName> masters = null;
|
||||
|
||||
if (master.isActiveMaster()) {
|
||||
ClusterStatus status = master.getClusterStatus();
|
||||
masters = status.getBackupMasters();
|
||||
} else{
|
||||
ServerName sn = master.getMasterAddressManager().getMasterAddress();
|
||||
assert sn != null : "Failed to retreive master's ServerName!";
|
||||
masters = Collections.singletonList(sn);
|
||||
}
|
||||
</%java>
|
||||
|
||||
<%java>
|
||||
ServerName [] serverNames = masters.toArray(new ServerName[masters.size()]);
|
||||
</%java>
|
||||
<%if (!master.isActiveMaster()) %>
|
||||
<%if serverNames[0] != null %>
|
||||
<h2>Master</h2>
|
||||
<a href="<% serverNames[0].getHostname() %>:<% master.getConfiguration().getInt("hbase.master.info.port", 60010) %>/master-status" target="_blank"><% serverNames[0].getHostname() %></a>
|
||||
<%else>
|
||||
Unable to parse master hostname.
|
||||
</%if>
|
||||
<%else>
|
||||
<h2>Backup Masters</h2>
|
||||
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
<th>ServerName</th>
|
||||
<th>Port</th>
|
||||
<th>Start Time</th>
|
||||
</tr>
|
||||
<%java>
|
||||
Arrays.sort(serverNames);
|
||||
for (ServerName serverName : serverNames) {
|
||||
</%java>
|
||||
<tr>
|
||||
<td><a href="<% serverName.getHostname() %>:<% master.getConfiguration().getInt("hbase.master.info.port", 60010) %>/master-status" target="_blank"><% serverName.getHostname() %></a></td>
|
||||
<td><% serverName.getPort() %></td>
|
||||
<td><% new Date(serverName.getStartcode()) %></td>
|
||||
</tr>
|
||||
<%java>
|
||||
}
|
||||
</%java>
|
||||
<tr><td>Total:<% (masters != null) ? masters.size() : 0 %></td>
|
||||
</table>
|
||||
</%if>
|
|
@ -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.generated.HBaseProtos.SnapshotDescription;
|
|||
<& ../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.generated.HBaseProtos.SnapshotDescription;
|
|||
</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.generated.HBaseProtos.SnapshotDescription;
|
|||
<& 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.generated.HBaseProtos.SnapshotDescription;
|
|||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<& AssignmentManagerStatusTmpl; assignmentManager=master.getAssignmentManager()&>
|
||||
<%else>
|
||||
<section>
|
||||
<& BackupMasterStatusTmpl; master = master &>
|
||||
</section>
|
||||
</%if>
|
||||
|
||||
|
||||
<section>
|
||||
<& ../common/TaskMonitorTmpl; filter = filter &>
|
||||
|
@ -196,48 +208,50 @@ org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription;
|
|||
<td><% org.apache.hadoop.util.VersionInfo.getDate() %>, <% org.apache.hadoop.util.VersionInfo.getUser() %></td>
|
||||
<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>
|
||||
|
|
|
@ -49,7 +49,7 @@ import org.apache.zookeeper.KeeperException;
|
|||
* 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);
|
||||
|
|
|
@ -197,6 +197,7 @@ import org.apache.hadoop.hbase.util.VersionInfo;
|
|||
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");
|
||||
|
|
|
@ -59,12 +59,17 @@ public class MasterStatusServlet extends HttpServlet {
|
|||
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 HttpServlet {
|
|||
.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 HttpServlet {
|
|||
|
||||
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;
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.apache.hadoop.conf.Configuration;
|
|||
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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue