Skip to content

Commit 62f267a

Browse files
sreenivasulureddythe-sakthi
authored andcommitted
HBASE-22649: Encode StoreFile path URLs in the UI to handle scenarios where CF contains special characters (like # etc.)
Signed-off-by: Sakthi<sakthi@apache.org> (cherry picked from commit dd761b1)
1 parent de2952b commit 62f267a

File tree

2 files changed

+15
-2
lines changed
  • hbase-server/src/main

2 files changed

+15
-2
lines changed

hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020

2121
import java.io.DataInput;
2222
import java.io.IOException;
23+
import java.io.UnsupportedEncodingException;
2324
import java.net.InetSocketAddress;
25+
import java.net.URLEncoder;
2426
import java.nio.ByteBuffer;
2527
import java.util.Arrays;
2628
import java.util.Collection;
@@ -282,6 +284,17 @@ public Path getPath() {
282284
return this.fileInfo.getPath();
283285
}
284286

287+
/**
288+
* @return Encoded Path if this StoreFile was made with a Stream.
289+
*/
290+
public Path getEncodedPath() {
291+
try {
292+
return new Path(URLEncoder.encode(fileInfo.getPath().toString(), HConstants.UTF8_ENCODING));
293+
} catch (UnsupportedEncodingException ex) {
294+
throw new RuntimeException("URLEncoder doesn't support UTF-8", ex);
295+
}
296+
}
297+
285298
/**
286299
* @return Returns the qualified path of this StoreFile
287300
*/
@@ -377,7 +390,7 @@ public static long getMaxSequenceIdInList(Collection<StoreFile> sfs) {
377390
/**
378391
* Check if this storefile was created by bulk load.
379392
* When a hfile is bulk loaded into HBase, we append
380-
* '_SeqId_<id-when-loaded>' to the hfile name, unless
393+
* '_SeqId_&lt;id-when-loaded&gt;' to the hfile name, unless
381394
* "hbase.mapreduce.bulkload.assign.sequenceNumbers" is
382395
* explicitly turned off.
383396
* If "hbase.mapreduce.bulkload.assign.sequenceNumbers"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
</tr>
113113
<% for(StoreFile sf : storeFiles) { %>
114114
<tr>
115-
<td><a href="storeFile.jsp?name=<%= sf.getPath() %>"><%= sf.getPath() %></a></td>
115+
<td><a href="storeFile.jsp?name=<%= sf.getEncodedPath() %>"><%= sf.getPath() %></a></td>
116116
<td><%= (int) (rs.getFileSystem().getLength(sf.getPath()) / 1024 / 1024) %></td>
117117
<td><%= new Date(sf.getModificationTimeStamp()) %></td>
118118
</tr>

0 commit comments

Comments
 (0)