Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] Embedded Jetty 7 : shutdown gracefully + loadbalance

Hi everyone,

I wrote a simple BPEL engine exposing its services through an embedded jetty
server (jetty-7.0.2.v20100331).
The engine is installed in a "cluster" behind an Apache 2 mod_proxy which
balances the requests between to 2 engines.
The engines statistics shows us that we have timings per request from 1 sec
to 6 hours of processing time (batch).

I try to implement a "prepare for shutdown" feature to help us to shutdown
gracefully an engine for maintenance: 
- the new requests must be refused and balanced on the mirror engine (by
mod_proxy)
- the current requests must continue to their end (and these threads must be
able to answer to their clients of course). 
- then, when we don't have anymore request, the engine stops the jetty and
the JVM stops too after some cleaning.

Programmatically, I have a Thread running a Server with a
SelectChannelConnector and a custom AbstractHandler.

I flag the server via a JMX call to prepare its shutdown with
setGracefulShutdown(1000); and setStopAtShutdown(true);
But it handles all the new incoming requests until a call to
connector.close();

My problem is that when I use connector.close(); the current threads are
able to finish their jobs but all the connections to the clients are dropped
(of course) and these threads must inform their clients the final job
status.

I tried to don't close the connector but rejecting the new request (with a
simple retrun in the custom handler) but it replies 404 to the client
without redirecting the request to the mirror engine
I tried few different HTTP errors more server-like than 404 but I missed the
good one apparently.

So, any tip to:
- shutdown gracefully
- letting the current thread finish and replying to the caller
- inform the loadbalancer that this jetty is not more available ?

Thanks for your time,

Christophe.

--
View this message in context: http://jetty.4.n6.nabble.com/Embedded-Jetty-7-shutdown-gracefully-loadbalance-tp4664115p4664115.html
Sent from the Jetty User mailing list archive at Nabble.com.


Back to the top