You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by notz <pa...@gmx.at> on 2007/12/12 12:55:42 UTC

Problem with ExecutorFilter and IoHandler

i currently use the mina framework with an jabber server. all users get
connected trough a connection manager that holds only 5 connections to the
server. on the server i have added on the SockectAcceptor an ExecuteFilter
like this:

socketAcceptor = new
SocketAcceptor(Runtime.getRuntime().availableProcessors(),
Executors.newCachedThreadPool());
socketAcceptor.getDefaultConfig().setThreadModel(ThreadModel.MANUAL);
socketAcceptor.getFilterChain().addFirst("xmpp", new ProtocolCodecFilter(new
XMPPCodecFactory()));
socketAcceptor.getFilterChain().addLast("threadPool", new ExecutorFilter());
 
my problem: if one IoHandler.messageReceived() is blocking for a longer time
- the hole underlying connection is blocking and no new thread is used to
process the next message. is that not the reason why i added an
ExecutorFilter?

i never get more active threads in my ExecutorFilter - ThreadPool than
connections to the server.

thanks for any advice, what i did wrong.
notz
-- 
View this message in context: http://www.nabble.com/Problem-with-ExecutorFilter-and-IoHandler-tp14293759s16868p14293759.html
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.


Re: Problem with ExecutorFilter and IoHandler

Posted by notz <pa...@gmx.at>.
> Did you try to change the order in your filterChain,
> beginning first by the threadPool and then your codec ?

> Also for your threadPool (I suppose you use Mina 1.X),
> your example show no threadpool in the ExecutorFilter.
> I would suggest you to do as :
> executor = Executors.newCachedThreadPool();

an new ExectuorFilter also creates by default a new ThreadPoolExecutor. but
i also tried your suggestion.

> socketAcceptor.getFilterChain().addLast("threadPool", new
> ExecutorFilter(executor));
> socketAcceptor.getFilterChain().addLast("xmpp", new
> ProtocolCodecFilter(new
> XMPPCodecFactory()));

i also tried this, but the behaviour havn't changed. i only can see with
jstack that the ExecutorThread is also processing the ProtocolCodecFilter.

any other hints?


notz wrote :

>
> i currently use the mina framework with an jabber server. all users get
> connected trough a connection manager that holds only 5 connections to the
> server. on the server i have added on the SockectAcceptor an ExecuteFilter
> like this:
>
> socketAcceptor = new
> SocketAcceptor(Runtime.getRuntime().availableProcessors(),
> Executors.newCachedThreadPool());
> socketAcceptor.getDefaultConfig().setThreadModel(ThreadModel.MANUAL);
> socketAcceptor.getFilterChain().addFirst("xmpp", new
> ProtocolCodecFilter(new
> XMPPCodecFactory()));
> socketAcceptor.getFilterChain().addLast("threadPool", new
> ExecutorFilter());
>
> my problem: if one IoHandler.messageReceived() is blocking for a longer
> time
> - the hole underlying connection is blocking and no new thread is used to
> process the next message. is that not the reason why i added an
> ExecutorFilter?
>
> i never get more active threads in my ExecutorFilter - ThreadPool than
> connections to the server.
>
> thanks for any advice, what i did wrong.
> notz
> --
> View this message in context:
>
http://www.nabble.com/Problem-with-ExecutorFilter-and-IoHandler-tp14293759s16868p14293759.html
> Sent from the Apache MINA Support Forum mailing list archive at
> Nabble.com.
>
>




-- 
View this message in context: http://www.nabble.com/Problem-with-ExecutorFilter-and-IoHandler-tp14293759s16868p14300592.html
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.


Re: Problem with ExecutorFilter and IoHandler

Posted by fr...@free.fr.
Did you try to change the order in your filterChain,
beginning first by the threadPool and then your codec ?

Also for your threadPool (I suppose you use Mina 1.X),
your example show no threadpool in the ExecutorFilter.
I would suggest you to do as :
executor = Executors.newCachedThreadPool();
socketAcceptor.getFilterChain().addLast("threadPool", new
ExecutorFilter(executor));
socketAcceptor.getFilterChain().addLast("xmpp", new ProtocolCodecFilter(new
 XMPPCodecFactory()));

And don't forget to do after unbind()
executor.shutdown();

Frederic

notz wrote :

>
> i currently use the mina framework with an jabber server. all users get
> connected trough a connection manager that holds only 5 connections to the
> server. on the server i have added on the SockectAcceptor an ExecuteFilter
> like this:
>
> socketAcceptor = new
> SocketAcceptor(Runtime.getRuntime().availableProcessors(),
> Executors.newCachedThreadPool());
> socketAcceptor.getDefaultConfig().setThreadModel(ThreadModel.MANUAL);
> socketAcceptor.getFilterChain().addFirst("xmpp", new ProtocolCodecFilter(new
> XMPPCodecFactory()));
> socketAcceptor.getFilterChain().addLast("threadPool", new ExecutorFilter());
>
> my problem: if one IoHandler.messageReceived() is blocking for a longer time
> - the hole underlying connection is blocking and no new thread is used to
> process the next message. is that not the reason why i added an
> ExecutorFilter?
>
> i never get more active threads in my ExecutorFilter - ThreadPool than
> connections to the server.
>
> thanks for any advice, what i did wrong.
> notz
> --
> View this message in context:
>
http://www.nabble.com/Problem-with-ExecutorFilter-and-IoHandler-tp14293759s16868p14293759.html
> Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.
>
>



Re: Problem with ExecutorFilter and IoHandler

Posted by Trustin Lee <tr...@gmail.com>.
Hi Notz,

On Dec 13, 2007 7:06 PM, notz <pa...@gmx.at> wrote:
>
> i can provide a thread dump, but i think missunderstanding something. i
> looked into the ExecutorFilter source code and there is a Session based
> queue. so there can never be 2 threads that processing events from 1 session
> - so this ExecutorFilter can't help me nor i see which advantage it will
> provide.
>
> but it the ExecutorFilter code is very helpfull to write my own
> ExecutorFilter that has no session based queue....

Ah I see.  Now I understood your problem.  MINA 2 provides an option
that disables per-session queue, so please feel free to modify
ExecutorFilter meanwhile.

Thanks,
Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6

Re: Problem with ExecutorFilter and IoHandler

Posted by notz <pa...@gmx.at>.
i can provide a thread dump, but i think missunderstanding something. i
looked into the ExecutorFilter source code and there is a Session based
queue. so there can never be 2 threads that processing events from 1 session
- so this ExecutorFilter can't help me nor i see which advantage it will
provide.

but it the ExecutorFilter code is very helpfull to write my own
ExecutorFilter that has no session based queue....
-- 
View this message in context: http://www.nabble.com/Problem-with-ExecutorFilter-and-IoHandler-tp14293759s16868p14313017.html
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.


Re: Problem with ExecutorFilter and IoHandler

Posted by Trustin Lee <tr...@gmail.com>.
Could you please provide thread dump?

Trustin

On Dec 12, 2007 8:55 PM, notz <pa...@gmx.at> wrote:
>
> i currently use the mina framework with an jabber server. all users get
> connected trough a connection manager that holds only 5 connections to the
> server. on the server i have added on the SockectAcceptor an ExecuteFilter
> like this:
>
> socketAcceptor = new
> SocketAcceptor(Runtime.getRuntime().availableProcessors(),
> Executors.newCachedThreadPool());
> socketAcceptor.getDefaultConfig().setThreadModel(ThreadModel.MANUAL);
> socketAcceptor.getFilterChain().addFirst("xmpp", new ProtocolCodecFilter(new
> XMPPCodecFactory()));
> socketAcceptor.getFilterChain().addLast("threadPool", new ExecutorFilter());
>
> my problem: if one IoHandler.messageReceived() is blocking for a longer time
> - the hole underlying connection is blocking and no new thread is used to
> process the next message. is that not the reason why i added an
> ExecutorFilter?
>
> i never get more active threads in my ExecutorFilter - ThreadPool than
> connections to the server.
>
> thanks for any advice, what i did wrong.
> notz
> --
> View this message in context: http://www.nabble.com/Problem-with-ExecutorFilter-and-IoHandler-tp14293759s16868p14293759.html
> Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.
>
>



-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6