Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-dev] Making ProxyServlet more extensible

Hi,

While svnsearch.org has been running on Jetty for quite a while now,
the dirty little secret is that I've actually been running Apache with
mod_proxy in front of it :-)

(I like the convenience of centralized logging, gzipping,
authentication etc that I get with Apache, but mod_proxy just doesn't
scale or work reliably with a an app using Comet like SVNSearch.)

So as a compromise I've made a little proxy server using Jetty 7's
ProxyServlet. Traffic to SVNSearch.org is sent directly to SVNSearch's
SelectChannelConnector, while other requests are handed off to Apache
as before.

Creating this proxy server, I've found the Jetty's ProxyServlet a bit
hard to extend. What I specifically need is this:

a) A way to customize the HttpClient such that I can set the connectionTimeout.

b) A way to set the Continuation's timeout so that it will not time
out before the HttpExchange does (default timeout seems to be 30s
which is way to little for long polling)

c) A way to hook into the HttpExchange's onConnectionFailed and
onExpire methods so that I can give more specific error messages than
just a 503. (I'd like to write something more user frieldly like
"SVNSearch is down for maintenance, we'll be back soon..")

I've patched ProxyServlet to handle these needs in the following way:

a) Solved by adding an empty protected void customizeClient(HttpClient
client) method to be extended by subclasses for HttpClient
customizations such as setting timeouts

b) Solved by adding an empty protected void
customizeContinuation(Continuation cont) method to be extended by
subclasses for Continuation customizations such as setting timeouts

c) Solved by adding methods
handle[OnConnectionFailed|OnExpire|OnException]() methods to be
extended by subclasses that need custom error / timeout handling.
These are called by the HttpExchange methods before calling
continuation.complete().

While the patch scratches my itch nicely I'm not so sure it's designed
for general purpose extensibility.

So I'll be happy to see a review of the patch and some discussion or
tips on improving it.

If the patch is welcome and the overall design is ok, I'll go ahead
and add an issue to Bugzilla

Thanks,
Eirik.

Attachment: Make_ProxyServlet_more_easily_extensible.patch
Description: Binary data


Back to the top