HBASE-10897 On master start, deadlock if refresh UI

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1586705 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
jxiang 2014-04-11 15:59:26 +00:00
parent 81bebaee81
commit a0a7cb53ca
5 changed files with 45 additions and 46 deletions

View File

@ -198,7 +198,9 @@ AssignmentManager assignmentManager = master.getAssignmentManager();
</div> </div>
</div> </div>
</section> </section>
<%if master.getAssignmentManager() != null %>
<& AssignmentManagerStatusTmpl; assignmentManager=master.getAssignmentManager()&> <& AssignmentManagerStatusTmpl; assignmentManager=master.getAssignmentManager()&>
</%if>
<%else> <%else>
<section> <section>
<& BackupMasterStatusTmpl; master = master &> <& BackupMasterStatusTmpl; master = master &>
@ -266,7 +268,8 @@ AssignmentManager assignmentManager = master.getAssignmentManager();
</tr> </tr>
<tr> <tr>
<td>Load average</td> <td>Load average</td>
<td><% StringUtils.limitDecimalTo2(master.getServerManager().getAverageLoad()) %></td> <td><% master.getServerManager() == null ? "0.00" :
StringUtils.limitDecimalTo2(master.getServerManager().getAverageLoad()) %></td>
<td>Average number of regions per regionserver. Naive computation.</td> <td>Average number of regions per regionserver. Naive computation.</td>
</tr> </tr>
<%if frags != null %> <%if frags != null %>
@ -278,7 +281,8 @@ AssignmentManager assignmentManager = master.getAssignmentManager();
</%if> </%if>
<tr> <tr>
<td>Coprocessors</td> <td>Coprocessors</td>
<td><% java.util.Arrays.toString(master.getMasterCoprocessors()) %></td> <td><% master.getMasterCoprocessorHost() == null ? "[]" :
java.util.Arrays.toString(master.getMasterCoprocessors()) %></td>
<td>Coprocessors currently loaded by the master</td> <td>Coprocessors currently loaded by the master</td>
</tr> </tr>
</%if> </%if>
@ -295,10 +299,10 @@ AssignmentManager assignmentManager = master.getAssignmentManager();
<%def catalogTables> <%def catalogTables>
<%java> <%java>
HTableDescriptor[] sysTables = admin.listTableDescriptorsByNamespace(NamespaceDescriptor HTableDescriptor[] sysTables = master.isInitialized() ? admin.listTableDescriptorsByNamespace(
.SYSTEM_NAMESPACE_NAME_STR); NamespaceDescriptor.SYSTEM_NAMESPACE_NAME_STR) : null;
</%java> </%java>
<%if (sysTables != null && sysTables.length > 0)%>
<table class="table table-striped"> <table class="table table-striped">
<tr> <tr>
<th>Table Name</th> <th>Table Name</th>
@ -326,11 +330,12 @@ AssignmentManager assignmentManager = master.getAssignmentManager();
</tr> </tr>
</%for> </%for>
</table> </table>
</%if>
</%def> </%def>
<%def userTables> <%def userTables>
<%java> <%java>
HTableDescriptor[] tables = admin.listTables(); HTableDescriptor[] tables = master.isInitialized() ? admin.listTables() : null;
</%java> </%java>
<%if (tables != null && tables.length > 0)%> <%if (tables != null && tables.length > 0)%>
<table class="table table-striped"> <table class="table table-striped">
@ -360,7 +365,7 @@ AssignmentManager assignmentManager = master.getAssignmentManager();
<%def userSnapshots> <%def userSnapshots>
<%java> <%java>
List<SnapshotDescription> snapshots = admin.listSnapshots(); List<SnapshotDescription> snapshots = master.isInitialized() ? admin.listSnapshots() : null;
</%java> </%java>
<%if (snapshots != null && snapshots.size() > 0)%> <%if (snapshots != null && snapshots.size() > 0)%>
<table class="table table-striped"> <table class="table table-striped">

View File

@ -722,6 +722,11 @@ public class HMaster extends HRegionServer implements MasterServices, Server {
tableNamespaceManager.start(); tableNamespaceManager.start();
} }
boolean isCatalogJanitorEnabled() {
return catalogJanitorChore != null ?
catalogJanitorChore.getEnabled() : false;
}
private void splitMetaLogBeforeAssignment(ServerName currentMetaServer) throws IOException { private void splitMetaLogBeforeAssignment(ServerName currentMetaServer) throws IOException {
if (this.distributedLogReplay) { if (this.distributedLogReplay) {
// In log replay mode, we mark hbase:meta region as recovering in ZK // In log replay mode, we mark hbase:meta region as recovering in ZK
@ -1503,14 +1508,22 @@ public class HMaster extends HRegionServer implements MasterServices, Server {
return s1.getServerName().compareTo(s2.getServerName()); return s1.getServerName().compareTo(s2.getServerName());
}}); }});
return new ClusterStatus(VersionInfo.getVersion(), String clusterId = fileSystemManager != null ?
this.fileSystemManager.getClusterId().toString(), fileSystemManager.getClusterId().toString() : null;
this.serverManager.getOnlineServers(), Map<String, RegionState> regionsInTransition = assignmentManager != null ?
this.serverManager.getDeadServers().copyServerNames(), assignmentManager.getRegionStates().getRegionsInTransition() : null;
this.serverName, String[] coprocessors = cpHost != null ? getMasterCoprocessors() : null;
backupMasters, boolean balancerOn = loadBalancerTracker != null ?
this.assignmentManager.getRegionStates().getRegionsInTransition(), loadBalancerTracker.isBalancerOn() : false;
this.getMasterCoprocessors(), this.loadBalancerTracker.isBalancerOn()); Map<ServerName, ServerLoad> onlineServers = null;
Set<ServerName> deadServers = null;
if (serverManager != null) {
deadServers = serverManager.getDeadServers().copyServerNames();
onlineServers = serverManager.getOnlineServers();
}
return new ClusterStatus(VersionInfo.getVersion(), clusterId,
onlineServers, deadServers, serverName, backupMasters,
regionsInTransition, coprocessors, balancerOn);
} }
/** /**

View File

@ -814,9 +814,8 @@ public class MasterRpcServices extends RSRpcServices
@Override @Override
public IsCatalogJanitorEnabledResponse isCatalogJanitorEnabled(RpcController c, public IsCatalogJanitorEnabledResponse isCatalogJanitorEnabled(RpcController c,
IsCatalogJanitorEnabledRequest req) throws ServiceException { IsCatalogJanitorEnabledRequest req) throws ServiceException {
boolean isEnabled = master.catalogJanitorChore != null ? return IsCatalogJanitorEnabledResponse.newBuilder().setValue(
master.catalogJanitorChore.getEnabled() : false; master.isCatalogJanitorEnabled()).build();
return IsCatalogJanitorEnabledResponse.newBuilder().setValue(isEnabled).build();
} }
@Override @Override

View File

@ -33,12 +33,9 @@ import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.client.HBaseAdmin; import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.protobuf.RequestConverter;
import org.apache.hadoop.hbase.tmpl.master.MasterStatusTmpl; import org.apache.hadoop.hbase.tmpl.master.MasterStatusTmpl;
import org.apache.hadoop.hbase.util.FSUtils; import org.apache.hadoop.hbase.util.FSUtils;
import com.google.protobuf.ServiceException;
/** /**
* The servlet responsible for rendering the index page of the * The servlet responsible for rendering the index page of the
* master. * master.
@ -57,12 +54,6 @@ public class MasterStatusServlet extends HttpServlet {
response.setContentType("text/html"); response.setContentType("text/html");
if (!master.isOnline()) {
response.getWriter().write("The Master is initializing!");
response.getWriter().close();
return;
}
Configuration conf = master.getConfiguration(); Configuration conf = master.getConfiguration();
HBaseAdmin admin = new HBaseAdmin(conf); HBaseAdmin admin = new HBaseAdmin(conf);
@ -72,29 +63,21 @@ public class MasterStatusServlet extends HttpServlet {
Set<ServerName> deadServers = null; Set<ServerName> deadServers = null;
if(master.isActiveMaster()) { if(master.isActiveMaster()) {
if (!master.isInitialized()) {
response.sendError(503, "Master not ready");
return;
}
metaLocation = getMetaLocationOrNull(master); metaLocation = getMetaLocationOrNull(master);
//ServerName metaLocation = master.getCatalogTracker().getMetaLocation(); ServerManager serverManager = master.getServerManager();
servers = master.getServerManager().getOnlineServersList(); if (serverManager != null) {
deadServers = master.getServerManager().getDeadServers().copyServerNames(); deadServers = serverManager.getDeadServers().copyServerNames();
servers = serverManager.getOnlineServersList();
}
} }
MasterStatusTmpl tmpl; MasterStatusTmpl tmpl = new MasterStatusTmpl()
try {
tmpl = new MasterStatusTmpl()
.setFrags(frags) .setFrags(frags)
.setMetaLocation(metaLocation) .setMetaLocation(metaLocation)
.setServers(servers) .setServers(servers)
.setDeadServers(deadServers) .setDeadServers(deadServers)
.setCatalogJanitorEnabled(master.getMasterRpcServices().isCatalogJanitorEnabled( .setCatalogJanitorEnabled(master.isCatalogJanitorEnabled());
null, RequestConverter.buildIsCatalogJanitorEnabledRequest()).getValue());
} catch (ServiceException s) {
admin.close();
throw new IOException(s);
}
if (request.getParameter("filter") != null) if (request.getParameter("filter") != null)
tmpl.setFilter(request.getParameter("filter")); tmpl.setFilter(request.getParameter("filter"));
if (request.getParameter("format") != null) if (request.getParameter("format") != null)

View File

@ -427,13 +427,12 @@ public class ServerManager {
public double getAverageLoad() { public double getAverageLoad() {
int totalLoad = 0; int totalLoad = 0;
int numServers = 0; int numServers = 0;
double averageLoad;
for (ServerLoad sl: this.onlineServers.values()) { for (ServerLoad sl: this.onlineServers.values()) {
numServers++; numServers++;
totalLoad += sl.getNumberOfRegions(); totalLoad += sl.getNumberOfRegions();
} }
averageLoad = (double)totalLoad / (double)numServers; return numServers == 0 ? 0 :
return averageLoad; (double)totalLoad / (double)numServers;
} }
/** /**