users@grizzly.java.net

Re: Http WebServer question

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

Salut,

Jeanfrancois Arcand wrote:
> 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

Fixed. That will be part of our next release (1.9.0) and available right
now using the SNAPSHOT/uploaded build from here:

http://download.java.net/maven/2/com/sun/grizzly/

Make sure you read the API documentation. In short, if you manipulate
the SocketChannel, you must make sure you either let Grizzly handle the
http headers, or handle it by yourself.

https://grizzly.dev.java.net/nonav/apidocs/com/sun/grizzly/tcp/Response.html

(uploading the new html now so refresh in a couple of min)

Let me know how it goes.

A+

-- Jeanfrancois


>
> 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
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>