Skip to content

Commit dbf97b7

Browse files
committed
HBASE-29940 GC Collector stats can't be displayed properly in JDK21
1 parent d070437 commit dbf97b7

2 files changed

Lines changed: 41 additions & 79 deletions

File tree

hbase-server/src/main/resources/hbase-webapps/master/processMaster.jsp

Lines changed: 20 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,6 @@ ObjectName jvmMetrics = new ObjectName("Hadoop:service=HBase,name=JvmMetrics");
3535
3636
// There is always two of GC collectors
3737
List<GarbageCollectorMXBean> gcBeans = JSONMetricUtil.getGcCollectorBeans();
38-
GarbageCollectorMXBean collector1 = null;
39-
GarbageCollectorMXBean collector2 = null;
40-
try {
41-
collector1 = gcBeans.get(0);
42-
collector2 = gcBeans.get(1);
43-
} catch(IndexOutOfBoundsException e) {}
4438
List<MemoryPoolMXBean> mPools = JSONMetricUtil.getMemoryPools();
4539
pageContext.setAttribute("pageTitle", "Process info for PID: " + JSONMetricUtil.getProcessPID());
4640
%>
@@ -79,10 +73,10 @@ pageContext.setAttribute("pageTitle", "Process info for PID: " + JSONMetricUtil.
7973
<table class="table table-striped" width="90%" >
8074
<tr>
8175
<th>ThreadsNew</th>
82-
<th>ThreadsRunable</th>
76+
<th>ThreadsRunnable</th>
8377
<th>ThreadsBlocked</th>
8478
<th>ThreadsWaiting</th>
85-
<th>ThreadsTimeWaiting</th>
79+
<th>ThreadsTimedWaiting</th>
8680
<th>ThreadsTerminated</th>
8781
</tr>
8882
<tr>
@@ -100,55 +94,42 @@ pageContext.setAttribute("pageTitle", "Process info for PID: " + JSONMetricUtil.
10094
<div class="page-header">
10195
<h2>GC Collectors</h2>
10296
</div>
103-
</div>
104-
<% if (gcBeans.size() == 2) { %>
97+
</div>
98+
<% if (gcBeans != null && !gcBeans.isEmpty()) { %>
10599
<div class="tabbable">
106100
<ul class="nav nav-pills" role="tablist">
101+
<% int idx = 0; for (GarbageCollectorMXBean gc : gcBeans) { %>
107102
<li class="nav-item">
108-
<a class="nav-link active" href="#tab_gc1" data-bs-toggle="tab" role="tab"><%=collector1.getName() %></a>
103+
<a class="nav-link <%= idx == 0 ? "active" : "" %>" href="#tab_gc_<%= idx %>" data-bs-toggle="tab" role="tab">
104+
<%= gc.getName() %>
105+
</a>
109106
</li>
110-
<li class="nav-item">
111-
<a class="nav-link" href="#tab_gc2" data-bs-toggle="tab" role="tab"><%=collector2.getName() %></a>
112-
</li>
107+
<% idx++; } %>
113108
</ul>
114109
<div class="tab-content">
115-
<div class="tab-pane active" id="tab_gc1" role="tabpanel">
110+
<% idx = 0; long totalGcTime = 0; for (GarbageCollectorMXBean gc : gcBeans) { totalGcTime += gc.getCollectionTime(); %>
111+
<div class="tab-pane <%= idx == 0 ? "active" : "" %>" id="tab_gc_<%= idx %>" role="tabpanel">
116112
<table class="table table-striped">
117113
<tr>
118114
<th>Collection Count</th>
119115
<th>Collection Time</th>
120116
<th>Last duration</th>
121117
</tr>
122118
<tr>
123-
<td> <%= collector1.getCollectionCount() %></td>
124-
<td> <%= StringUtils.humanTimeDiff(collector1.getCollectionTime()) %> </td>
125-
<td> <%= StringUtils.humanTimeDiff(JSONMetricUtil.getLastGcDuration(
126-
collector1.getObjectName())) %></td>
119+
<td><%= gc.getCollectionCount() %></td>
120+
<td><%= StringUtils.humanTimeDiff(gc.getCollectionTime()) %></td>
121+
<td><%= StringUtils.humanTimeDiff(JSONMetricUtil.getLastGcDuration(
122+
gc.getObjectName())) %></td>
127123
</tr>
128124
</table>
129125
</div>
130-
<div class="tab-pane" id="tab_gc2" role="tabpanel">
131-
<table class="table table-striped">
132-
<tr>
133-
<th>Collection Count</th>
134-
<th>Collection Time</th>
135-
<th>Last duration</th>
136-
</tr>
137-
<tr>
138-
<td> <%= collector2.getCollectionCount() %></td>
139-
<td> <%= StringUtils.humanTimeDiff(collector2.getCollectionTime()) %> </td>
140-
<td> <%= StringUtils.humanTimeDiff(JSONMetricUtil.getLastGcDuration(
141-
collector2.getObjectName())) %></td>
142-
</tr>
143-
</table>
144-
</div>
126+
<% idx++; } %>
145127
</div>
146128
</div>
147-
<%} else { %>
148-
<p> Can not display GC Collector stats.</p>
149-
<%} %>
150-
Total GC Collection time: <%= StringUtils.humanTimeDiff(collector1.getCollectionTime() +
151-
collector2.getCollectionTime())%>
129+
<p>Total GC Collection time: <%= StringUtils.humanTimeDiff(totalGcTime) %></p>
130+
<% } else { %>
131+
<p>Can not display GC Collector stats.</p>
132+
<% } %>
152133
</div>
153134
<% for(MemoryPoolMXBean mp:mPools) {
154135
if(mp.getName().contains("Cache")) continue;%>

hbase-server/src/main/resources/hbase-webapps/regionserver/processRS.jsp

Lines changed: 21 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,6 @@ Object pauseInfoThresholdExceeded = JSONMetricUtil.getValueFromMBean(rsMetrics,
3838
3939
// There is always two of GC collectors
4040
List<GarbageCollectorMXBean> gcBeans = JSONMetricUtil.getGcCollectorBeans();
41-
GarbageCollectorMXBean collector1 = null;
42-
GarbageCollectorMXBean collector2 = null;
43-
try {
44-
collector1 = gcBeans.get(0);
45-
collector2 = gcBeans.get(1);
46-
} catch(IndexOutOfBoundsException e) {}
4741
List<MemoryPoolMXBean> mPools = JSONMetricUtil.getMemoryPools();
4842
pageContext.setAttribute("pageTitle", "Process info for PID: " + JSONMetricUtil.getProcessPID());
4943
%>
@@ -85,10 +79,10 @@ pageContext.setAttribute("pageTitle", "Process info for PID: " + JSONMetricUtil.
8579
<table class="table table-striped" width="90%" >
8680
<tr>
8781
<th>ThreadsNew</th>
88-
<th>ThreadsRunable</th>
82+
<th>ThreadsRunnable</th>
8983
<th>ThreadsBlocked</th>
9084
<th>ThreadsWaiting</th>
91-
<th>ThreadsTimeWaiting</th>
85+
<th>ThreadsTimedWaiting</th>
9286
<th>ThreadsTerminated</th>
9387
</tr>
9488
<tr>
@@ -107,55 +101,42 @@ pageContext.setAttribute("pageTitle", "Process info for PID: " + JSONMetricUtil.
107101
<div class="page-header">
108102
<h2>GC Collectors</h2>
109103
</div>
110-
</div>
111-
<% if (gcBeans.size() == 2) { %>
104+
</div>
105+
<% if (gcBeans != null && !gcBeans.isEmpty()) { %>
112106
<div class="tabbable">
113107
<ul class="nav nav-pills" role="tablist">
108+
<% int idx = 0; for (GarbageCollectorMXBean gc : gcBeans) { %>
114109
<li class="nav-item">
115-
<a class="nav-link active" href="#tab_gc1" data-bs-toggle="tab" role="tab"><%=collector1.getName() %></a>
110+
<a class="nav-link <%= idx == 0 ? "active" : "" %>" href="#tab_gc_<%= idx %>" data-bs-toggle="tab" role="tab">
111+
<%= gc.getName() %>
112+
</a>
116113
</li>
117-
<li class="nav-item">
118-
<a class="nav-link" href="#tab_gc2" data-bs-toggle="tab" role="tab"><%=collector2.getName() %></a>
119-
</li>
114+
<% idx++; } %>
120115
</ul>
121116
<div class="tab-content">
122-
<div class="tab-pane active" id="tab_gc1" role="tabpanel">
117+
<% idx = 0; long totalGcTime = 0; for (GarbageCollectorMXBean gc : gcBeans) { totalGcTime += gc.getCollectionTime(); %>
118+
<div class="tab-pane <%= idx == 0 ? "active" : "" %>" id="tab_gc_<%= idx %>" role="tabpanel">
123119
<table class="table table-striped">
124120
<tr>
125121
<th>Collection Count</th>
126122
<th>Collection Time</th>
127123
<th>Last duration</th>
128124
</tr>
129125
<tr>
130-
<td> <%= collector1.getCollectionCount() %></td>
131-
<td> <%= StringUtils.humanTimeDiff(collector1.getCollectionTime()) %> </td>
132-
<td> <%= StringUtils.humanTimeDiff(JSONMetricUtil.getLastGcDuration(
133-
collector1.getObjectName())) %></td>
126+
<td><%= gc.getCollectionCount() %></td>
127+
<td><%= StringUtils.humanTimeDiff(gc.getCollectionTime()) %></td>
128+
<td><%= StringUtils.humanTimeDiff(JSONMetricUtil.getLastGcDuration(
129+
gc.getObjectName())) %></td>
134130
</tr>
135131
</table>
136132
</div>
137-
<div class="tab-pane" id="tab_gc2" role="tabpanel">
138-
<table class="table table-striped">
139-
<tr>
140-
<th>Collection Count</th>
141-
<th>Collection Time</th>
142-
<th>Last duration</th>
143-
</tr>
144-
<tr>
145-
<td> <%= collector2.getCollectionCount() %></td>
146-
<td> <%= StringUtils.humanTimeDiff(collector2.getCollectionTime()) %> </td>
147-
<td> <%= StringUtils.humanTimeDiff(JSONMetricUtil.getLastGcDuration(
148-
collector2.getObjectName())) %></td>
149-
</tr>
150-
</table>
133+
<% idx++; } %>
151134
</div>
152-
</div>
153-
</div>
154-
<%} else { %>
155-
<p> Can not display GC Collector stats.</p>
156-
<%} %>
157-
Total GC Collection time: <%= StringUtils.humanTimeDiff(collector1.getCollectionTime() +
158-
collector2.getCollectionTime())%>
135+
</div>
136+
<p>Total GC Collection time: <%= StringUtils.humanTimeDiff(totalGcTime) %></p>
137+
<% } else { %>
138+
<p>Can not display GC Collector stats.</p>
139+
<% } %>
159140
</div>
160141
<% for(MemoryPoolMXBean mp:mPools) {
161142
if(mp.getName().contains("Cache")) continue;%>

0 commit comments

Comments
 (0)