Skip to content

Commit 3ec493c

Browse files
authored
HBASE-28753 FNFE may occur when accessing the region.jsp of the replica region (branch-2) (#6118)
Signed-off-by: Duo Zhang <[email protected]> Signed-off-by: Pankaj Kumar <[email protected]>
1 parent 6e81029 commit 3ec493c

File tree

1 file changed

+19
-12
lines changed
  • hbase-server/src/main/resources/hbase-webapps/regionserver

1 file changed

+19
-12
lines changed

hbase-server/src/main/resources/hbase-webapps/regionserver/region.jsp

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,26 @@
2121
import="java.util.Collection"
2222
import="java.util.Date"
2323
import="java.util.List"
24+
import="org.apache.hadoop.fs.FileSystem"
25+
import="org.apache.hadoop.hbase.client.RegionInfo"
2426
import="org.apache.hadoop.hbase.client.RegionInfoDisplay"
2527
import="org.apache.hadoop.hbase.regionserver.HRegionServer"
2628
import="org.apache.hadoop.hbase.regionserver.HStoreFile"
27-
import="org.apache.hadoop.hbase.regionserver.Region"
28-
import="org.apache.hadoop.hbase.regionserver.Store"
29-
import="org.apache.hadoop.hbase.regionserver.StoreFile"
29+
import="org.apache.hadoop.hbase.regionserver.HRegion"
30+
import="org.apache.hadoop.hbase.regionserver.HStore"
3031
%>
3132
<%
3233
String regionName = request.getParameter("name");
3334
HRegionServer rs = (HRegionServer) getServletContext().getAttribute(HRegionServer.REGIONSERVER);
35+
FileSystem fs = rs.getFileSystem();
3436
35-
Region region = rs.getRegion(regionName);
37+
HRegion region = rs.getRegion(regionName);
3638
String displayName;
39+
boolean isReplicaRegion = false;
3740
if (region != null) {
3841
displayName = RegionInfoDisplay.getRegionNameAsStringForDisplay(region.getRegionInfo(),
3942
rs.getConfiguration());
43+
isReplicaRegion = region.getRegionInfo().getReplicaId() > RegionInfo.DEFAULT_REPLICA_ID;
4044
} else {
4145
displayName = "region {" + regionName + "} is not currently online on this region server";
4246
}
@@ -54,10 +58,10 @@
5458
</div>
5559

5660
<% if(region != null) { //
57-
List<? extends Store> stores = region.getStores();
58-
for (Store store : stores) {
61+
List<HStore> stores = region.getStores();
62+
for (HStore store : stores) {
5963
String cf = store.getColumnFamilyName();
60-
Collection<? extends StoreFile> storeFiles = store.getStorefiles(); %>
64+
Collection<HStoreFile> storeFiles = store.getStorefiles(); %>
6165

6266
<h3>Column Family: <%= cf %></h3>
6367

@@ -73,17 +77,20 @@
7377
<th>Len Of Biggest Cell</th>
7478
<th>Key Of Biggest Cell</th>
7579
</tr>
76-
<% for(StoreFile sf : storeFiles) { %>
80+
<% int count = 0;
81+
for(HStoreFile sf : storeFiles) {
82+
if (isReplicaRegion && !fs.exists(sf.getPath())) continue;
83+
count++; %>
7784
<tr>
7885
<td><a href="storeFile.jsp?name=<%= sf.getEncodedPath() %>"><%= sf.getPath() %></a></td>
79-
<td><%= (int) (rs.getFileSystem().getLength(sf.getPath()) / 1024 / 1024) %></td>
86+
<td><%= (int) (fs.getLength(sf.getPath()) / 1024 / 1024) %></td>
8087
<td><%= new Date(sf.getModificationTimestamp()) %></td>
81-
<td><%= String.format("%,1d", ((HStoreFile)sf).getFileInfo().getHFileInfo().getLenOfBiggestCell()) %></td>
82-
<td><%= ((HStoreFile)sf).getFileInfo().getHFileInfo().getKeyOfBiggestCell() %></td>
88+
<td><%= String.format("%,1d", sf.getFileInfo().getHFileInfo().getLenOfBiggestCell()) %></td>
89+
<td><%= sf.getFileInfo().getHFileInfo().getKeyOfBiggestCell() %></td>
8390
</tr>
8491
<% } %>
8592

86-
<p> <%= storeFiles.size() %> StoreFile(s) in set.</p>
93+
<p> <%= count %> StoreFile(s) in set. <%= isReplicaRegion ? "The information about storefile(s) may not up-to-date because it's not the primary region." : "" %></p>
8794
</table>
8895
<% }
8996
}%>

0 commit comments

Comments
 (0)