Hi Trustin,

Thanks for your suggestions.  Coincidentally, we have implemented (1),
(2), and (3), along with other stuff, very similar to what you
suggested !  (Actually I may as well change them to behave exactly as
you suggested ...)

As to (4), we are using the Java 5 ScheduledExecutorService framework
to allow those active connections to continue for about 10 seconds
before forcefully shutting them down.  Hopefully the administrators
won't be too unhappy about this :)

As to the use of Mina 0.9.4+ vs 0.8.2, the only concern, however
pathetic, is that 0.8.2 is under the "stable" directory, whereas 0.9.4
is under "unstable".  Since we are deploying the app to some dead
serious production environment....Any chance the 0.9.4 can be moved
under "stable", so we can move on to it without causing unnecessary
concerns to the admin/management group ?

H


On 8/10/06, Trustin Lee <[EMAIL PROTECTED]> wrote:
Here's my suggestion on graceful shutdown.

1) Modify your I/O Handler (or ProtocolHandler) to maintain the list of
connected sessions.  sessionOpened() and sessionClosed() would be the best
place to do this.
2) Unbind the service so there cannot be more new sessions.  The existing
sessions will not be disconnected at this moment.
3) Close all sessions in the list you've been maintaining at step (1).

Regarding the timeout stuff, it depends on the contract between clients and
a server, so the implementation can change depending on it.  My suggestion
is just to close the sessions immediately because a server that takes
minutes to shut itself down makes administrators unhappy.

HTH,
Trustin

On 8/6/06, Hanson Char <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I am interested in your thoughts and suggestions in implementing a
> graceful shutdown of a Mina server.  Please read below for details.
>
> Hanson Char
>
> Implementing Graceful Shutdown
> ========================
> We have a server implemented in Mina 0.8.2, and are thinking of
> implementing a graceful shutdown of the server upon certain event
> (such as trapping a SIGINT or SIGTERM).
>
> The shutdown basically needs to:
> 1) stop any new connection from being made, and
> 2) closes all existing open sessions;
>
> For (2), however, I am thinking instead of closing the outstanding
> open sessions immediately, maybe a better approach would be to wait
> for the existing write's to finish prior to closing the sessions ?
>
> Specifically, for each existing open session,
> 1) check if it is idle and if so close the session immediately;
> 2) if not, wait for up to 10 seconds (or whatever timeout parameter),
> or until it's idle, then close the session;
>
> Thoughts ?  Suggestions ?
>
> Thanks in advance.
>



--
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP key fingerprints:
* E167 E6AF E73A CBCE EE41  4A29 544D DE48 FE95 4E7E
* B693 628E 6047 4F8F CFA4  455E 1C62 A7DC 0255 ECA6


Reply via email to