Skip to content

Commit 67a3085

Browse files
guluo2016Apache9
authored andcommitted
HBASE-28753 FNFE may occur when accessing the region.jsp of the replica region (#6117)
Signed-off-by: Duo Zhang <zhangduo@apache.org> Signed-off-by: Pankaj Kumar <pankajkumar@apache.org> (cherry picked from commit 6d89c63)
1 parent ee7d822 commit 67a3085

File tree

1 file changed

+25
-17
lines changed
  • hbase-server/src/main/resources/hbase-webapps/regionserver

1 file changed

+25
-17
lines changed

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

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,31 @@
2222
import="java.util.Collection"
2323
import="java.util.Date"
2424
import="java.util.List"
25+
import="org.apache.hadoop.fs.FileSystem"
2526
import="org.apache.hadoop.fs.FileStatus"
2627
import="org.apache.hadoop.fs.Path"
2728
import="org.apache.hadoop.hbase.HConstants"
29+
import="org.apache.hadoop.hbase.client.RegionInfo"
2830
import="org.apache.hadoop.hbase.client.RegionInfoDisplay"
2931
import="org.apache.hadoop.hbase.mob.MobUtils"
3032
import="org.apache.hadoop.hbase.regionserver.HRegionServer"
3133
import="org.apache.hadoop.hbase.regionserver.HMobStore"
3234
import="org.apache.hadoop.hbase.regionserver.HStoreFile"
33-
import="org.apache.hadoop.hbase.regionserver.Region"
34-
import="org.apache.hadoop.hbase.regionserver.Store"
35-
import="org.apache.hadoop.hbase.regionserver.StoreFile"
35+
import="org.apache.hadoop.hbase.regionserver.HRegion"
36+
import="org.apache.hadoop.hbase.regionserver.HStore"
3637
%>
3738
<%
3839
String regionName = request.getParameter("name");
3940
HRegionServer rs = (HRegionServer) getServletContext().getAttribute(HRegionServer.REGIONSERVER);
41+
FileSystem fs = rs.getFileSystem();
4042
41-
Region region = rs.getRegion(regionName);
43+
HRegion region = rs.getRegion(regionName);
4244
String displayName;
45+
boolean isReplicaRegion = false;
4346
if (region != null) {
4447
displayName = RegionInfoDisplay.getRegionNameAsStringForDisplay(region.getRegionInfo(),
4548
rs.getConfiguration());
49+
isReplicaRegion = region.getRegionInfo().getReplicaId() > RegionInfo.DEFAULT_REPLICA_ID;
4650
} else {
4751
displayName = "region {" + regionName + "} is not currently online on this region server";
4852
}
@@ -59,11 +63,11 @@
5963
</div>
6064
</div>
6165

62-
<% if(region != null) { //
63-
List<? extends Store> stores = region.getStores();
64-
for (Store store : stores) {
66+
<% if(region != null) {
67+
List<HStore> stores = region.getStores();
68+
for (HStore store : stores) {
6569
String cf = store.getColumnFamilyName();
66-
Collection<? extends StoreFile> storeFiles = store.getStorefiles(); %>
70+
Collection<HStoreFile> storeFiles = store.getStorefiles(); %>
6771

6872
<h3>Column Family: <%= cf %></h3>
6973

@@ -79,17 +83,20 @@
7983
<th>Len Of Biggest Cell</th>
8084
<th>Key Of Biggest Cell</th>
8185
</tr>
82-
<% for(StoreFile sf : storeFiles) { %>
86+
<% int count = 0;
87+
for(HStoreFile sf : storeFiles) {
88+
if (isReplicaRegion && !fs.exists(sf.getPath())) continue;
89+
count ++; %>
8390
<tr>
8491
<td><a href="storeFile.jsp?name=<%= sf.getEncodedPath() %>"><%= sf.getPath() %></a></td>
85-
<td><%= (int) (rs.getFileSystem().getLength(sf.getPath()) / 1024 / 1024) %></td>
92+
<td><%= (int) (fs.getLength(sf.getPath()) / 1024 / 1024) %></td>
8693
<td><%= new Date(sf.getModificationTimestamp()) %></td>
87-
<td><%= String.format("%,1d", ((HStoreFile)sf).getFileInfo().getHFileInfo().getLenOfBiggestCell()) %></td>
88-
<td><%= ((HStoreFile)sf).getFileInfo().getHFileInfo().getKeyOfBiggestCell() %></td>
94+
<td><%= String.format("%,1d", sf.getFileInfo().getHFileInfo().getLenOfBiggestCell()) %></td>
95+
<td><%= sf.getFileInfo().getHFileInfo().getKeyOfBiggestCell() %></td>
8996
</tr>
9097
<% } %>
9198

92-
<p> <%= storeFiles.size() %> StoreFile(s) in set.</p>
99+
<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>
93100
</table>
94101

95102
<% if (store instanceof HMobStore) { %>
@@ -103,17 +110,18 @@
103110

104111
<%
105112
int mobCnt = 0;
106-
for (StoreFile sf : storeFiles) {
113+
for (HStoreFile sf : storeFiles) {
107114
try {
108-
byte[] value = ((HStoreFile)sf).getMetadataValue(HStoreFile.MOB_FILE_REFS);
115+
byte[] value = sf.getMetadataValue(HStoreFile.MOB_FILE_REFS);
109116
if (value == null) {
110117
continue;
111118
}
112119
113120
Collection<String> fileNames = MobUtils.deserializeMobFileRefs(value).build().values();
114-
mobCnt += fileNames.size();
115121
for (String fileName : fileNames) {
116122
Path mobPath = new Path(((HMobStore) store).getPath(), fileName);
123+
if (isReplicaRegion && !fs.exists(mobPath)) continue;
124+
mobCnt ++;
117125
FileStatus status = rs.getFileSystem().getFileStatus(mobPath);
118126
String mobPathStr = mobPath.toString();
119127
String encodedStr = URLEncoder.encode(mobPathStr, HConstants.UTF8_ENCODING); %>
@@ -132,7 +140,7 @@
132140
<% }
133141
} %>
134142

135-
<p> <%= mobCnt %> MobFile(s) in set.</p>
143+
<p> <%= mobCnt %> MobFile(s) in set. <%= isReplicaRegion ? "The information about MobFile(s) may not up-to-date because it's not the primary region." : "" %></p>
136144
</table>
137145
<% }
138146
}

0 commit comments

Comments
 (0)