dev@grizzly.java.net

Re: Orderly Shutdown of Server in ProtocalParser code

From: Parker Lord <plord_at_seecontrol.com>
Date: Wed, 17 Jun 2009 19:28:23 -0700 (PDT)

Basically, the bigger issue is how to code the part that will cause the
process to exit.

Looks like yours is a restart, so to stop I would just do:

new Thread(){

   public void run(){
      ctx.getController().stop();
}.start();

That will cause the entire process and all threads to exit?



Jeanfrancois Arcand-2 wrote:
>
> Salut,
>
> Parker Lord wrote:
>> I have a server using the ProtocolParser to parse out message and then
>> pass
>> them into my message filter.
>>
>> How do I perform an orderly shutdown of the server when I receive a
>> shutdown
>> command from a client.
>>
>> I want to send a simple 'stop' string to the server, have it then
>> initiate
>> the shutdown of the server.
>>
>> Ideally would also like to be able to restart it.
>
> OK let me try to see if I understand properly. Mainly, you want to be
> able to support two protocol
>
> (first)
>
> client ---> protocol_a ---> server
>
> (second)
>
> client ---> protocol_b ---> server
>
> where protocol_b is the 'stop' string. Security wise, I would not mix
> the handling of protocol_a and protocol_b, but instead create 2
> SelectorHandler, one for protocol_a, one for protocol_b. For the
> SelectorHandler listening for protocol_b, I strongly recommend you bind
> the Selectorhandler (the address) to 127.0.0.1 as if you open it to all
> port, some malicious use can re-start your server.
>
> For protocol_b, just write a simple ProtocolFilter that take read the
> String from the byteBuffer, and if the byteBuffer contains the expected
> String ('stop'), the do something like:
>
>
> public boolean execute(Context ctx){
>
> // Read from the ByteBuffer
> // If stop, then
>
> new Thread(){
>
> public void run(){
> ctx.getController().stop();
> ctx.getController.start();
> }.start();
>
> }
>
> That should work. Did I understood your question correctly?
>
> Thanks!
>
> -- Jeanfrancois
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: dev-help_at_grizzly.dev.java.net
>
>
>

-- 
View this message in context: http://www.nabble.com/Orderly-Shutdown-of-Server-in-ProtocalParser-code-tp24081691p24085419.html
Sent from the Grizzly - Development mailing list archive at Nabble.com.