You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Trustin Lee <tr...@gmail.com> on 2005/09/30 04:47:57 UTC

Re: Delay forwarding data

Hi Christian,

2005/9/29, Christian Beil <ch...@web.de>:
>
> we talked some time ago. I told you about the SALSA project I'm working
> on and that we use MINA.
> I am programming a kind of proxy and it works fine.
> But I need to delay some of the forwarded data.
> I am analyzing MINA framework myself, but I think you know it a little
> better :-)
> I wondered if you have an idea how this could be achieved.
> I hope you can help.


You'll have to take a look at SocketIoProcessor first. SocketIoProcessor
doesn't notify when a session is ready to read or write if you didn't
register for SelectionKey.OP_READ or OP_WRITE. So if you're going to block
writing you'll have to modify where SocketIoProcessor register for OP_WRITE
flag. For write operations, it will start even if OP_WRITE flag is not set
when user requests write operation immediately. You'll have to modify
SocketIoProcessor not to flush the writeBufferQueue when the session is
'suspended' for write opertaions.

HTH,
Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/

Re: Delay forwarding data

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

I appologize for this late reply first of all. It was a busy week.

2005/10/17, Christian Beil <ch...@web.de>:
>
> thanks for your help last time. It really was. I found the part in
> SocketIoProcessor I have to modify.
> I hope you could help me again :-)
> I'm considering whether I should realize this message delaying stuff
> like this (modifying MINA), or if I should add a DelayingQueue to my
> framework.
> Incoming messages would then be handed to the DelyingQueue (in its own
> thread) and be fired out from there after some time.
> What do you think of this?
> But now I need another feature: I want to stop reading from the remote
> side of the proxy for some session, if the mobile client side of the
> proxy is unable to receive messages for the moment. A kind of flow
> control. Is it possible to stop reading from some sessions? I think I
> yet need to add some methods to SocketIoProcessor to suspend some
> sessions, so that they will note be scheduled for flush.
> Perhaps add an attribute to the Session class and in
> SocketIoProcessor.processSessions(Set selectedKeys) check for this
> attribute and put the session in a SuspendedQueue. What do you think of
> this?
> Again I will be very grateful for your help.


For reads, it is much better to turn off SelectionKey.OP_READ for the
channel you want to suspend reading.

For writes, SocketIoProcess should not call flushSession() method until
suspension is not released.

It should be easy to implement and actually Niklas provided a patch for
this:

http://www.nabble.com/-mina-Traffic-control-patch-proposal-t427795.html#a1172083

But I didn't look into it yet.

How would a multiplexing filter for mina be, do you know the oldish
> WebMUX protocol?


I've just read WebMUX protocol specification roughly. If I understood
correctly, you could create a ProtocolEncoder and ProtocolDecoder that wraps
existing protocol Encoders and ProtocolDecoders.

Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/