Skip to content

Commit ed001cb

Browse files
committed
FNFE may occur when accessing the region.jsp of the replica region
Fix the blanks issue
1 parent f0cfb87 commit ed001cb

File tree

1 file changed

+18
-10
lines changed
  • hbase-server/src/main/resources/hbase-webapps/regionserver

1 file changed

+18
-10
lines changed

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

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +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"
26-
import="org.apache.hadoop.hbase.regionserver.Region"
27-
import="org.apache.hadoop.hbase.regionserver.Store"
28-
import="org.apache.hadoop.hbase.regionserver.StoreFile"
28+
import="org.apache.hadoop.hbase.regionserver.HStoreFile"
29+
import="org.apache.hadoop.hbase.regionserver.HRegion"
30+
import="org.apache.hadoop.hbase.regionserver.HStore"
2931
%>
3032
<%
3133
String regionName = request.getParameter("name");
3234
HRegionServer rs = (HRegionServer) getServletContext().getAttribute(HRegionServer.REGIONSERVER);
35+
FileSystem fs = rs.getFileSystem();
3336
34-
Region region = rs.getRegion(regionName);
37+
HRegion region = rs.getRegion(regionName);
3538
String displayName;
39+
boolean isReplicaRegion = false;
3640
if (region != null) {
3741
displayName = RegionInfoDisplay.getRegionNameAsStringForDisplay(region.getRegionInfo(),
3842
rs.getConfiguration());
43+
isReplicaRegion = region.getRegionInfo().getReplicaId() > RegionInfo.DEFAULT_REPLICA_ID;
3944
} else {
4045
displayName = "region {" + regionName + "} is not currently online on this region server";
4146
}
@@ -53,10 +58,10 @@
5358
</div>
5459

5560
<% if(region != null) { //
56-
List<? extends Store> stores = region.getStores();
57-
for (Store store : stores) {
61+
List<HStore> stores = region.getStores();
62+
for (HStore store : stores) {
5863
String cf = store.getColumnFamilyName();
59-
Collection<? extends StoreFile> storeFiles = store.getStorefiles(); %>
64+
Collection<HStoreFile> storeFiles = store.getStorefiles(); %>
6065

6166
<h3>Column Family: <%= cf %></h3>
6267

@@ -70,15 +75,18 @@
7075
<th>Size (MB)</th>
7176
<th>Modification time</th>
7277
</tr>
73-
<% for(StoreFile sf : storeFiles) { %>
78+
<% int count = 0;
79+
for(HStoreFile sf : storeFiles) {
80+
if (isReplicaRegion && !fs.exists(sf.getPath())) continue;
81+
count++; %>
7482
<tr>
7583
<td><a href="storeFile.jsp?name=<%= sf.getEncodedPath() %>"><%= sf.getPath() %></a></td>
76-
<td><%= (int) (rs.getFileSystem().getLength(sf.getPath()) / 1024 / 1024) %></td>
84+
<td><%= (int) (fs.getLength(sf.getPath()) / 1024 / 1024) %></td>
7785
<td><%= new Date(sf.getModificationTimestamp()) %></td>
7886
</tr>
7987
<% } %>
8088

81-
<p> <%= storeFiles.size() %> StoreFile(s) in set.</p>
89+
<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>
8290
</table>
8391
<% }
8492
}%>

0 commit comments

Comments
 (0)