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

zhangduo 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 54123b33155 HBASE-29940 GC Collector stats can't be displayed properly 
in JDK21 (#7822)
54123b33155 is described below

commit 54123b33155d5228f219930ffe631bc775f2faee
Author: Liu Xiao <[email protected]>
AuthorDate: Fri Mar 6 14:53:38 2026 +0800

    HBASE-29940 GC Collector stats can't be displayed properly in JDK21 (#7822)
    
    Signed-off-by: Duo Zhang <[email protected]>
---
 .../hbase-webapps/master/processMaster.jsp         | 59 +++++++--------------
 .../hbase-webapps/regionserver/processRS.jsp       | 61 ++++++++--------------
 2 files changed, 41 insertions(+), 79 deletions(-)

diff --git 
a/hbase-server/src/main/resources/hbase-webapps/master/processMaster.jsp 
b/hbase-server/src/main/resources/hbase-webapps/master/processMaster.jsp
index 73630317600..c9ed0f43d85 100644
--- a/hbase-server/src/main/resources/hbase-webapps/master/processMaster.jsp
+++ b/hbase-server/src/main/resources/hbase-webapps/master/processMaster.jsp
@@ -35,12 +35,6 @@ ObjectName jvmMetrics = new 
ObjectName("Hadoop:service=HBase,name=JvmMetrics");
 
 // There is always two of GC collectors
 List<GarbageCollectorMXBean> gcBeans = JSONMetricUtil.getGcCollectorBeans();
-GarbageCollectorMXBean collector1 = null;
-GarbageCollectorMXBean collector2 = null;
-try {
-collector1 = gcBeans.get(0);
-collector2 = gcBeans.get(1);
-} catch(IndexOutOfBoundsException e) {}
 List<MemoryPoolMXBean> mPools = JSONMetricUtil.getMemoryPools();
 pageContext.setAttribute("pageTitle", "Process info for PID: " + 
JSONMetricUtil.getProcessPID());
 %>
@@ -79,10 +73,10 @@ pageContext.setAttribute("pageTitle", "Process info for 
PID: " + JSONMetricUtil.
   <table class="table table-striped" width="90%" >
     <tr>
         <th>ThreadsNew</th>
-        <th>ThreadsRunable</th>
+        <th>ThreadsRunnable</th>
         <th>ThreadsBlocked</th>
         <th>ThreadsWaiting</th>
-        <th>ThreadsTimeWaiting</th>
+        <th>ThreadsTimedWaiting</th>
         <th>ThreadsTerminated</th>
     </tr>
      <tr>
@@ -100,19 +94,21 @@ pageContext.setAttribute("pageTitle", "Process info for 
PID: " + JSONMetricUtil.
     <div class="page-header">
     <h2>GC Collectors</h2>
     </div>
-    </div>
-    <% if (gcBeans.size() == 2) { %>
+  </div>
+    <% if (gcBeans != null && !gcBeans.isEmpty()) { %>
 <div class="tabbable">
   <ul class="nav nav-pills" role="tablist">
+    <% int idx = 0; for (GarbageCollectorMXBean gc : gcBeans) { %>
     <li class="nav-item">
-      <a class="nav-link active" href="#tab_gc1" data-bs-toggle="tab" 
role="tab"><%=collector1.getName() %></a>
+      <a class="nav-link <%= idx == 0 ? "active" : "" %>" href="#tab_gc_<%= 
idx %>" data-bs-toggle="tab" role="tab">
+        <%= gc.getName() %>
+      </a>
     </li>
-    <li class="nav-item">
-      <a class="nav-link" href="#tab_gc2" data-bs-toggle="tab" 
role="tab"><%=collector2.getName() %></a>
-     </li>
+    <% idx++; } %>
   </ul>
     <div class="tab-content">
-      <div class="tab-pane active" id="tab_gc1" role="tabpanel">
+      <% idx = 0; long totalGcTime = 0; for (GarbageCollectorMXBean gc : 
gcBeans) { totalGcTime += gc.getCollectionTime(); %>
+      <div class="tab-pane <%= idx == 0 ? "active" : "" %>" id="tab_gc_<%= idx 
%>" role="tabpanel">
           <table class="table table-striped">
             <tr>
               <th>Collection Count</th>
@@ -120,35 +116,20 @@ pageContext.setAttribute("pageTitle", "Process info for 
PID: " + JSONMetricUtil.
               <th>Last duration</th>
             </tr>
             <tr>
-              <td> <%= collector1.getCollectionCount() %></td>
-              <td> <%= 
StringUtils.humanTimeDiff(collector1.getCollectionTime()) %> </td>
-              <td> <%= 
StringUtils.humanTimeDiff(JSONMetricUtil.getLastGcDuration(
-                collector1.getObjectName())) %></td>
+              <td><%= gc.getCollectionCount() %></td>
+              <td><%= StringUtils.humanTimeDiff(gc.getCollectionTime()) %></td>
+              <td><%= 
StringUtils.humanTimeDiff(JSONMetricUtil.getLastGcDuration(
+                gc.getObjectName())) %></td>
             </tr>
           </table>
       </div>
-      <div class="tab-pane" id="tab_gc2" role="tabpanel">
-        <table class="table table-striped">
-          <tr>
-            <th>Collection Count</th>
-            <th>Collection Time</th>
-             <th>Last duration</th>
-          </tr>
-          <tr>
-            <td> <%= collector2.getCollectionCount()  %></td>
-            <td> <%= StringUtils.humanTimeDiff(collector2.getCollectionTime()) 
%> </td>
-            <td> <%= 
StringUtils.humanTimeDiff(JSONMetricUtil.getLastGcDuration(
-              collector2.getObjectName())) %></td>
-          </tr>
-          </table>
-      </div>
+      <% idx++; } %>
       </div>
   </div>
-  <%} else { %>
-  <p> Can not display GC Collector stats.</p>
-  <%} %>
-  Total GC Collection time: <%= 
StringUtils.humanTimeDiff(collector1.getCollectionTime() +
-    collector2.getCollectionTime())%>
+  <p>Total GC Collection time: <%= StringUtils.humanTimeDiff(totalGcTime) 
%></p>
+  <% } else { %>
+  <p>Can not display GC Collector stats.</p>
+  <% } %>
 </div>
 <% for(MemoryPoolMXBean mp:mPools) {
 if(mp.getName().contains("Cache")) continue;%>
diff --git 
a/hbase-server/src/main/resources/hbase-webapps/regionserver/processRS.jsp 
b/hbase-server/src/main/resources/hbase-webapps/regionserver/processRS.jsp
index 9261de13f45..b1e1fe359ca 100644
--- a/hbase-server/src/main/resources/hbase-webapps/regionserver/processRS.jsp
+++ b/hbase-server/src/main/resources/hbase-webapps/regionserver/processRS.jsp
@@ -38,12 +38,6 @@ Object pauseInfoThresholdExceeded = 
JSONMetricUtil.getValueFromMBean(rsMetrics,
 
 // There is always two of GC collectors
 List<GarbageCollectorMXBean> gcBeans = JSONMetricUtil.getGcCollectorBeans();
-GarbageCollectorMXBean collector1 = null;
-GarbageCollectorMXBean collector2 = null;
-try {
-collector1 = gcBeans.get(0);
-collector2 = gcBeans.get(1);
-} catch(IndexOutOfBoundsException e) {}
 List<MemoryPoolMXBean> mPools = JSONMetricUtil.getMemoryPools();
 pageContext.setAttribute("pageTitle", "Process info for PID: " + 
JSONMetricUtil.getProcessPID());
 %>
@@ -85,10 +79,10 @@ pageContext.setAttribute("pageTitle", "Process info for 
PID: " + JSONMetricUtil.
   <table class="table table-striped" width="90%" >
     <tr>
         <th>ThreadsNew</th>
-        <th>ThreadsRunable</th>
+        <th>ThreadsRunnable</th>
         <th>ThreadsBlocked</th>
         <th>ThreadsWaiting</th>
-        <th>ThreadsTimeWaiting</th>
+        <th>ThreadsTimedWaiting</th>
         <th>ThreadsTerminated</th>
     </tr>
     <tr>
@@ -107,19 +101,21 @@ pageContext.setAttribute("pageTitle", "Process info for 
PID: " + JSONMetricUtil.
     <div class="page-header">
     <h2>GC Collectors</h2>
     </div>
-    </div>
-    <% if (gcBeans.size() == 2) { %>
+  </div>
+    <% if (gcBeans != null && !gcBeans.isEmpty()) { %>
 <div class="tabbable">
   <ul class="nav nav-pills" role="tablist">
+    <% int idx = 0; for (GarbageCollectorMXBean gc : gcBeans) { %>
     <li class="nav-item">
-      <a class="nav-link active" href="#tab_gc1" data-bs-toggle="tab" 
role="tab"><%=collector1.getName() %></a>
+      <a class="nav-link <%= idx == 0 ? "active" : "" %>" href="#tab_gc_<%= 
idx %>" data-bs-toggle="tab" role="tab">
+        <%= gc.getName() %>
+      </a>
     </li>
-    <li class="nav-item">
-      <a class="nav-link" href="#tab_gc2" data-bs-toggle="tab" 
role="tab"><%=collector2.getName() %></a>
-     </li>
+    <% idx++; } %>
   </ul>
     <div class="tab-content">
-      <div class="tab-pane active" id="tab_gc1" role="tabpanel">
+      <% idx = 0; long totalGcTime = 0; for (GarbageCollectorMXBean gc : 
gcBeans) { totalGcTime += gc.getCollectionTime(); %>
+      <div class="tab-pane <%= idx == 0 ? "active" : "" %>" id="tab_gc_<%= idx 
%>" role="tabpanel">
           <table class="table table-striped">
             <tr>
               <th>Collection Count</th>
@@ -127,35 +123,20 @@ pageContext.setAttribute("pageTitle", "Process info for 
PID: " + JSONMetricUtil.
               <th>Last duration</th>
             </tr>
             <tr>
-              <td> <%= collector1.getCollectionCount() %></td>
-              <td> <%= 
StringUtils.humanTimeDiff(collector1.getCollectionTime()) %> </td>
-              <td> <%= 
StringUtils.humanTimeDiff(JSONMetricUtil.getLastGcDuration(
-                collector1.getObjectName())) %></td>
+              <td><%= gc.getCollectionCount() %></td>
+              <td><%= StringUtils.humanTimeDiff(gc.getCollectionTime()) %></td>
+              <td><%= 
StringUtils.humanTimeDiff(JSONMetricUtil.getLastGcDuration(
+                gc.getObjectName())) %></td>
             </tr>
           </table>
       </div>
-      <div class="tab-pane" id="tab_gc2" role="tabpanel">
-        <table class="table table-striped">
-          <tr>
-            <th>Collection Count</th>
-            <th>Collection Time</th>
-             <th>Last duration</th>
-          </tr>
-          <tr>
-            <td> <%= collector2.getCollectionCount()  %></td>
-            <td> <%= StringUtils.humanTimeDiff(collector2.getCollectionTime()) 
%> </td>
-            <td> <%= 
StringUtils.humanTimeDiff(JSONMetricUtil.getLastGcDuration(
-              collector2.getObjectName())) %></td>
-          </tr>
-          </table>
+      <% idx++; } %>
       </div>
-      </div>
-  </div>
-  <%} else { %>
-  <p> Can not display GC Collector stats.</p>
-  <%} %>
-  Total GC Collection time: <%= 
StringUtils.humanTimeDiff(collector1.getCollectionTime() +
-    collector2.getCollectionTime())%>
+</div>
+<p>Total GC Collection time: <%= StringUtils.humanTimeDiff(totalGcTime) %></p>
+  <% } else { %>
+  <p>Can not display GC Collector stats.</p>
+  <% } %>
 </div>
 <% for(MemoryPoolMXBean mp:mPools) {
 if(mp.getName().contains("Cache")) continue;%>

Reply via email to