Daniel John Debrunner wrote:
Emmanuel Lecharny wrote:
Daniel John Debrunner wrote:

I'm seeing hangs when I use an IoEventQueueThrottle as below. I read the comments in the javadoc about requiring an executor in the filter chain. I get no hangs if I do not add "writeThrottle" into the chain (my app is currently throttling by waiting for every 100th write to complete).

// Setup
NioSocketConnector connector = new NioSocketConnector();
connector.getFilterChain().addFirst("executor", new ExecutorFilter(1));
connector.getFilterChain().addLast("writeThrottle",
    new WriteRequestFilter(new IoEventQueueThrottle(10)));


// message sennding

IoBuffer buf = prepareBuffer();

WriteFuture wf = session.write(buf);

Are there any examples of how to use IoEventQueueThrottle for write throttling?

The problem is that you probably have a slow client. Even if you use a throttling mechanism, you will block one thread until all the write is done.

I don't think so. Without the "writeThrottle" in the filter chain I see 8000-20000/sec messages sent from the above code to a mina server (2.0 M6).
Hmmm. So wrong assumption from my side : you don't have a slow client.
Adding the "writeThrottle" leads to a hang, no messages seen by the client.


That would be good for sure to have such a mechanism implemented in MINA... This is not exactly what does the IoEventQueueThrottler : it does limit the size of data sent to the client to a certain size, limiting the throughput. Probably not what you want.

So the threshold parameter to IoEventQueueThrottler constructor is number of bytes, not number of messages?
Number of bytes. Here is the portion of code which does that :

   public void offered(Object source, IoEvent event) {
       int eventSize = estimateSize(event);
       int currentCounter = counter.addAndGet(eventSize);
       logState();

       if (currentCounter >= threshold) {
           block();
       }
   }

FYI, the counter is *never* decreased.

To be frank, this is not a piece of code I know, but from what I see, it's *extremly* dubious that id does something useful, and most likely to block forever.

I would suggest not to use this, and to fill a JIRA reporting the problem.

Sorry for that...

--
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org


Reply via email to