Hi Frederic,

On 9/26/06, Frédéric Brégier <[EMAIL PROTECTED]> wrote:

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 ?


The documentation is outdated seriously.

First, there's no such level in MINA.  In MINA 0.8, we had two layers, but
they are merged into one layer, and there's only one filter chain per
session.   The thread model is decided by the number of ExecutorFilter you
inserted into the chain.  By default, one ExecutorFilter is inserted, but
you can change this behavior by setting a different ThreadModel.  Please
refer to ThreadModel JavaDoc and its subclasses.

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);


You usually don't need to specify the executor as a constructor parameter.
It's for some containers or microkernels which want to manage threading.

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.


(1) and (2) are very different as I answered above.

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 );


You can use ThreadModel.MANUAL if you want, but then you have to insert
ExecutorFilter by yourself.  The default thread model is a
PooledThreadModel.  ThreadModel extends IoFilterChainBuilder, and inserts an
appropriate thread pool filter into the filter chain when a session is
created.  So, if you set the right ThreadModel, you don't need to insert
another thread pool filter by yourself.

HTH,
Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP key fingerprints:
* E167 E6AF E73A CBCE EE41  4A29 544D DE48 FE95 4E7E
* B693 628E 6047 4F8F CFA4  455E 1C62 A7DC 0255 ECA6

Reply via email to