dev@grizzly.java.net

Re: About graceful shutdown

From: Oleksiy Stashok <oleksiy.stashok_at_oracle.com>
Date: Mon, 10 Mar 2014 00:41:02 -0700

Hi Bongjae,

unbindAll just closes ServerSocketChannels, so new connections won't be
accepted, but at the same time existing connections will be still active.

Hope that will help.

WBR,
Alexey.

On 09.03.14 20:04, Bongjae Chang wrote:
> Hi,
> Grizzly provides GracefulShutdownListener interface so custom server
> can implement graceful shutdown logic.
>
> When I reviewed NIOTransport#shutdown, there are 3 steps.
> 1) state set to be STOPPING.
> 2) unbindAll
> 3) shutdown listener will be called and checked within period in
> background thread and return a future.
>
> At this logic, I have a question above 2) and 3).
> I think that all connections will be closed after 2) then server can't
> send responses corresponding to requests which were received before
> the shutdown operation.
>
> The following is an example.
> ---
> request 1: received
> request 2: received
> (start to shut down)
> request 3: rejected with STOPPING state
> request 4: rejected with STOPPING state
> ..
> processing request 1, 2: graceful
> ..
> unbindAll
> sending response 1, 2: maybe server can’t send responses because there
> are no connections.
> ---
>
> I think that request 1 and request 2’s responses should be sent to
> clients but can’t because connections are already closed.
>
> I don’t know whether I have a right understanding. Please correct me
> if I am missing some points.
>
> Thanks!
>
> Regards,
> Bongjae Chang
>