Re: Seda Shutdown

Quartz <[email protected]> Wed, 19 Nov 2003 12:16:02 -0800 (PST)
Newsgroups gmane.comp.java.seda.user
Message-ID <[email protected]>
As I remember, shutdown does a really crappy threadgroup.stop, or thread.stop.
Which of course are unacceptable.

Ready to refactor the source? If you can go over ALL (and I mean ALL) blocking queue methods, and
add InterruptedException on all SinkIF/SourceIF blocking methods signature, and find everywhere
these method are called, and also expect  the handleEvent to throw a new
"InterruptedEventhandlerEception", and ensure that ALL handlers implementation can handle an
interrupt(), and close the sink and process it before removing the stage... then only you may
envision destroying a stage safely.

That is what I called a gracefull shutdown months ago in a RFE.

Note: even if the shutdown can call interrupt(), most of the asocket subsystem is absolutely not
ready to handle that. There are very specific state machines in there, and when interruption
occurs between states, the handler may not process and release its resource correctly. So, it is
highly probable that you will need to POST shutdown events to these asocket/afile stages and
expect a confirmation when they are completed before assuming the shutdown has succeeded.

-----
As for general purpose...
I suggest you rewrite the sandstorm manager part about instanciating the Thread manager type,
and make it classname based, then read it from the config, Class.forName/newInstance thing...

Then, write your own thread manager and I mean it, TPSTM sucks big time above 10 stage, because it
makes too many threads, and if you reduce the pool max size, then you reduce the trottling
granularity (too coarse when your only choices are 1, 2 or 3 threads...)

Writing a ThreadManager is not so hard. Just have to implement register/deregister.
Then write a scheduler based on the queue sizes (or other custom stage need metrics indicator).
Then, each performer thread just dequeue and call handle event. The fun/tricky part is this
scheduling logic and the shutdown.

I suggest you start with a Priority controller (fixed number of threads, 1 thread per stage) as an
exercice. It works great. (just remember to leave out thread prio 10 for the controller only,
available prio should remain in [1-9] interval).

I may be able to give my ThreadPriorityTM source if not under our company intellectual property. I
will check.

If you want a better approach, write a single thread pool, with lets say 50 threads, and make sure
that when you reach the max (ex: 50), when you add a thread to a stage, you must remove one from
another stage.

Have fun.


--- "Vohra, Bhupesh (Bhupesh)" <[email protected]> wrote:
> Hi,
> 
> Is Seda Shutdown supported currently?
> In lot of files, shutdown function like Stop()/Destroy() just throw 
> java.lang.IllegalArgumentException
> 
> To test shutdown, I added following code in 
> seda.sandStorm.main.Main.java
> 
>  Sandstorm ss = new Sandstorm();
> >>>>
>       sandStormMgr mgr = (sandStormMgr)ss.getManager(); //get Manager
>       mgr.stop(); //Stop sandstorm.
> >>>>
> 
> I am getting exception:
> 
> Sandstorm.main(): Got exception: java.lang.IllegalArgumentException: aSocketThreadManager:
> deregisterAll not supported
>  java.lang.IllegalArgumentException: aSocketThreadManager: deregisterAll not supported 	at
> seda.sandStorm.lib.aSocket.aSocketThreadManager.deregisterAll(aSocketThreadManager.java:76) 	at
> seda.sandStorm.internal.sandStormMgr.stop(sandStormMgr.java:125) 	at
> seda.sandStorm.main.Main.main(Main.java:99) 
> 
> Also is there any way to destroy one stage only?
> seda.sandStorm.internal.Stage.java throws exception
>   /**
>    * Destroy this stage.
>    */
>   public void destroy() {
>     throw new IllegalArgumentException("XXX Not yet implemented!");
>   }
> 
> 
> Thanx,
> Bhupesh
> 
> 
> -------------------------------------------------------
> This SF.net email is sponsored by: SF.net Giveback Program.
> Does SourceForge.net help you be more productive?  Does it
> help you create better code?  SHARE THE LOVE, and help us help
> YOU!  Click Here: http://sourceforge.net/donate/
> _______________________________________________
> SEDA-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/seda-users


__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree


-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/