hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sam Berlin (JIRA)" <j...@apache.org>
Subject [jira] Updated: (HTTPCORE-148) Create AsyncNHttpServiceHandler & AsyncNHttpClientHandler
Date Sat, 16 Feb 2008 15:47:08 GMT

     [ https://issues.apache.org/jira/browse/HTTPCORE-148?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Sam Berlin updated HTTPCORE-148:
--------------------------------

    Attachment: changes.txt

Attached is a final revision of the async service side.  There's a slew of tests in the TestAsyncNHttpHandlers
test, which is an integration test for everything involved in AsyncNHttpServiceHandler.  As
the client side is fleshed out, the client side of that test should convert from the buffering
handler to the async handler.  All tests pass, and it's pretty slick IMHO.

The general theme of AsyncNHttpServiceHandler is that it provides the best of both worlds
of the buffering & throttling variants.  Like the buffering mode, everything is done in
a single thread.  Better than the throttling mode, absolutely nothing is buffered in memory.
 To support migration from old code, there's a few delegate classes that act like the buffering
& throttling variants.  If the service handler detects an outgoing entity doesn't implement
ProducingNHttpEntity, it will wrap it within a NBlockingProducingNHttpEntity.  That entity
will buffer the output entirely in memory.  On the incoming side, in order to support migrating
existing HttpRequestHandlers, there's a NBlockingHttpRequestHandler that the HttpRequestHandler
can be wrapped in.  If the service detects the current handler is wrapped, it uses the special
BlockingHandler interface to handle the request, which lets the external HttpRequestHandler
use getContent() and all sorts of blocking methods, also allowing feedback in the form of
exceptions to be processed correctly.

The end result is that the only real change external code has to make in order to incorporate
AsyncNHttpServiceHandler is to register existing HttpRequestHandlers by wrapping them within
an NBlockingHttpRequestHandler (and still, only if it expected entities and read them with
getContent).  To make best use of the service handler, though, it's advised to read incoming
entities as if they were ConsumingNHttpEntities, and provide outgoing entities that implement
ProducingNHttpEntity.  There's an AsyncNHttpFileServer example that shows how easy it is to
write up a single-threaded file server.

Thanks!

> Create AsyncNHttpServiceHandler & AsyncNHttpClientHandler
> ---------------------------------------------------------
>
>                 Key: HTTPCORE-148
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-148
>             Project: HttpComponents Core
>          Issue Type: New Feature
>          Components: HttpCore NIO
>    Affects Versions: 4.0-beta2
>            Reporter: Sam Berlin
>         Attachments: changes.txt
>
>
> Attached is a patch (minus tests right now) for AsyncNHttpServiceHandler.  It actually
works (as tested by running & hitting it with IE.)  :)
> To test, run the example 'AsyncNHttpFileServer' in the examples directory.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Mime
View raw message