Hi Dan,
I opened a JIRA related to this: (MUSE-237) Cannot set subscription
termination time if Subscribe was first called with null time
 
We have a query implementation that creates one resource instance per
query to maintain the state of the query.  When the resource instance is
created, we set a default lifetime (i.e. 2 hours).  But users can extend
the resource lifetime if they want the query process to stay alive
longer, so we need to support the ScheduledTermination operation.
 
In the SimpleScheduledTermination class, a new Timer is created for each
instances of this class.  This means that if we generate 1000 query
resource instances, there will be 1000 Timer/threads.  But, the
execution logic for the Timer tasks are simple (i.e. call
resource.shutdown()), so we don't really need one thread per task.
 
As a workaround, I extended SimpleScheduledTermination and created a new
TimerTask, instead of a new Timer.  Then I schedule the TimerTask on a
small number of Timers which are managed outside of
SimpleScheduledTermination, which helps limit the number of threads
generated in the system.
 
There's another problem/bug, too.  In SimpleScheduledTermination, the
Timer object is initialized outside of the constructor, so I am unable
to override any logic to prevent the Timer from initializing.  If it was
initialized in the constuctor, then at least I could override it there.
So my workaround for this was to override initialize() and immediately
call setTerminationTime(null) to stop the Timer/thread in the parent
class.  Then I can use my own Timer/TimerTask to manage the threads that
stay alive.

________________________________

From: Daniel Jemiolo [mailto:[EMAIL PROTECTED] 
Sent: Monday, June 18, 2007 10:05 AM
To: [email protected]
Subject: Re: Timer Thread per Resource - Can it be Optimized



This should only happen if you add WSRL ScheduledTermination (not
ImmediateTermination) to your resources. In this case, we have one timer
for each resource, since each may have a separate termination time. I'm
open to optimizing the implementation, but don't have any ideas for how
to do this and still get the correct termination behavior. Perhaps the
first question you should ask is: is it necessary to have *scheduled*
termination on this particular resource type?

Dan



"Srinivasan Packirisamy \(spackiri\)" <[EMAIL PROTECTED]> wrote on
05/30/2007 07:59:11 PM:

> Hi,
>    When a resource is created with WS-RL capabilities, a timer 
> thread created for each resource. So, if we create 1000s resources 
> with WS-RL capabilities, the TimerThread count just keeps increasing
> and eventually causes issues in the WebServer. Can this be optimized?
>  
> ~Srini
>  

Reply via email to