You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ta...@apache.org on 2025/06/06 00:52:34 UTC
(hbase) branch branch-2 updated: HBASE-29362 Fix Incorrect JSON Format in RegionServer Web Console Block Cache Status (#7047) (#7061)
This is an automated email from the ASF dual-hosted git repository.
taklwu 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 74f3ec292a2 HBASE-29362 Fix Incorrect JSON Format in RegionServer Web Console Block Cache Status (#7047) (#7061)
74f3ec292a2 is described below
commit 74f3ec292a223cd6f26e57586a8e0d33bcd69f0f
Author: Tak Lon (Stephen) Wu <ta...@apache.org>
AuthorDate: Thu Jun 5 17:52:28 2025 -0700
HBASE-29362 Fix Incorrect JSON Format in RegionServer Web Console Block Cache Status (#7047) (#7061)
Signed-off-by: Tak Lon (Stephen) Wu <ta...@apache.org>
(cherry-pick 539f7b7d4788361b191d5e1eea85c0d38e4b0fe5)
Co-authored-by: EungsopYoo <rs...@hanmail.net>
---
.../hadoop/hbase/tmpl/regionserver/BlockCacheViewTmpl.jamon | 12 +++++++++++-
.../hadoop/hbase/regionserver/http/RSStatusServlet.java | 9 +++++++--
2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/BlockCacheViewTmpl.jamon b/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/BlockCacheViewTmpl.jamon
index d5a9aa54e6f..ce55aaf1270 100644
--- a/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/BlockCacheViewTmpl.jamon
+++ b/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/BlockCacheViewTmpl.jamon
@@ -66,5 +66,15 @@ cbsbf = null;
<%args>
CachedBlocksByFile cbsbf;
</%args>
-[<%for Map.Entry<String, NavigableSet<CachedBlock>> e: cbsbf.getCachedBlockStatsByFile().entrySet() %><% BlockCacheUtil.toJSON(e.getKey(), e.getValue()) %></%for>]
+<%java>
+ boolean firstEntry = true;
+</%java>
+[<%for Map.Entry<String, NavigableSet<CachedBlock>> e: cbsbf.getCachedBlockStatsByFile().entrySet() %>
+ <%if !firstEntry %>,</%if><% BlockCacheUtil.toJSON(e.getKey(), e.getValue()) %>
+ <%java>
+ if (firstEntry) {
+ firstEntry = false;
+ }
+ </%java>
+</%for>]
</%def>
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/http/RSStatusServlet.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/http/RSStatusServlet.java
index b9bf2da6080..43bac8791b4 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/http/RSStatusServlet.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/http/RSStatusServlet.java
@@ -37,7 +37,12 @@ public class RSStatusServlet extends HttpServlet {
(HRegionServer) getServletContext().getAttribute(HRegionServer.REGIONSERVER);
assert hrs != null : "No RS in context!";
- resp.setContentType("text/html");
+ String format = req.getParameter("format");
+ if ("json".equals(format)) {
+ resp.setContentType("application/json");
+ } else {
+ resp.setContentType("text/html");
+ }
if (!hrs.isOnline()) {
resp.getWriter().write("The RegionServer is initializing!");
@@ -46,7 +51,7 @@ public class RSStatusServlet extends HttpServlet {
}
RSStatusTmpl tmpl = new RSStatusTmpl();
- if (req.getParameter("format") != null) tmpl.setFormat(req.getParameter("format"));
+ if (format != null) tmpl.setFormat(format);
if (req.getParameter("filter") != null) tmpl.setFilter(req.getParameter("filter"));
if (req.getParameter("bcn") != null) tmpl.setBcn(req.getParameter("bcn"));
if (req.getParameter("bcv") != null) tmpl.setBcv(req.getParameter("bcv"));