Bryan Duxbury wrote:
I've been experiencing some problems in implementing a graceful shutdown in a server app I'm writing. The app keeps some HDFS files open at all times and needs to close them before completely shutting down. However, what keeps happening is that I get some "Filesystem closed" message.

I've tracked this down to the fact that Filesystem registers its own shutdown hook handler for the purpose of closing all filesystems. Apparently, this shutdown hook gets run prior to (or concurrently with) my server shutdown hook, and as a result, when I try to close my files I can't.

I've looked around, and I can't seem to find a Java Runtime method for controlling the order of shutdown hooks, and I don't think HDFS gives me any way to suppress this shutdown hook behavior. Does it make sense for this to be configurable? I'd be fine with the responsibility of having to close all the filesystems myself as long as I got control.


+1 for shutdown hook control;

You don't get much control in shutdown hook control, but you can abuse sun.misc.SignalHandler to play tricks there; you get told off by the compiler, but provided people dont run the JVM with the -Xrs option, you can catch every signal but -9 and deal with it sooner rather than later

Reply via email to