users@glassfish.java.net

Re: WorkManager queue size

From: Jagadish Prasath Ramu <Jagadish.Ramu_at_Sun.COM>
Date: Fri, 24 Apr 2009 13:34:00 +0530

On Fri, 2009-04-24 at 00:34 -0700, FredrikJ wrote:
>
> Jagadish Prasath Ramu wrote:
> >
> > Yes, it represents the work-manager's usage of threads.
> > You can dedicate the thread-pool (asadmin create-thread-pool) only for a
> > particular task and hence the statistics will be the real representation
> > of the task that you are trying to monitor.
> >
>
> Let me try to explain what I mean a bit better;
>
> One thread pool will have many short-lived CommonWorkManagers associated
> with it.
CommonWorkManager is used *only* by connector container and the expected
usage is, one work-manager per resource-adapter (throughout its
life-cycle). I guess, you are using the CommonWorkManager outside of
this scope.
> The reason for this is that a new CommonWorkManager is created
> every time I ask the WorkManagerFactory for a work manager.
Yes, every time you ask the Factory, it will provide new work-manager
(in-line with the above design of connector container)
>
> When I ask the CommonWorkManager for the queue size, I would expect to get
> the queue size of the thread pool, which is what I think you mean in your
> reply as well.
No. It is the usage of the threads by a particular instance of the
WorkManager.
The monitoring stats are specific to the work manager and not for the
pool.
Hence, if you have dedicated the thread pool for only one work manager,
then it will help to achieve your requirement of work-manager statistics
reflecting the thread-pool usage also.
>
> But I don't. I basically get the number of task that I have added to this
> particular CommonWorkManager (on the current thread, in the current
> invocation scope). This count is completely unrelated to the thread pool's
> queue size or thread usage.
Please refer the above response.
Probably you may want to cache the work-manager across the requests to
achieve your requirement.

>
> So when you say 'it represents the work-manager's usage of threads', I think
> that is not currently the case at all. The CWM will only live between my
> call to the factory and to I have added my task local to my current thread
> and method invocation.