This is an automated email from the ASF dual-hosted git repository.
taklwu pushed a commit to branch branch-3
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-3 by this push:
new 7a2f7732605 HBASE-29362 Fix Incorrect JSON Format in RegionServer Web
Console Block Cache Status (#7047) (#7060)
7a2f7732605 is described below
commit 7a2f773260560a27d8a68d6eec8ba4b82fe3f595
Author: Tak Lon (Stephen) Wu <[email protected]>
AuthorDate: Wed Jun 4 10:05:44 2025 -0700
HBASE-29362 Fix Incorrect JSON Format in RegionServer Web Console Block
Cache Status (#7047) (#7060)
Signed-off-by: Tak Lon (Stephen) Wu <[email protected]>
(cherry-pick 539f7b7d4788361b191d5e1eea85c0d38e4b0fe5)
Co-authored-by: EungsopYoo <[email protected]>
---
.../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"));