Skip to content

Commit

Permalink
NPE may occur when opening master-status or table.jsp or procedure.js…
Browse files Browse the repository at this point in the history
…p while Master is initializing
  • Loading branch information
guluo2016 committed Sep 5, 2024
1 parent fb9d89d commit 013e163
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ public void doGet(HttpServletRequest request, HttpServletResponse response) thro
private ServerName getMetaLocationOrNull(HMaster master) {
RegionStateNode rsn = master.getAssignmentManager().getRegionStates()
.getRegionStateNode(RegionInfoBuilder.FIRST_META_REGIONINFO);
return rsn.isInState(RegionState.State.OPEN) ? rsn.getRegionLocation() : null;
if (rsn != null) {
return rsn.isInState(RegionState.State.OPEN) ? rsn.getRegionLocation() : null;
}
return null;
}

private Map<String, Integer> getFragmentationInfo(HMaster master, Configuration conf)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,28 @@
<%@ page import="org.apache.hadoop.hbase.metrics.Histogram" %>
<%@ page import="java.util.TreeMap" %>
<%@ page import="org.apache.hadoop.hbase.metrics.impl.HistogramImpl" %>

<jsp:include page="header.jsp">
<jsp:param name="pageTitle" value="${pageTitle}"/>
</jsp:include>

<%
HMaster master = (HMaster) getServletContext().getAttribute(HMaster.MASTER);
if (!master.isInitialized()) {
%>
<div class="container-fluid content">
<div class="row inner_header">
<div class="page-header">
<h1>Master is initializing</h1>
</div>
</div>
<p><hr><p>
<jsp:include page="redirect.jsp" />
</div>
<% return;
} %>

<%
ProcedureExecutor<MasterProcedureEnv> procExecutor = master.getMasterProcedureExecutor();
List<Procedure<MasterProcedureEnv>> procedures = procExecutor.getProcedures();
Collections.sort(procedures, new Comparator<Procedure>() {
Expand All @@ -63,9 +83,6 @@
List<LockedResource> lockedResources = master.getLocks();
pageContext.setAttribute("pageTitle", "HBase Master Procedures: " + master.getServerName());
%>
<jsp:include page="header.jsp">
<jsp:param name="pageTitle" value="${pageTitle}"/>
</jsp:include>

<div class="container-fluid content">
<div class="row top_header">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,22 @@
String regionName = request.getParameter("name");
HRegionServer rs = (HRegionServer) getServletContext().getAttribute(HRegionServer.REGIONSERVER);
FileSystem fs = rs.getFileSystem();
HRegion region = rs.getRegion(regionName);
HRegion region = null;
if (regionName != null) {
region = rs.getRegion(regionName);
}
String displayName;
boolean isReplicaRegion = false;
if (region != null) {
displayName = RegionInfoDisplay.getRegionNameAsStringForDisplay(region.getRegionInfo(),
rs.getConfiguration());
isReplicaRegion = region.getRegionInfo().getReplicaId() > RegionInfo.DEFAULT_REPLICA_ID;
} else {
displayName = "region {" + regionName + "} is not currently online on this region server";
if (regionName != null) {
displayName = "region {" + regionName + "} is not currently online on this region server";
} else {
displayName = "you must specify a region name when accessing this page";
}
}
pageContext.setAttribute("pageTitle", "HBase RegionServer: " + rs.getServerName());
%>
Expand Down

0 comments on commit 013e163

Please sign in to comment.