org.apache.mina.filter
Class WriteBufferLimitFilterBuilder

java.lang.Object
  extended by org.apache.mina.filter.WriteBufferLimitFilterBuilder

public class WriteBufferLimitFilterBuilder
extends Object

This filter will turn the asynchronous filterWrite method in to a blocking send when there are more than the prescribed number of messages awaiting filterWrite. It should be used in conjunction with the ReadThrottleFilterBuilder on a server as the blocking writes will allow the read thread to cause an Out of Memory exception due to a back log of unprocessed messages. This is should only be viewed as a temporary work around for DIRMINA-302. A true solution should not be implemented as a filter as this issue will always occur. On a machine where the network is slower than the local producer. Suggested improvement is to allow implementation of policices on what to do when buffer is full. They could be: Block - As this does Wait on a given Future - to drain more of the queue.. in essence this filter with high/low watermarks Throw Exception - through the client filterWrite() method to allow them to get immediate feedback on buffer state

Usage:


 DefaultFilterChainBuilder builder = ...
 WriteBufferLimitFilterBuilder filter = new WriteBufferLimitFilterBuilder();
 filter.attach( builder );
 

or


 IoFilterChain chain = ...
 WriteBufferLimitFilterBuilder filter = new WriteBufferLimitFilterBuilder();
 filter.attach( chain );
 

Version:
$Rev: 619823 $, $Date: 2008-02-08 10:09:37 +0000 (Fri, 08 Feb 2008) $

Nested Class Summary
 class WriteBufferLimitFilterBuilder.SendLimit
           
 
Field Summary
static String PENDING_SIZE
           
 
Constructor Summary
WriteBufferLimitFilterBuilder()
           
WriteBufferLimitFilterBuilder(int maxWriteBufferSize)
           
 
Method Summary
 void attach(org.apache.mina.common.DefaultIoFilterChainBuilder builder)
          Attach this filter to the specified builder.
 void attach(org.apache.mina.common.IoFilterChain chain)
          Attach this filter to the specified filter chain.
 void setMaximumConnectionBufferCount(int maximumConnectionBufferCount)
          Set the maximum amount pending items in the writeQueue for a given session.
 void setMaximumConnectionBufferSize(long maximumConnectionBufferSize)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PENDING_SIZE

public static final String PENDING_SIZE
Constructor Detail

WriteBufferLimitFilterBuilder

public WriteBufferLimitFilterBuilder()

WriteBufferLimitFilterBuilder

public WriteBufferLimitFilterBuilder(int maxWriteBufferSize)
Method Detail

setMaximumConnectionBufferCount

public void setMaximumConnectionBufferCount(int maximumConnectionBufferCount)
Set the maximum amount pending items in the writeQueue for a given session. Changing the value will only take effect when new data is received for a connection, including existing connections. Default value is 5000 msgs.

Parameters:
maximumConnectionBufferCount - New buffer size. Must be > 0

setMaximumConnectionBufferSize

public void setMaximumConnectionBufferSize(long maximumConnectionBufferSize)

attach

public void attach(org.apache.mina.common.IoFilterChain chain)
Attach this filter to the specified filter chain. It will search for the ThreadPoolFilter, and attach itself before and after that filter.

Parameters:
chain - IoFilterChain to attach self to.

attach

public void attach(org.apache.mina.common.DefaultIoFilterChainBuilder builder)
Attach this filter to the specified builder. It will search for the ExecutorFilter, and attach itself before and after that filter.

Parameters:
builder - DefaultIoFilterChainBuilder to attach self to.


Licensed to the Apache Software Foundation