Skip to content

Commit

Permalink
HBASE-28753 FNFE may occur when accessing the region.jsp of the repli…
Browse files Browse the repository at this point in the history
…ca region (#6117)

Signed-off-by: Duo Zhang <zhangduo@apache.org>
Signed-off-by: Pankaj Kumar <pankajkumar@apache.org>
(cherry picked from commit 6d89c63)
  • Loading branch information
guluo2016 authored and Apache9 committed Jul 27, 2024
1 parent ee7d822 commit 67a3085
Showing 1 changed file with 25 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,31 @@
import="java.util.Collection"
import="java.util.Date"
import="java.util.List"
import="org.apache.hadoop.fs.FileSystem"
import="org.apache.hadoop.fs.FileStatus"
import="org.apache.hadoop.fs.Path"
import="org.apache.hadoop.hbase.HConstants"
import="org.apache.hadoop.hbase.client.RegionInfo"
import="org.apache.hadoop.hbase.client.RegionInfoDisplay"
import="org.apache.hadoop.hbase.mob.MobUtils"
import="org.apache.hadoop.hbase.regionserver.HRegionServer"
import="org.apache.hadoop.hbase.regionserver.HMobStore"
import="org.apache.hadoop.hbase.regionserver.HStoreFile"
import="org.apache.hadoop.hbase.regionserver.Region"
import="org.apache.hadoop.hbase.regionserver.Store"
import="org.apache.hadoop.hbase.regionserver.StoreFile"
import="org.apache.hadoop.hbase.regionserver.HRegion"
import="org.apache.hadoop.hbase.regionserver.HStore"
%>
<%
String regionName = request.getParameter("name");
HRegionServer rs = (HRegionServer) getServletContext().getAttribute(HRegionServer.REGIONSERVER);
FileSystem fs = rs.getFileSystem();
Region region = rs.getRegion(regionName);
HRegion 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";
}
Expand All @@ -59,11 +63,11 @@
</div>
</div>

<% if(region != null) { //
List<? extends Store> stores = region.getStores();
for (Store store : stores) {
<% if(region != null) {
List<HStore> stores = region.getStores();
for (HStore store : stores) {
String cf = store.getColumnFamilyName();
Collection<? extends StoreFile> storeFiles = store.getStorefiles(); %>
Collection<HStoreFile> storeFiles = store.getStorefiles(); %>

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

Expand All @@ -79,17 +83,20 @@
<th>Len Of Biggest Cell</th>
<th>Key Of Biggest Cell</th>
</tr>
<% for(StoreFile sf : storeFiles) { %>
<% int count = 0;
for(HStoreFile sf : storeFiles) {
if (isReplicaRegion && !fs.exists(sf.getPath())) continue;
count ++; %>
<tr>
<td><a href="storeFile.jsp?name=<%= sf.getEncodedPath() %>"><%= sf.getPath() %></a></td>
<td><%= (int) (rs.getFileSystem().getLength(sf.getPath()) / 1024 / 1024) %></td>
<td><%= (int) (fs.getLength(sf.getPath()) / 1024 / 1024) %></td>
<td><%= new Date(sf.getModificationTimestamp()) %></td>
<td><%= String.format("%,1d", ((HStoreFile)sf).getFileInfo().getHFileInfo().getLenOfBiggestCell()) %></td>
<td><%= ((HStoreFile)sf).getFileInfo().getHFileInfo().getKeyOfBiggestCell() %></td>
<td><%= String.format("%,1d", sf.getFileInfo().getHFileInfo().getLenOfBiggestCell()) %></td>
<td><%= sf.getFileInfo().getHFileInfo().getKeyOfBiggestCell() %></td>
</tr>
<% } %>

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

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

<%
int mobCnt = 0;
for (StoreFile sf : storeFiles) {
for (HStoreFile sf : storeFiles) {
try {
byte[] value = ((HStoreFile)sf).getMetadataValue(HStoreFile.MOB_FILE_REFS);
byte[] value = sf.getMetadataValue(HStoreFile.MOB_FILE_REFS);
if (value == null) {
continue;
}
Collection<String> fileNames = MobUtils.deserializeMobFileRefs(value).build().values();
mobCnt += fileNames.size();
for (String fileName : fileNames) {
Path mobPath = new Path(((HMobStore) store).getPath(), fileName);
if (isReplicaRegion && !fs.exists(mobPath)) continue;
mobCnt ++;
FileStatus status = rs.getFileSystem().getFileStatus(mobPath);
String mobPathStr = mobPath.toString();
String encodedStr = URLEncoder.encode(mobPathStr, HConstants.UTF8_ENCODING); %>
Expand All @@ -132,7 +140,7 @@
<% }
} %>

<p> <%= mobCnt %> MobFile(s) in set.</p>
<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>
</table>
<% }
}
Expand Down

0 comments on commit 67a3085

Please sign in to comment.