dev@grizzly.java.net

Re: testing threadpool

From: gustav trede <gustav.trede_at_gmail.com>
Date: Mon, 6 Apr 2009 23:00:27 +0200

2009/4/6 rama <rama.rama_at_tiscali.it>

> Hello!
>
> i am testing the new threadpool on the current snapshot of 1.9.11 release
>
>
> standing to source, there are 2 different thread pool that can be used
> right now
> Sending
>
> java/grizzly/trunk/code/modules/utils/src/main/java/com/sun/grizzly/util/FixedThreadPool.java
> Adding
>
> java/grizzly/trunk/code/modules/utils/src/main/java/com/sun/grizzly/util/TestThreadPool.java
>
> the 1st one should act as "normally"
> the 2nd one should add worker when all worker are busy and when
> currentthread < maxthread
>
> (that's what i have understand for now)
>
> so, i start a little class with
> GrizzlyWebServer ws = new GrizzlyWebServer(path);
> ws.getSelectorThread().setThreadPool(new TestThreadPool());
> ws.addGrizzlyAdapter(new GrizzlyAdapter() {
> public void service(GrizzlyRequest a1,
> GrizzlyResponse a2) {
>
> System.out.println(Thread.currentThread().getName());
> try { Thread.sleep(10000);} catch
> (InterruptedException e) {}
> }
> }, new String[]{"/"});
> ws.start();
>
> that basically set the threadpool with the testthreadpool (or fixed)
>
> when i run it i got
> AVVERTENZA: Cannot guess which ThreadFactory the ExecutorService is using.
> Some ClassCastException might be throw if the ThreadFactory isn't creating
> instance of com.sun.grizzly.http.HttpWorkerThread
>
> and if i try to connect
> GRAVE: ProtocolChain exception
> java.lang.NullPointerException
> at com.sun.grizzly.filter.ReadFilter.execute(ReadFilter.java:124)
> at com.sun.grizzly.filter.ReadFilter.execute(ReadFilter.java:100)
> at
> com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:136)
> at
> com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:103)
> at
> com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:89)
> at
> com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
> at
> com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:67)
> at
> com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
> at
> java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:269)
> at java.util.concurrent.FutureTask.run(FutureTask.java:123)
> at
> com.sun.grizzly.util.FixedThreadPool$BasicWorker.dowork(FixedThreadPool.java:252)
> at
> com.sun.grizzly.util.FixedThreadPool$BasicWorker.run(FixedThreadPool.java:237)
> at java.lang.Thread.run(Thread.java:613)
>
>
> i am doing something of wrong to test the new stuff?
>

There are constructors which take ThreadFactory as parameter if the default
WorkerThreadImpl dont cut it.

I have never used the TestThreadPool myself, only compiled it.
Comet uses the Fixed one though.