You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by sa...@apache.org on 2019/09/20 08:29:39 UTC

[hbase] branch branch-1.4 updated: HBASE-22649: Encode StoreFile path URLs in the UI to handle scenarios where CF contains special characters (like # etc.)

This is an automated email from the ASF dual-hosted git repository.

sakthi pushed a commit to branch branch-1.4
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-1.4 by this push:
     new 4161008  HBASE-22649: Encode StoreFile path URLs in the UI to handle scenarios where CF contains special characters (like # etc.)
4161008 is described below

commit 4161008f5d1f1c29ca869189ff2eff79d60d3fd2
Author: sreenivasulureddy <sr...@huawei.com>
AuthorDate: Thu Sep 5 11:42:31 2019 +0530

    HBASE-22649: Encode StoreFile path URLs in the UI to handle scenarios where CF contains special characters (like # etc.)
    
    Signed-off-by: Sakthi<sa...@apache.org>
    (cherry picked from commit dd761b1e69cde2120b0ce4a6ebaf7d901717c14f)
---
 .../org/apache/hadoop/hbase/regionserver/StoreFile.java   | 15 ++++++++++++++-
 .../main/resources/hbase-webapps/regionserver/region.jsp  |  2 +-
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java
index 5568441..7fa450d 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java
@@ -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;
@@ -286,6 +288,17 @@ public class StoreFile {
   }
 
   /**
+   * @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
    */
   public Path getQualifiedPath() {
@@ -380,7 +393,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"
diff --git a/hbase-server/src/main/resources/hbase-webapps/regionserver/region.jsp b/hbase-server/src/main/resources/hbase-webapps/regionserver/region.jsp
index 62e1b66..63e3bce 100644
--- a/hbase-server/src/main/resources/hbase-webapps/regionserver/region.jsp
+++ b/hbase-server/src/main/resources/hbase-webapps/regionserver/region.jsp
@@ -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>