# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: /Users/oleksiys/Projects/Glassfish/v3/core/kernel/src/main/java/com/sun/enterprise/v3/services/impl/monitor # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. Index: MonitorableThreadPool.java --- MonitorableThreadPool.java Base (BASE) +++ MonitorableThreadPool.java Locally Modified (Based On LOCAL) @@ -84,6 +84,13 @@ super.afterExecute(r, t); } + @Override + protected void onWorkerExit(BasicWorker worker) { + monitoring.getThreadPoolProbeProvider().threadReleasedEvent( + threadPoolMonitoringName, Thread.currentThread().getName()); + super.onWorkerExit(worker); + } + public class ProbeWorkerThreadFactory implements ThreadFactory { @Override @@ -92,8 +99,8 @@ MonitorableThreadPool.this, r, name + "-(" + workerThreadCounter.getAndIncrement() + ")", initialByteBufferSize, monitoring); - monitoring.getThreadPoolProbeProvider().newThreadsAllocatedEvent( - threadPoolMonitoringName, 1, true); + monitoring.getThreadPoolProbeProvider().threadAllocatedEvent( + threadPoolMonitoringName, thread.getName()); return thread; } } Index: probes/ThreadPoolProbeProvider.java --- probes/ThreadPoolProbeProvider.java Base (BASE) +++ probes/ThreadPoolProbeProvider.java Locally Modified (Based On LOCAL) @@ -50,12 +50,15 @@ * Emits notification that new thread was created and added to the * thread pool. */ - @Probe(name="newThreadsAllocatedEvent") - public void newThreadsAllocatedEvent( + @Probe(name="threadAllocatedEvent") + public void threadAllocatedEvent( @ProbeParam("threadPoolName") String threadPoolName, - @ProbeParam("increment") int increment, - @ProbeParam("startThread") boolean startThread) {} + @ProbeParam("threadId") String threadId) {} + @Probe(name="threadReleasedEvent") + public void threadReleasedEvent( + @ProbeParam("threadPoolName") String threadPoolName, + @ProbeParam("threadId") String threadId) {} @Probe(name="maxNumberOfThreadsReachedEvent") public void maxNumberOfThreadsReachedEvent( Index: stats/ThreadPoolStatsProvider.java --- stats/ThreadPoolStatsProvider.java Base (BASE) +++ stats/ThreadPoolStatsProvider.java Locally Modified (Based On LOCAL) @@ -82,17 +82,26 @@ return numberOfActiveThreads; } - @ProbeListener("glassfish:kernel:thread-pool:newThreadsAllocatedEvent") - public void newThreadsAllocatedEvent( + @ProbeListener("glassfish:kernel:thread-pool:threadAllocatedEvent") + public void threadAllocatedEvent( @ProbeParam("threadPoolName") String threadPoolName, - @ProbeParam("increment") int increment, - @ProbeParam("startThread") boolean startThread) { + @ProbeParam("threadId") String threadId) { if (name.equals(threadPoolName)) { currentThreadPoolSize.increment(); } } + @ProbeListener("glassfish:kernel:thread-pool:threadReleasedEvent") + public void threadReleasedEvent( + @ProbeParam("threadPoolName") String threadPoolName, + @ProbeParam("threadId") String threadId) { + + if (name.equals(threadPoolName)) { + currentThreadPoolSize.decrement(); + } + } + @ProbeListener("glassfish:kernel:thread-pool:threadDispatchedFromPoolEvent") public void threadDispatchedFromPoolEvent( @ProbeParam("threadPoolName") String threadPoolName,