Skip to content

Commit a8440a2

Browse files
committed
Thread pool monitoring - set number of threads directly from pool info
1 parent f89b561 commit a8440a2

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/services/impl/monitor/ThreadPoolMonitor.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,19 @@ public void onThreadAllocateEvent(AbstractThreadPool threadPool, Thread thread)
6666
grizzlyMonitoring.getThreadPoolProbeProvider().threadAllocatedEvent(
6767
monitoringId, threadPool.getConfig().getPoolName(),
6868
thread.getId());
69+
grizzlyMonitoring.getThreadPoolProbeProvider().setCurrentThreadCountEvent(
70+
monitoringId, threadPool.getConfig().getPoolName(),
71+
threadPool.getSize());
6972
}
7073

7174
@Override
7275
public void onThreadReleaseEvent(AbstractThreadPool threadPool, Thread thread) {
7376
grizzlyMonitoring.getThreadPoolProbeProvider().threadReleasedEvent(
7477
monitoringId, threadPool.getConfig().getPoolName(),
7578
thread.getId());
79+
grizzlyMonitoring.getThreadPoolProbeProvider().setCurrentThreadCountEvent(
80+
monitoringId, threadPool.getConfig().getPoolName(),
81+
threadPool.getSize());
7682
}
7783

7884
@Override

nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/services/impl/monitor/probes/ThreadPoolProbeProvider.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,10 @@ public void threadReturnedToPoolEvent(
7676
@ProbeParam("monitoringId") String monitoringId,
7777
@ProbeParam("threadPoolName") String threadPoolName,
7878
@ProbeParam("threadId") long threadId) {}
79+
80+
@Probe(name="setCurrentThreadCountEvent")
81+
public void setCurrentThreadCountEvent(
82+
@ProbeParam("monitoringId") String monitoringId,
83+
@ProbeParam("threadPoolName") String threadPoolName,
84+
@ProbeParam("currentThreadCount") int currentThreadCount) {}
7985
}

nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/services/impl/monitor/stats/ThreadPoolStatsProvider.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,17 @@ public void threadReturnedToPoolEvent(
162162
}
163163
}
164164

165+
@ProbeListener("glassfish:kernel:thread-pool:setCurrentThreadCountEvent")
166+
public void setCurrentThreadCountEvent(
167+
@ProbeParam("monitoringId") String monitoringId,
168+
@ProbeParam("threadPoolName") String threadPoolName,
169+
@ProbeParam("currentThreadCount") int currentThreadCount) {
170+
171+
if (name.equals(monitoringId)) {
172+
this.currentThreadCount.setCount(currentThreadCount);
173+
}
174+
}
175+
165176
@Reset
166177
public void reset() {
167178
if (threadPoolConfig != null) {

0 commit comments

Comments
 (0)