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:03:53 UTC

[hbase] branch branch-2 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-2
in repository https://gitbox.apache.org/repos/asf/hbase.git


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

commit 63593d6cce9a9acf52409bfd03882e8dfa847085
Author: sreenivasulureddy <sr...@huawei.com>
AuthorDate: Thu Sep 5 12:05:26 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 49718b8b46cd9e06aeef3f74647b32c6df99f7ae)
---
 .../org/apache/hadoop/hbase/regionserver/HStoreFile.java     | 12 ++++++++++++
 .../java/org/apache/hadoop/hbase/regionserver/StoreFile.java |  5 +++++
 .../src/main/resources/hbase-webapps/regionserver/region.jsp |  2 +-
 3 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStoreFile.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStoreFile.java
index 41ed3d7..e306d24 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStoreFile.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStoreFile.java
@@ -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;
@@ -264,6 +267,15 @@ public class HStoreFile implements StoreFile {
   }
 
   @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());
   }
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 0d2f461..7cfdfee 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
@@ -66,6 +66,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
    */
   Path getQualifiedPath();
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 ff83374..8183c69 100644
--- a/hbase-server/src/main/resources/hbase-webapps/regionserver/region.jsp
+++ b/hbase-server/src/main/resources/hbase-webapps/regionserver/region.jsp
@@ -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>