Hi,
On Fri, May 22, 2009 at 2:04 PM, Jeanfrancois Arcand
<Jeanfrancois.Arcand_at_sun.com> wrote:
> Salut,
>
> César Fernando Henriques wrote:
>>
>> Thanks you Jean, will be good if you have a little of free time to
>> check my code but don't worry, I'm not hurry
>
> (saw your post on Netty ;-))
Yeah, I have been pretty nice with Grizzly in the post ;-), I'm trying
both, will make a decision in the comming days.. Grizzly looks pretty
good and I will use it If I can move on with the currents issues.
>
> For me your code works perfectly (I'm using 1.9.16-SNAPSHOT)
>
> I did:
>>
>> jfarcand_at_jfarcand-desktop:/appserv80/grizzly/gws_comet$ jdebug
>> -Dcom.sun.grizzly.enableSnoop=true
>> -Dcom.sun.grizzly.displayConfiguration=true -cp
>>
>> /appserv80/grizzly/trunk/modules/bundles/comet/target/grizzly-comet-webserver-1.9.16-SNAPSHOT.jar:.
>> ar.com.alttab.webserver.Test
>> Listening for transport dt_socket at address: 9009
>> 22-May-2009 12:56:24 PM com.sun.grizzly.http.SelectorThread
>> displayConfiguration
>> INFO: Grizzly configuration for port 8080
>> Thread Pool: StatsThreadPool[name=http, priority=10,
>> min-threads=5, max-threads=5, max-queue-size=4096,
>> initial-byte-buffer-size=8192, byte-buffer-type=HEAP_VIEW,
>> is-shutdown=false, port=8080]
>> ByteBuffer size: 8192
>> maxHttpHeaderSize: 8192
>> maxKeepAliveRequests: 256
>> keepAliveTimeoutInSeconds: 30
>> Static File Cache enabled: true
>> Static resources directory:
>> /home/jfarcand/workspace/grizzly/gws_comet
>> Adapter : com.sun.grizzly.tcp.http11.GrizzlyAdapterChain
>> Asynchronous Request Processing enabled: true
>> 22-May-2009 12:56:33 PM com.sun.grizzly.http.ProcessorTask parseRequest
>> INFO: SocketChannel request linejava.nio.channels.SocketChannel[connected
>> local=/127.0.0.1:8080 remote=/127.0.0.1:39679] is: R( /)
>> 22-May-2009 12:56:33 PM com.sun.grizzly.http.ProcessorTask parseRequest
>> INFO: SocketChannel headersjava.nio.channels.SocketChannel[connected
>> local=/127.0.0.1:8080 remote=/127.0.0.1:39679] are: === MimeHeaders ===
>> user-agent = Wget/1.11.4
>> accept = */*
>> host = 127.0.0.1:8080
>> connection = Keep-Alive
>>
>> Suspending : com.sun.grizzly.http.servlet.HttpServletRequestImpl_at_1712651
>> 22-May-2009 12:56:53 PM com.sun.grizzly.http.ProcessorTask parseRequest
>> INFO: SocketChannel request linejava.nio.channels.SocketChannel[connected
>> local=/127.0.0.1:8080 remote=/127.0.0.1:39680] is: R( /)
>> 22-May-2009 12:56:53 PM com.sun.grizzly.http.ProcessorTask parseRequest
>> INFO: SocketChannel headersjava.nio.channels.SocketChannel[connected
>> local=/127.0.0.1:8080 remote=/127.0.0.1:39680] are: === MimeHeaders ===
>> user-agent = Wget/1.11.4
>> accept = */*
>> host = 127.0.0.1:8080
>> connection = Keep-Alive
>>
>> Suspending : com.sun.grizzly.http.servlet.HttpServletRequestImpl_at_6397eb
>> 22-May-2009 12:57:04 PM com.sun.grizzly.http.SocketChannelOutputBuffer
>> flushChannel
>> INFO: HTTP/1.1 200 OK
>> server: grizzly/1.9.16
>> Content-Length: 0
>> Date: Fri, 22 May 2009 16:57:04 GMT
>> Connection: Keep-Alive
>>
>>
>> 22-May-2009 12:57:23 PM com.sun.grizzly.http.SocketChannelOutputBuffer
>> flushChannel
>> INFO: HTTP/1.1 200 OK
>> server: grizzly/1.9.16
>> Content-Length: 0
>> Date: Fri, 22 May 2009 16:57:23 GMT
>> Connection: Keep-Alive
>
> And added the following line in
>
>> CometResponseHandler handler = new CometResponseHandler();
>> handler.attach(arg1);
>> context.addCometHandler(handler);
>> System.out.println("Suspending : " + arg0);
>
> I do see the Suspended called all the time, and also the push/notify. Ho can
> I reproduce your use case?
I don't see the call after addComet in the second client request until
I close the first call.
I'm using eclipse and running in debug mode Test.java. I will try
running the sample in the same way as you did. and I'll let you know
how it goes.
>
>>
>> Do you know if there are any plan to release Grizzly Comet Web Server
>> for nio framework 2.0?
>
> We are targetting June 2009. I will soon work on the Comet implementation
> (after J1).
Excellent.
>
>>
>> Last question, (already asked on the other thread), is there any way
>> to add a ProtocolFilter to GrizzlyWebServer, I have been playing with
>> netty and have the chance to add Custom Handlers to the channel, so I
>> was thinking to add ProtocolHandler, CompressionHandler and
>> CryptoHandler.
>
> Yes, and I've answered:
>
>> In Grizzly you will do something like:
>>
>> GrizzlyWebServer.getSelectorThread().getSelectorHandler().
>> getProtocolChain().poll().addFilter(2,yourCustomProtocolParser());
>
>
>>
>> Another good use of Filters in my case could be to transform
>> documents, I'm going to access different content from moble phones so
>> maybe a good service to add in the Daemon could be a
>> DocumentTransformationFilter, that extract text/html from pdf, doc,
>> docx (I already have this implemented in a DTS Service running
>> standalone).
>>
>> What do you think?
>
> I think that could be pretty simple to do that inside a GrizzlyAdapter
> instead of a ProtocolFilter. Inside the grizzlyAdapter all the headers will
> be parsed for you, and you just have to manipulate the body of the request.
Yeah, could be and options, I was thinking in something like the
CompressionFilter, CryptoFilter, TransformationFilter to abstract that
process from the GrizzleAdapter, in the adapter I'm going to do just
validations/authentication and messages routing from daemon to proxy.
I will try to think more about this and elaborate in another post.
Thank you!!
Cesar.-
>
> Thanks!
>
> -- Jeanfrancois
>
>
>>
>> Thanks
>>
>> Cesar.-
>>
>>
>> On Thu, May 21, 2009 at 10:18 PM, Jeanfrancois Arcand
>> <Jeanfrancois.Arcand_at_sun.com> wrote:
>>>
>>> Salut,
>>>
>>> I'm back (was releasing this little monster -> http://is.gd/Cb5Y)
>>>
>>> César Fernando Henriques wrote:
>>>>
>>>> Maybe I'm getting wrong... but is supposed that the request get
>>>> suspened for different client's. In my case the servlet serve one
>>>> client and suspend... that's ok, if I dispacth a comet event the
>>>> response is updated with the notify, but I I create another request to
>>>> the servlet from another client the servlet doesn't respond until I
>>>> close the previuos request (Close the browser).
>>>>
>>>> I don't think that should be happening... but maybe I'm totally
>>>> confused.
>>>
>>> No you are correct. I suspect there is not enough threads...but that
>>> strange. I will play with the sample (THANKS) to see what's happening.
>>>
>>> Apology for the delay.
>>>
>>> -- Jeanfrancois
>>>
>>>> Thanks!
>>>>
>>>> On Thu, May 21, 2009 at 6:01 PM, Jeanfrancois Arcand
>>>> <Jeanfrancois.Arcand_at_sun.com> wrote:
>>>>>
>>>>> Salut,
>>>>>
>>>>> César Fernando Henriques wrote:
>>>>>>
>>>>>> Jean, Yes, the service method is invoked, and the event is dispatched
>>>>>> on CometResponseHandler. My problem is that the Servlet running on
>>>>>> GrizzlyWebServer is blocking and I just can serve one client at time.
>>>>>
>>>>> OK but all request gets suspended and that's normal you don't get any
>>>>> response. What are you expecting?
>>>>>
>>>>> Thanks!
>>>>>
>>>>> -- jeanfrancois
>>>>>
>>>>>> I have attached the code.
>>>>>>
>>>>>> Thanks you!!!
>>>>>>
>>>>>> On Thu, May 21, 2009 at 5:43 PM, Jeanfrancois Arcand
>>>>>> <Jeanfrancois.Arcand_at_sun.com> wrote:
>>>>>>>
>>>>>>> Salut,
>>>>>>>
>>>>>>> Survivant 00 wrote:
>>>>>>>>
>>>>>>>> I never did comet stuff yet, but here a snippet that will enable
>>>>>>>> comet.
>>>>>>>>
>>>>>>>>
>>>>>>>> // comet
>>>>>>>> if(cometEnabled){
>>>>>>>> SelectorThread st = ws.getSelectorThread();
>>>>>>>> AsyncHandler asyncHandler = new
>>>>>>>> DefaultAsyncHandler();
>>>>>>>> asyncHandler.addAsyncFilter(new CometAsyncFilter());
>>>>>>>> st.setAsyncHandler(asyncHandler);
>>>>>>>> st.setEnableAsyncExecution(true);
>>>>>>>> }
>>>>>>>>
>>>>>>> No this not not needed.
>>>>>>>
>>>>>>> Cesar, is the service method of your GrizzlyAdapter invoked? Can you
>>>>>>> send
>>>>>>> me
>>>>>>> the entire class so I can try?
>>>>>>>
>>>>>>> Thanks
>>>>>>>
>>>>>>> -- Jeanfrancois
>>>>>>>
>>>>>>>>
>>>>>>>> 2009/5/21 César Fernando Henriques <cesar_at_alttab.com.ar
>>>>>>>> <mailto:cesar_at_alttab.com.ar>>
>>>>>>>>
>>>>>>>> Hi guys, I'm runnign the following code and something is wrong, the
>>>>>>>> servlet is blocking so I just can serve one client at time. Is that
>>>>>>>> supposed to work in that way?
>>>>>>>>
>>>>>>>> Sorry if this is a silly question.. I'm new to Grizzly.
>>>>>>>>
>>>>>>>>
>>>>>>>> GrizzlyWebServer server = new GrizzlyWebServer(80);
>>>>>>>>
>>>>>>>> server.addAsyncFilter(new CometAsyncFilter());
>>>>>>>>
>>>>>>>> server.addGrizzlyAdapter(new ServletAdapter(new
>>>>>>>> MyServlet()),
>>>>>>>> new String[]{"/"});
>>>>>>>>
>>>>>>>> server.addGrizzlyAdapter(new GrizzlyAdapter() {
>>>>>>>>
>>>>>>>> @Override
>>>>>>>> public void service(GrizzlyRequest arg0, GrizzlyResponse
>>>>>>>> arg1) {
>>>>>>>>
>>>>>>>> CometEngine cometEngine = CometEngine.getEngine();
>>>>>>>> CometContext cometContext =
>>>>>>>> cometEngine.getCometContext("caca");
>>>>>>>>
>>>>>>>> try {
>>>>>>>> cometContext.notify("Chatter test has joined.");
>>>>>>>> } catch (IOException e) {
>>>>>>>> // TODO Auto-generated catch block
>>>>>>>> e.printStackTrace();
>>>>>>>> }
>>>>>>>> }
>>>>>>>> }, new String[] { "/test" });
>>>>>>>>
>>>>>>>> try {
>>>>>>>> server.start();
>>>>>>>> } catch (IOException e) {
>>>>>>>> // TODO Auto-generated catch block
>>>>>>>> e.printStackTrace();
>>>>>>>> }
>>>>>>>>
>>>>>>>>
>>>>>>>> Regards.-
>>>>>>>>
>>>>>>>>
>>>>>>>> ---------------------------------------------------------------------
>>>>>>>> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
>>>>>>>> <mailto:users-unsubscribe_at_grizzly.dev.java.net>
>>>>>>>> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>>>>>>>> <mailto: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
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> ------------------------------------------------------------------------
>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> 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
>>>>>
>>>>>
>>>> ---------------------------------------------------------------------
>>>> 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
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> 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
>
>