Thank you Frederic for the detailed instruction!  I really appreciate it!

Regards,
Trustin

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

It is only my own experience, but here is my way to set
Thread Pool for several part of Mina in 1.0 :

For SocketAcceptor (or IoAcceptor) :
    Executor executor1 = Executors.newFixedThreadPool(nbThread);
    SocketAcceptor acceptor = new SocketAcceptor(nbThread, executor1);

My feeling is that it shouldn't be a newCachedThreadPool here since
it seems it is relative to the number of SocketIoProcessors that
the SocketAcceptor will use.
By default (new SocketAcceptor() without arguments), it use
a value of 16 threads and SocketIoProcessors.

For SocketAcceptorConfig (or IoAcceptorConfig), in order to
be able to specify my own Thread Pool Filter:
    SockectAccaptorConfig config = new SocketAcceptorConfig();
    config.setThreadModel(ThreadModel.MANUAL);

Then for the filter chain (example here is for compression) :
    IoFilterChain chain = config.getFilterChain();

    Executor executor2 = Executors.newCachedThreadPool();
    chain.addLast( "compressionPool",
        new ExecutorFilter( new ExecutorExecutor( executor2 ) ) );
    chain.addLast( "compression", compressionFilter);

And so on for any Filters that could be expensive in cpu...

    chain.addLast( "otherPool",
        new ExecutorFilter( new ExecutorExecutor(
            Executors.newCachedThreadPool() ) ) );
    chain.addLast( "other", other);

You can use also newFixedThreadPool instead of
newCachedThreadPool as you want here for FilterChain.

Hope this helps you.
Frederic




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