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 12:05:26 +05:30 committed by Sakthi
parent 0ec0a9403f
commit 49718b8b46
No known key found for this signature in database
GPG Key ID: DBD8A084851528A6
3 changed files with 18 additions and 1 deletions

View File

@ -19,6 +19,8 @@
package org.apache.hadoop.hbase.regionserver;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
@ -33,6 +35,7 @@ import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellComparator;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HDFSBlocksDistribution;
import org.apache.hadoop.hbase.io.TimeRange;
import org.apache.hadoop.hbase.io.hfile.BlockType;
@ -263,6 +266,15 @@ public class HStoreFile implements StoreFile {
return this.fileInfo.getPath();
}
@Override
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);
}
}
@Override
public Path getQualifiedPath() {
return this.fileInfo.getPath().makeQualified(fs.getUri(), fs.getWorkingDirectory());

View File

@ -65,6 +65,11 @@ public interface StoreFile {
*/
Path getPath();
/**
* @return Encoded Path if this StoreFile was made with a Stream.
*/
Path getEncodedPath();
/**
* @return Returns the qualified path of this StoreFile
*/

View File

@ -67,7 +67,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>