You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by tiandike <wh...@21cn.com> on 2007/10/26 10:13:58 UTC

a question about SessionBuffer

I find in  ExecutorFilter   the request will  be wrapped in event and put in 
SessionBuffer.eventQueue field .
If  my handler handle request slow  and client send request faster ,will the 
size of eventQueue  became huge and lead to OutofMemoryException error?
Thanks
-- 
View this message in context: http://www.nabble.com/a-question-about-SessionBuffer-tf4695808s16868.html#a13422687
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.


Re: a question about SessionBuffer

Posted by Trustin Lee <tr...@gmail.com>.
You are right.  It's a known issue.  Please refer to the following issue:

https://issues.apache.org/jira/browse/DIRMINA-464

So you need to move the ProtocolCodecFilter behind ExecutorFilter, and
then ReadThrottleFilterBuilder will start to work.

HTH,
Trustin

On 10/29/07, tiandike <wh...@21cn.com> wrote:
>
> i add ReadThrottleFilterBuilder in my code ,but find it's invalid .
>
>
> my code is :
>  IoAcceptor acceptor = new SocketAcceptor(num,
> Executors.newCachedThreadPool());
>         IoAcceptorConfig config = new SocketAcceptorConfig();
>         config.setThreadModel(ThreadModel.MANUAL);
>         DefaultIoFilterChainBuilder chain = config.getFilterChain();
>        chain.addLast("codec",new ProtocolCodecFilter(new
> TextLineCodecFactory()));
>         chain.addLast("threadPool", new
> ExecutorFilter(Executors.newCachedThreadPool()));
>
>         UICReadThrottleFilterBuilder readThrottleFilterBuilder = new
> UICReadThrottleFilterBuilder();
>             readThrottleFilterBuilder.attach(chain);
>
>        acceptor.bind(new InetSocketAddress(PORT), new
> EchoProtocolHandler1(),
>                 config);
> ....................
>
>
> i find in sourcecode :
>  if (message instanceof ByteBuffer) {
>                 add(session, ((ByteBuffer) message).remaining());
>             }
>
> and at this time  message is not the instanceof ByteBuffer so add function
> will never be executed!
>
>
>
>
> Trustin Lee wrote:
> >
> > On 10/26/07, tiandike <wh...@21cn.com> wrote:
> >>
> >> I find in  ExecutorFilter   the request will  be wrapped in event and put
> >> in
> >> SessionBuffer.eventQueue field .
> >> If  my handler handle request slow  and client send request faster ,will
> >> the
> >> size of eventQueue  became huge and lead to OutofMemoryException error?
> >
> > Yes.  That's why you need to use ReadThrottleFilterBuilder.
> >
> > HTH,
> > Trustin
> > --
> > what we call human nature is actually human habit
> > --
> > http://gleamynode.net/
> > --
> > PGP Key ID: 0x0255ECA6
> >
> >
>
> --
> View this message in context: http://www.nabble.com/a-question-about-SessionBuffer-tf4695808s16868.html#a13463313
> 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

Re: a question about SessionBuffer

Posted by tiandike <wh...@21cn.com>.
i add ReadThrottleFilterBuilder in my code ,but find it's invalid .


my code is :
 IoAcceptor acceptor = new SocketAcceptor(num,
Executors.newCachedThreadPool());
        IoAcceptorConfig config = new SocketAcceptorConfig();
        config.setThreadModel(ThreadModel.MANUAL);
        DefaultIoFilterChainBuilder chain = config.getFilterChain();
       chain.addLast("codec",new ProtocolCodecFilter(new
TextLineCodecFactory()));
        chain.addLast("threadPool", new
ExecutorFilter(Executors.newCachedThreadPool()));
        
        UICReadThrottleFilterBuilder readThrottleFilterBuilder = new
UICReadThrottleFilterBuilder();   	      
	    readThrottleFilterBuilder.attach(chain);

       acceptor.bind(new InetSocketAddress(PORT), new
EchoProtocolHandler1(),
                config);
....................


i find in sourcecode :
 if (message instanceof ByteBuffer) {
                add(session, ((ByteBuffer) message).remaining());
            }

and at this time  message is not the instanceof ByteBuffer so add function
will never be executed!




Trustin Lee wrote:
> 
> On 10/26/07, tiandike <wh...@21cn.com> wrote:
>>
>> I find in  ExecutorFilter   the request will  be wrapped in event and put
>> in
>> SessionBuffer.eventQueue field .
>> If  my handler handle request slow  and client send request faster ,will
>> the
>> size of eventQueue  became huge and lead to OutofMemoryException error?
> 
> Yes.  That's why you need to use ReadThrottleFilterBuilder.
> 
> HTH,
> Trustin
> -- 
> what we call human nature is actually human habit
> --
> http://gleamynode.net/
> --
> PGP Key ID: 0x0255ECA6
> 
> 

-- 
View this message in context: http://www.nabble.com/a-question-about-SessionBuffer-tf4695808s16868.html#a13463313
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.


Re: a question about SessionBuffer

Posted by Trustin Lee <tr...@gmail.com>.
On 10/26/07, tiandike <wh...@21cn.com> wrote:
>
> I find in  ExecutorFilter   the request will  be wrapped in event and put in
> SessionBuffer.eventQueue field .
> If  my handler handle request slow  and client send request faster ,will the
> size of eventQueue  became huge and lead to OutofMemoryException error?

Yes.  That's why you need to use ReadThrottleFilterBuilder.

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