Graceful and Forced Shutdown Feature

sohguanh sohguanh at yahoo.com.sg
Thu Sep 24 21:43:00 EDT 2009


I understand Netty is an NIO framework but it would be nice to enhance it
with pre-built classes for doing server graceful and forced shutdown.

Graceful shutdown
I discover the tutorial and common technique is run a forever loop,
Thread.sleep(x) then check some condition to indicate a shutdown is to be
executed. This technique means some latency as the main thread will only
wake up after x seconds to check.

In JDK 1.5 I uses java.util.concurrent.CountDownLatch and the main thread
execute await() method. This will block until the CountDownLatch count
reached zero. Then in the server handler thread once the shutdown command is
received, it will execute countDown() to decrement the count. This approach
greatly improve the latency the main thread receive shutdown command. Seems
await() method will wake up and not wait x seconds using the Thread.sleep(x)
technique.

I hope Netty new release provide some shutdown classes using various
techniques for graceful shutdown.

Forced shutdown
How do Netty server detect JVM dies so it can terminate gracefully? I
discover java.lang.Runtime.addShutdownHook method and also the
com.sun.misc.Signals but seem not working for me in a predictable manner.

I hope Netty new release provide some shutdown classes using various
techniques for forced shutdown.

-- 
View this message in context: http://n2.nabble.com/Graceful-and-Forced-Shutdown-Feature-tp3709901p3709901.html
Sent from the Netty User Group mailing list archive at Nabble.com.


More information about the netty-users mailing list