dev@grizzly.java.net

Re: issue with suspend request

From: Jeanfrancois Arcand <Jeanfrancois.Arcand_at_Sun.COM>
Date: Thu, 16 Apr 2009 14:46:15 -0400

Salut,

rama wrote:
>>
>> Looks like, from the test, that after invoking service you also need
>> to also Adapter.afterService(). Can you gives it a try? It still not
>> working I will take a look asap.
>>
>
> ok, i replace the resume with
> public void resumed(testGW attachment) {
> try {
>
> attachment.service(grizzlyRequest,httpResp);
> attachment.afterService(grizzlyRequest,
> httpResp);
> } catch (Exception e) {
> }
> }
>
> correct isn't it?
>
> (using the same example that i have write here)
>
> As for memory usage, it's hard to say since i can't test it.
>
> ab still don't work, even adding afterservice, for that reason simulate
> 10K of request will be a pain :S
>
> i have do something of wrong again?

Are you using ab with -k by any chance? Try it with if not

Let me look at it. Stay tuned (apology it may take couple of hour as all
kind of firedrill are happening on the GlassFish side :-))

A+

-- Jeanfrancois


>
>> Thanks Rama!!
>>
>> -- Jeanfrancois
>>
>>
>>> best regards
>>> ----code---
>>> import com.sun.grizzly.http.embed.
>>> GrizzlyWebServer;
>>> import com.sun.grizzly.tcp.CompletionHandler;
>>> import com.sun.grizzly.tcp.http11.GrizzlyAdapter;
>>> import com.sun.grizzly.tcp.
>>> http11.GrizzlyRequest;
>>> import com.sun.grizzly.tcp.http11.
>>> GrizzlyResponse;
>>> import java.util.concurrent.LinkedBlockingQueue;
>>> import java.util.concurrent.TimeUnit;
>>> public class test {
>>> public static void main( String arg[] ) throws Exception {
>>> GrizzlyWebServer ws = new GrizzlyWebServer();
>>> ws.
>>> getSelectorThread().setDisplayConfiguration(true);
>>> ws.
>>> addGrizzlyAdapter(new testGW());
>>> ws.start();
>>> }
>>> }
>>> class testGW extends GrizzlyAdapter {
>>> SP t = new SP();
>>> public void service(final GrizzlyRequest grizzlyRequest, final
>>> GrizzlyResponse httpResp) {
>>> if (!httpResp.isSuspended()) {
>>> httpResp.suspend(Integer.MAX_VALUE,this,new
>>> CompletionHandler<testGW>() {
>>> public void resumed(testGW attachment) {
>>> try {
>>> attachment.service(grizzlyRequest,
>>> httpResp);
>>> } catch (Exception e) {
>>> }
>>> }
>>> public void cancelled(testGW attachment) {
>>> throw new Error("Request cancelled?!?");
>>> }
>>> });
>>> t.add(httpResp);
>>> return;
>>> }
>>> try {
>>> String error = "bau";
>>> httpResp.
>>> setContentLength(error.length());
>>> httpResp.
>>> setContentType("text/html");
>>> httpResp.setStatus(404);
>>> httpResp.getWriter().print(error);
>>> } catch (Exception e) {
>>> }
>>> }
>>> }
>>> class SP extends Thread {
>>> LinkedBlockingQueue<GrizzlyResponse> v = new
>>> LinkedBlockingQueue<GrizzlyResponse>();
>>> public void add
>>> (GrizzlyResponse httpResp) {
>>> v.add(httpResp);
>>> }
>>> public SP() {
>>> this.start();
>>> }
>>> public void run() {
>>> while (true) {
>>> try {
>>> GrizzlyResponse e = v.poll(10, TimeUnit.SECONDS);
>>> if (e==null) continue;
>>> Thread.sleep(10);
>>> e.
>>> resume();
>>> } catch (InterruptedException e1) {
>>> }
>>> }
>>> }
>>> }
>>> ----
>>> Arriva Tiscali Mobile! Acquista la tua SIM Tiscali a soli €5 e scopri
>>> la semplicità e la convenienza del nuovo servizio per il tuo
>>> cellulare. Passa a Tiscali Mobile
>>> http://abbonati.tiscali.it/promo/tiscalimobile/
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe_at_grizzly.dev.java.net
>>> <mailto:dev-unsubscribe_at_grizzly.dev.java.net>
>>> For additional commands, e-mail: dev-help_at_grizzly.dev.java.net
>>> <mailto:dev-help_at_grizzly.dev.java.net>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe_at_grizzly.dev.java.net
>> <mailto:dev-unsubscribe_at_grizzly.dev.java.net>
>> For additional commands, e-mail: dev-help_at_grizzly.dev.java.net
>> <mailto:dev-help_at_grizzly.dev.java.net>
>>
>