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 Mon, 25 Sep 2006 18:55:45 GMT
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();

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

View raw message