org.apache.mina.filter.traffic
Class TrafficShapingFilter

java.lang.Object
  extended by org.apache.mina.common.IoFilterAdapter
      extended by org.apache.mina.filter.traffic.TrafficShapingFilter
All Implemented Interfaces:
IoFilter

public class TrafficShapingFilter
extends IoFilterAdapter

An IoFilter that limits bandwidth (bytes per second) related with read and write operations on a per-session basis.

It is always recommended to add this filter in the first place of the IoFilterChain.

Version:
$Rev: 594761 $, $Date: 2007-11-14 05:46:02 +0100 (Wed, 14 Nov 2007) $
Author:
The Apache MINA Project (dev@mina.apache.org)

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.mina.common.IoFilter
IoFilter.NextFilter
 
Constructor Summary
TrafficShapingFilter(ScheduledExecutorService scheduledExecutor, int maxReadThroughput, int maxWriteThroughput)
           
TrafficShapingFilter(ScheduledExecutorService scheduledExecutor, MessageSizeEstimator messageSizeEstimator, int maxReadThroughput, int maxWriteThroughput)
           
 
Method Summary
 void filterSetTrafficMask(IoFilter.NextFilter nextFilter, IoSession session, TrafficMask trafficMask)
          Filters IoSession.setTrafficMask(TrafficMask) method invocation.
 int getMaxReadThroughput()
           
 int getMaxWriteThroughput()
           
 MessageSizeEstimator getMessageSizeEstimator()
           
 ScheduledExecutorService getScheduledExecutor()
           
 void messageReceived(IoFilter.NextFilter nextFilter, IoSession session, Object message)
          Filters IoHandler.messageReceived(IoSession,Object) event.
 void messageSent(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest)
          Filters IoHandler.messageSent(IoSession,Object) event.
 void onPostRemove(IoFilterChain parent, String name, IoFilter.NextFilter nextFilter)
          Invoked after this filter is removed from the specified parent.
 void onPreAdd(IoFilterChain parent, String name, IoFilter.NextFilter nextFilter)
          Invoked before this filter is added to the specified parent.
 void setMaxReadThroughput(int maxReadThroughput)
           
 void setMaxWriteThroughput(int maxWriteThroughput)
           
 
Methods inherited from class org.apache.mina.common.IoFilterAdapter
destroy, exceptionCaught, filterClose, filterWrite, init, onPostAdd, onPreRemove, sessionClosed, sessionCreated, sessionIdle, sessionOpened
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TrafficShapingFilter

public TrafficShapingFilter(ScheduledExecutorService scheduledExecutor,
                            int maxReadThroughput,
                            int maxWriteThroughput)

TrafficShapingFilter

public TrafficShapingFilter(ScheduledExecutorService scheduledExecutor,
                            MessageSizeEstimator messageSizeEstimator,
                            int maxReadThroughput,
                            int maxWriteThroughput)
Method Detail

getScheduledExecutor

public ScheduledExecutorService getScheduledExecutor()

getMessageSizeEstimator

public MessageSizeEstimator getMessageSizeEstimator()

getMaxReadThroughput

public int getMaxReadThroughput()

setMaxReadThroughput

public void setMaxReadThroughput(int maxReadThroughput)

getMaxWriteThroughput

public int getMaxWriteThroughput()

setMaxWriteThroughput

public void setMaxWriteThroughput(int maxWriteThroughput)

onPreAdd

public void onPreAdd(IoFilterChain parent,
                     String name,
                     IoFilter.NextFilter nextFilter)
              throws Exception
Description copied from interface: IoFilter
Invoked before this filter is added to the specified parent. Please note that this method can be invoked more than once if this filter is added to more than one parents. This method is not invoked before IoFilter.init() is invoked.

Specified by:
onPreAdd in interface IoFilter
Overrides:
onPreAdd in class IoFilterAdapter
Parameters:
parent - the parent who called this method
name - the name assigned to this filter
nextFilter - the IoFilter.NextFilter for this filter. You can reuse this object until this filter is removed from the chain.
Throws:
Exception

onPostRemove

public void onPostRemove(IoFilterChain parent,
                         String name,
                         IoFilter.NextFilter nextFilter)
                  throws Exception
Description copied from interface: IoFilter
Invoked after this filter is removed from the specified parent. Please note that this method can be invoked more than once if this filter is removed from more than one parents. This method is always invoked before IoFilter.destroy() is invoked.

Specified by:
onPostRemove in interface IoFilter
Overrides:
onPostRemove in class IoFilterAdapter
Parameters:
parent - the parent who called this method
name - the name assigned to this filter
nextFilter - the IoFilter.NextFilter for this filter. You can reuse this object until this filter is removed from the chain.
Throws:
Exception

messageReceived

public void messageReceived(IoFilter.NextFilter nextFilter,
                            IoSession session,
                            Object message)
                     throws Exception
Description copied from interface: IoFilter
Filters IoHandler.messageReceived(IoSession,Object) event.

Specified by:
messageReceived in interface IoFilter
Overrides:
messageReceived in class IoFilterAdapter
Throws:
Exception

messageSent

public void messageSent(IoFilter.NextFilter nextFilter,
                        IoSession session,
                        WriteRequest writeRequest)
                 throws Exception
Description copied from interface: IoFilter
Filters IoHandler.messageSent(IoSession,Object) event.

Specified by:
messageSent in interface IoFilter
Overrides:
messageSent in class IoFilterAdapter
Throws:
Exception

filterSetTrafficMask

public void filterSetTrafficMask(IoFilter.NextFilter nextFilter,
                                 IoSession session,
                                 TrafficMask trafficMask)
                          throws Exception
Description copied from interface: IoFilter
Filters IoSession.setTrafficMask(TrafficMask) method invocation.

Specified by:
filterSetTrafficMask in interface IoFilter
Overrides:
filterSetTrafficMask in class IoFilterAdapter
Throws:
Exception


Copyright © 2004-2009 Apache MINA Project. All Rights Reserved.