users@grizzly.java.net

Re: From Grizzly 1.9.x to 2.x

From: Oleksiy Stashok <oleksiy.stashok_at_oracle.com>
Date: Thu, 04 Aug 2011 10:44:04 +0200

Hi David,

checked the sample you sent one more time.
First of all it doesn't work, cause you try to use non-blocking
InputStream as it was blocking, so when you change code like this
(change false -> true):

     public boolean upload() {
         boolean finish;
         int read;

         finish = false;
         try {
             read = req.getInputStream(*true*).read(buffer);


it starts to work.

But as I understand in your sample you're actually trying to simulate
non-blocking upload, and IMO it would make sense to use non-blocking
InputStream. Please check this sample [1] and documentation [2], it may
help you to understand non-blocking InputStream better.

Thanks.

WBR,
Alexey.


[1]
http://java.net/projects/grizzly/sources/git/content/samples/http-server-samples/src/main/java/org/glassfish/grizzly/samples/httpserver/nonblockinghandler/UploadHttpHandlerSample.java
[2] http://grizzly.java.net/nonav/docs/docbkx2.0/html/hsf-nio-streams.html



On 08/03/2011 04:33 PM, Gay David (Annecy) wrote:
>
> Hi all,
>
> I'm trying to experiment Grizzly 2 by porting my current application
> from 1.9.x to 2.x.
>
> Basically I'm assuming that the default Grizzly behavior is the same
> to do long request :
>
> * Suspend the response
>
> * Give the processing of the request/response to my own thread pool
>
> * Once finish, resume it
>
> Am I wrong ?
>
> So my first step is to convert all my code that use Gz 1.9 API to Gz
> 2.0 API (package change, etc.) and check how it works (and also check
> if it's fix some problems I have under heavy load).
>
> The second step would be later to use new functionality of Gz 2.0
>
> So I've done the first step, but I'm block on some units test that
> simulate some heavy upload/download. (unit tests that went ok with Gz
> 1.9.x)
>
> I've made a simple test case to illustrate my problem. This test
> simulate uploads, but I still have to same problem with download.
>
> I've add it in attachement, it's a simple Maven project.
>
> At the end of the (long) test, I've many exception like :
>
> java.lang.IllegalStateException: Internal
> org.glassfish.grizzly.http.server.Response has not been set
>
> at
> org.glassfish.grizzly.http.server.Response.checkResponse(Response.java:1607)
>
> at
> org.glassfish.grizzly.http.server.Response.setStatus(Response.java:1255)
>
> at
> org.glassfish.grizzly.http.server.HttpHandlerChain.service(HttpHandlerChain.java:202)
>
> at
> org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:162)
>
> at
> org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:160)
>
> at
> org.glassfish.grizzly.filterchain.ExecutorResolver$3.execute(ExecutorResolver.java:95)
>
> at
> org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:444)
>
> at
> org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:364)
>
> at
> org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:290)
>
> at
> org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:133)
>
> at
> org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:76)
>
> at
> org.glassfish.grizzly.filterchain.FilterChainContext$1.run(FilterChainContext.java:198)
>
> at
> org.glassfish.grizzly.filterchain.FilterChainContext.resume(FilterChainContext.java:222)
>
> at org.glassfish.grizzly.http.server.Response.cancel(Response.java:1599)
>
> at
> org.glassfish.grizzly.http.server.Response$SuspendedContextImpl.onClosed(Response.java:1717)
>
> at
> org.glassfish.grizzly.nio.NIOConnection.notifyCloseListeners(NIOConnection.java:612)
>
> at
> org.glassfish.grizzly.nio.NIOConnection.close(NIOConnection.java:358)
>
> at
> org.glassfish.grizzly.nio.NIOConnection.close(NIOConnection.java:349)
>
> at
> org.glassfish.grizzly.nio.SelectorRunner.shutdownSelector(SelectorRunner.java:210)
>
> at
> org.glassfish.grizzly.nio.SelectorRunner.run(SelectorRunner.java:286)
>
> at
> org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:508)
>
> at
> org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:488)
>
> at java.lang.Thread.run(Thread.java:662)
>
> Could someone helps me to check if I do something wrong, or if it's a
> Gz 2.x problem.
>
> BTW : I'm using Grizzly 2.1.1
>
> Thanks and regards
>
> David
>