users@glassfish.java.net

Re: WorkManager queue size

From: FredrikJ <fredrik_at_robotsociety.com>
Date: Thu, 23 Apr 2009 07:29:54 -0700 (PDT)

Update -

It seems like the CommonWorkManager is created once per request and is not
designed to be used as a shared resource (thread unsafe?). The statistical
methods are tied to the CWM instance only and no the underlying thread pool.

This means that when you call getWaitQueueength() for instance, you only get
the count of task you have assigned to this specific instance of CWM. Why I
would be interested in this instead of the shared queue size is beyond me...
but anyway, that seems to be the case.

So, since I can't use the work manager to inspect the work queue I made a
hack to get and check the queue directly, it looks a bit like this (without
failure handling etc):

       public int getQueueSize(String threadpool) {
            ThreadPoolManager threadpoolManager =
S1ASThreadPoolManager.getThreadPoolManager();
            ThreadPool tp = threadpoolManager.getThreadPool(threadpool);
            WorkQueue queue = tp.getAnyWorkQueue();
            return queue.workItemsInQueue();
        }

So we do have a working queue size lookup now, but it feels like a major
hack. I would argue that the returned CommonWorkManager should be able to
return proper data for the shared thread pool(s) and not the instance local
data.


-- 
View this message in context: http://www.nabble.com/WorkManager-queue-size-tp23158627p23197363.html
Sent from the java.net - glassfish users mailing list archive at Nabble.com.