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