Skip to content

Commit 2da2f60

Browse files
authored
HBASE-30284 FNFE when viewing MOB Files of a MOB table restored from snapshot in HBase UI (#8466) (#8470)
Signed-off-by: Xiao Liu <liuxiaocs@apache.org>
1 parent 5b8b504 commit 2da2f60

1 file changed

Lines changed: 29 additions & 6 deletions

File tree

  • hbase-server/src/main/resources/hbase-webapps/regionserver

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

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@
2222
import="java.util.Collection"
2323
import="java.util.Date"
2424
import="java.util.List"
25-
import="org.apache.hadoop.fs.FileStatus"
25+
import="java.util.Map"
2626
import="org.apache.hadoop.fs.FileSystem"
27+
import="org.apache.hadoop.fs.FileStatus"
2728
import="org.apache.hadoop.fs.Path"
29+
import="org.apache.hadoop.hbase.TableName"
2830
import="org.apache.hadoop.hbase.client.RegionInfo"
2931
import="org.apache.hadoop.hbase.client.RegionInfoDisplay"
3032
import="org.apache.hadoop.hbase.mob.MobUtils"
@@ -33,6 +35,7 @@
3335
import="org.apache.hadoop.hbase.regionserver.HRegion"
3436
import="org.apache.hadoop.hbase.regionserver.HStore"
3537
import="org.apache.hadoop.hbase.regionserver.HStoreFile"
38+
import="org.apache.hadoop.hbase.util.CommonFSUtils"
3639
%>
3740
<%@ page import="java.nio.charset.StandardCharsets" %>
3841
<%
@@ -116,18 +119,38 @@
116119

117120
<%
118121
int mobCnt = 0;
122+
HMobStore mobStore = (HMobStore) store;
119123
for (HStoreFile sf : storeFiles) {
120124
try {
121125
byte[] value = sf.getMetadataValue(HStoreFile.MOB_FILE_REFS);
122126
if (value == null) {
123127
continue;
124128
}
125129
126-
Collection<String> fileNames = MobUtils.deserializeMobFileRefs(value).build().values();
127-
mobCnt += fileNames.size();
128-
for (String fileName : fileNames) {
129-
Path mobPath = new Path(((HMobStore) store).getPath(), fileName);
130-
FileStatus status = fs.getFileStatus(mobPath);
130+
for (Map.Entry<TableName, String> mobRef :
131+
MobUtils.deserializeMobFileRefs(value).build().entries()) {
132+
TableName mobTable = mobRef.getKey();
133+
String fileName = mobRef.getValue();
134+
Path mobPath = null;
135+
FileStatus status = null;
136+
for (Path candidate : mobStore.getLocations(mobTable)) {
137+
Path p = new Path(candidate, fileName);
138+
FileStatus[] fileStatuses = CommonFSUtils.listStatus(fs, p);
139+
if (fileStatuses == null) {
140+
continue;
141+
}
142+
mobPath = p;
143+
status = fileStatuses[0];
144+
break;
145+
}
146+
147+
if (mobPath == null) {
148+
// File not found in any known location (working dir or archive dir) for the referenced table.
149+
// Nothing to show on the UI, so skip it.
150+
continue;
151+
}
152+
153+
mobCnt ++;
131154
String mobPathStr = mobPath.toString();
132155
String encodedStr = URLEncoder.encode(mobPathStr, StandardCharsets.UTF_8.toString()); %>
133156

0 commit comments

Comments
 (0)