users@grizzly.java.net

Re: Http WebServer question

From: Jeanfrancois Arcand <Jeanfrancois.Arcand_at_Sun.COM>
Date: Thu, 13 Nov 2008 17:14:34 -0500

Salut,

Richard Jackson wrote:
> I'm just starting to look at grizzly and trying to decide if I want to
> use it verses something else. So I've been looking at the api's and
> javadocs and samples. One thing I don't see covered is how you are
> actually serving static content. From browsing the javadoc it seems
> you are using the traditional approach (read the file in then write it
> out to the channel) as well as possibly caching the file data.

Right. First request is serviced by reading the file, then the file is
mapped using native memory and the reference cached. Next all requests
got serviced from the cache. The class to look at are:

StaticResourceAdapter

> https://grizzly.dev.java.net/nonav/xref/com/sun/grizzly/tcp/StaticResourcesAdapter.html

FileCache

> https://grizzly.dev.java.net/nonav/xref/com/sun/grizzly/http/FileCache.html


Why not
> let the OS do that for you? Take a look at this article
> http://www.ibm.com/developerworks/linux/library/j-zerocopy/index.html

That's look promising.


>
> I'm not sure if the approach described works on all platforms but the
> question I have is can I get at the channel and do it myself when
> using a GrizzlyWebServer?

Yes you can probably do that by doing (this is ugly)

((SocketChannelOutputBuffer)response.getOutputBuffer()).getChannel();

https://grizzly.dev.java.net/nonav/xref/com/sun/grizzly/tcp/Response.html#178
https://grizzly.dev.java.net/nonav/xref/com/sun/grizzly/http/SocketChannelOutputBuffer.html#123

I've filled:

https://grizzly.dev.java.net/issues/show_bug.cgi?id=319

And will add a new API on the Request/Response object called getChannel
so you can take advantages of it. I should have it later this week or
Monday for sure.

Thanks

-- Jeanfrancois



>
> Thanks
> Richard
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>