mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Frédéric Brégier <fred.breg...@free.fr>
Subject Re: ThreadPool in Mina with concurrent from Java5 Howto ?
Date Tue, 26 Sep 2006 05:15:57 GMT
In addition of my previous mail,
I have one question :
Why in the interface of new SocketAcceptor(nbThread, executor1)
do we precise the number of Thread ?
Is it relative to the number of thread in the executor or not ?
If yes, should we say in the API that executor should be a
fixedThreadPool (and the number of thread could be determined
from the ThreadPoolExecutor).

Frederic
----- Original Message ----- 
From: "Frédéric Brégier"
Sent: Monday, September 25, 2006 8:55 PM
Subject: Re: ThreadPool in Mina with concurrent from Java5 Howto ?


Sorry to come back on this subject, but I am a bit
confused with the Mina logic for ThreadPool.

First, what I suppose to understand :
- First IoAcceptor have one ThreadPool to handle
 incoming IoSessions.
- Second, the IoConfig use a ThreadPool to handle
 process of filters.
- Eventually, in the filter chain, we can insert a new ThreadPool
 for specific filters that are supposed to consume a lot of cpu
(for example compression or ssl ?).

For me, the doc says there are two level of ThreadPool management,
but in the API I found three levels. Do I missed something ?

Now from the coding part, I do the following.
Of course, if I am wrong in the model, it should be wrong
also in the code, so don't hesitate to give me your advice.

(exemple is with Socket)

0) I define several ThreadPool :
Executor executor1 = Executors.newFixedThreadPool(nbThread1);
Executor executor2 = Executors.newCachedThreadPool();
Executor executor3 = Executors.newCachedThreadPool();

1) Put a fixed threadPool to IoAcceptor : let me known if someone
can say if it is better here to use a CachedThreadPool or a FixedThreadPool
?
It highly depends I woul say how Mina is using it.

IoAcceptor acceptor = new SocketAcceptor(nbThread, executor1);

2) Put a cached threadPool in IoAcceptorConfig :
I don't know here if it is the same than (1) or not ?
When I look into the code of Mina, it seems not,
but I am really not sure.

IoAccaptorConfig config = new SocketAcceptorConfig();
config.setThreadModel(executor2);

Also I don't understand why Peter (and in the old doc)
I should use :
IoConfig.setThreadModel( ThreadModel.MANUAL );

3) And finally inside the filter chain, for instance for "compression" :

IoFilterChain chain = IoConfig.getFilterChain();
chain.addLast( "compressionPool",
   new ExecutorFilter( new ExecutorExecutor( executor3 ) ) );
chain.addLast( "compression", compressionFilter);


Thank you for your help
Frederic



Mime
View raw message