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:
parent
81bebaee81
commit
a0a7cb53ca
|
@ -198,7 +198,9 @@ AssignmentManager assignmentManager = master.getAssignmentManager();
|
|||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<%if master.getAssignmentManager() != null %>
|
||||
<& AssignmentManagerStatusTmpl; assignmentManager=master.getAssignmentManager()&>
|
||||
</%if>
|
||||
<%else>
|
||||
<section>
|
||||
<& BackupMasterStatusTmpl; master = master &>
|
||||
|
@ -266,7 +268,8 @@ AssignmentManager assignmentManager = master.getAssignmentManager();
|
|||
</tr>
|
||||
<tr>
|
||||
<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>
|
||||
</tr>
|
||||
<%if frags != null %>
|
||||
|
@ -278,7 +281,8 @@ AssignmentManager assignmentManager = master.getAssignmentManager();
|
|||
</%if>
|
||||
<tr>
|
||||
<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>
|
||||
</tr>
|
||||
</%if>
|
||||
|
@ -295,10 +299,10 @@ AssignmentManager assignmentManager = master.getAssignmentManager();
|
|||
|
||||
<%def catalogTables>
|
||||
<%java>
|
||||
HTableDescriptor[] sysTables = admin.listTableDescriptorsByNamespace(NamespaceDescriptor
|
||||
.SYSTEM_NAMESPACE_NAME_STR);
|
||||
HTableDescriptor[] sysTables = master.isInitialized() ? admin.listTableDescriptorsByNamespace(
|
||||
NamespaceDescriptor.SYSTEM_NAMESPACE_NAME_STR) : null;
|
||||
</%java>
|
||||
|
||||
<%if (sysTables != null && sysTables.length > 0)%>
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
<th>Table Name</th>
|
||||
|
@ -326,11 +330,12 @@ AssignmentManager assignmentManager = master.getAssignmentManager();
|
|||
</tr>
|
||||
</%for>
|
||||
</table>
|
||||
</%if>
|
||||
</%def>
|
||||
|
||||
<%def userTables>
|
||||
<%java>
|
||||
HTableDescriptor[] tables = admin.listTables();
|
||||
HTableDescriptor[] tables = master.isInitialized() ? admin.listTables() : null;
|
||||
</%java>
|
||||
<%if (tables != null && tables.length > 0)%>
|
||||
<table class="table table-striped">
|
||||
|
@ -360,7 +365,7 @@ AssignmentManager assignmentManager = master.getAssignmentManager();
|
|||
|
||||
<%def userSnapshots>
|
||||
<%java>
|
||||
List<SnapshotDescription> snapshots = admin.listSnapshots();
|
||||
List<SnapshotDescription> snapshots = master.isInitialized() ? admin.listSnapshots() : null;
|
||||
</%java>
|
||||
<%if (snapshots != null && snapshots.size() > 0)%>
|
||||
<table class="table table-striped">
|
||||
|
|
|
@ -722,6 +722,11 @@ public class HMaster extends HRegionServer implements MasterServices, Server {
|
|||
tableNamespaceManager.start();
|
||||
}
|
||||
|
||||
boolean isCatalogJanitorEnabled() {
|
||||
return catalogJanitorChore != null ?
|
||||
catalogJanitorChore.getEnabled() : false;
|
||||
}
|
||||
|
||||
private void splitMetaLogBeforeAssignment(ServerName currentMetaServer) throws IOException {
|
||||
if (this.distributedLogReplay) {
|
||||
// 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 new ClusterStatus(VersionInfo.getVersion(),
|
||||
this.fileSystemManager.getClusterId().toString(),
|
||||
this.serverManager.getOnlineServers(),
|
||||
this.serverManager.getDeadServers().copyServerNames(),
|
||||
this.serverName,
|
||||
backupMasters,
|
||||
this.assignmentManager.getRegionStates().getRegionsInTransition(),
|
||||
this.getMasterCoprocessors(), this.loadBalancerTracker.isBalancerOn());
|
||||
String clusterId = fileSystemManager != null ?
|
||||
fileSystemManager.getClusterId().toString() : null;
|
||||
Map<String, RegionState> regionsInTransition = assignmentManager != null ?
|
||||
assignmentManager.getRegionStates().getRegionsInTransition() : null;
|
||||
String[] coprocessors = cpHost != null ? getMasterCoprocessors() : null;
|
||||
boolean balancerOn = loadBalancerTracker != null ?
|
||||
loadBalancerTracker.isBalancerOn() : false;
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -814,9 +814,8 @@ public class MasterRpcServices extends RSRpcServices
|
|||
@Override
|
||||
public IsCatalogJanitorEnabledResponse isCatalogJanitorEnabled(RpcController c,
|
||||
IsCatalogJanitorEnabledRequest req) throws ServiceException {
|
||||
boolean isEnabled = master.catalogJanitorChore != null ?
|
||||
master.catalogJanitorChore.getEnabled() : false;
|
||||
return IsCatalogJanitorEnabledResponse.newBuilder().setValue(isEnabled).build();
|
||||
return IsCatalogJanitorEnabledResponse.newBuilder().setValue(
|
||||
master.isCatalogJanitorEnabled()).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -33,12 +33,9 @@ import org.apache.hadoop.classification.InterfaceAudience;
|
|||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hbase.ServerName;
|
||||
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.util.FSUtils;
|
||||
|
||||
import com.google.protobuf.ServiceException;
|
||||
|
||||
/**
|
||||
* The servlet responsible for rendering the index page of the
|
||||
* master.
|
||||
|
@ -57,12 +54,6 @@ public class MasterStatusServlet extends HttpServlet {
|
|||
|
||||
response.setContentType("text/html");
|
||||
|
||||
if (!master.isOnline()) {
|
||||
response.getWriter().write("The Master is initializing!");
|
||||
response.getWriter().close();
|
||||
return;
|
||||
}
|
||||
|
||||
Configuration conf = master.getConfiguration();
|
||||
HBaseAdmin admin = new HBaseAdmin(conf);
|
||||
|
||||
|
@ -72,29 +63,21 @@ public class MasterStatusServlet extends HttpServlet {
|
|||
Set<ServerName> deadServers = null;
|
||||
|
||||
if(master.isActiveMaster()) {
|
||||
if (!master.isInitialized()) {
|
||||
response.sendError(503, "Master not ready");
|
||||
return;
|
||||
}
|
||||
metaLocation = getMetaLocationOrNull(master);
|
||||
//ServerName metaLocation = master.getCatalogTracker().getMetaLocation();
|
||||
servers = master.getServerManager().getOnlineServersList();
|
||||
deadServers = master.getServerManager().getDeadServers().copyServerNames();
|
||||
ServerManager serverManager = master.getServerManager();
|
||||
if (serverManager != null) {
|
||||
deadServers = serverManager.getDeadServers().copyServerNames();
|
||||
servers = serverManager.getOnlineServersList();
|
||||
}
|
||||
}
|
||||
|
||||
MasterStatusTmpl tmpl;
|
||||
try {
|
||||
tmpl = new MasterStatusTmpl()
|
||||
MasterStatusTmpl tmpl = new MasterStatusTmpl()
|
||||
.setFrags(frags)
|
||||
.setMetaLocation(metaLocation)
|
||||
.setServers(servers)
|
||||
.setDeadServers(deadServers)
|
||||
.setCatalogJanitorEnabled(master.getMasterRpcServices().isCatalogJanitorEnabled(
|
||||
null, RequestConverter.buildIsCatalogJanitorEnabledRequest()).getValue());
|
||||
} catch (ServiceException s) {
|
||||
admin.close();
|
||||
throw new IOException(s);
|
||||
}
|
||||
.setCatalogJanitorEnabled(master.isCatalogJanitorEnabled());
|
||||
|
||||
if (request.getParameter("filter") != null)
|
||||
tmpl.setFilter(request.getParameter("filter"));
|
||||
if (request.getParameter("format") != null)
|
||||
|
|
|
@ -427,13 +427,12 @@ public class ServerManager {
|
|||
public double getAverageLoad() {
|
||||
int totalLoad = 0;
|
||||
int numServers = 0;
|
||||
double averageLoad;
|
||||
for (ServerLoad sl: this.onlineServers.values()) {
|
||||
numServers++;
|
||||
totalLoad += sl.getNumberOfRegions();
|
||||
}
|
||||
averageLoad = (double)totalLoad / (double)numServers;
|
||||
return averageLoad;
|
||||
return numServers == 0 ? 0 :
|
||||
(double)totalLoad / (double)numServers;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue