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>
This commit is contained in:
sreenivasulureddy 2019-09-05 11:42:31 +05:30 committed by Sakthi
parent b5b871c133
commit dd761b1e69
2 changed files with 15 additions and 2 deletions

View File

@ -20,7 +20,9 @@ package org.apache.hadoop.hbase.regionserver;
import java.io.DataInput;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.InetSocketAddress;
import java.net.URLEncoder;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Collection;
@ -287,6 +289,17 @@ public class StoreFile {
return this.fileInfo.getPath();
}
/**
* @return Encoded Path if this StoreFile was made with a Stream.
*/
public Path getEncodedPath() {
try {
return new Path(URLEncoder.encode(fileInfo.getPath().toString(), HConstants.UTF8_ENCODING));
} catch (UnsupportedEncodingException ex) {
throw new RuntimeException("URLEncoder doesn't support UTF-8", ex);
}
}
/**
* @return Returns the qualified path of this StoreFile
*/
@ -382,7 +395,7 @@ public class StoreFile {
/**
* Check if this storefile was created by bulk load.
* When a hfile is bulk loaded into HBase, we append
* '_SeqId_<id-when-loaded>' to the hfile name, unless
* '_SeqId_&lt;id-when-loaded&gt;' to the hfile name, unless
* "hbase.mapreduce.bulkload.assign.sequenceNumbers" is
* explicitly turned off.
* If "hbase.mapreduce.bulkload.assign.sequenceNumbers"

View File

@ -112,7 +112,7 @@
</tr>
<% for(StoreFile sf : storeFiles) { %>
<tr>
<td><a href="storeFile.jsp?name=<%= sf.getPath() %>"><%= sf.getPath() %></a></td>
<td><a href="storeFile.jsp?name=<%= sf.getEncodedPath() %>"><%= sf.getPath() %></a></td>
<td><%= (int) (rs.getFileSystem().getLength(sf.getPath()) / 1024 / 1024) %></td>
<td><%= new Date(sf.getModificationTimeStamp()) %></td>
</tr>