Package org.apache.mina.filter.firewall
Class ConnectionThrottleFilter
- java.lang.Object
-
- org.apache.mina.core.filterchain.IoFilterAdapter
-
- org.apache.mina.filter.firewall.ConnectionThrottleFilter
-
- All Implemented Interfaces:
IoFilter
public class ConnectionThrottleFilter extends IoFilterAdapter
AIoFilterwhich blocks connections from connecting at a rate faster than the specified interval.- Author:
- Apache MINA Project
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.mina.core.filterchain.IoFilter
IoFilter.NextFilter
-
-
Constructor Summary
Constructors Constructor Description ConnectionThrottleFilter()Default constructor.ConnectionThrottleFilter(long allowedInterval)Constructor that takes in a specified wait time.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanisConnectionOk(IoSession session)Method responsible for deciding if a connection is OK to continuevoidsessionCreated(IoFilter.NextFilter nextFilter, IoSession session)FiltersIoHandler.sessionCreated(IoSession)event.voidsetAllowedInterval(long allowedInterval)Sets the interval between connections from a client.-
Methods inherited from class org.apache.mina.core.filterchain.IoFilterAdapter
destroy, event, exceptionCaught, filterClose, filterWrite, init, inputClosed, messageReceived, messageSent, onPostAdd, onPostRemove, onPreAdd, onPreRemove, sessionClosed, sessionIdle, sessionOpened, toString
-
-
-
-
Constructor Detail
-
ConnectionThrottleFilter
public ConnectionThrottleFilter()
Default constructor. Sets the wait time to 1 second
-
ConnectionThrottleFilter
public ConnectionThrottleFilter(long allowedInterval)
Constructor that takes in a specified wait time.- Parameters:
allowedInterval- The number of milliseconds a client is allowed to wait before making another successful connection
-
-
Method Detail
-
setAllowedInterval
public void setAllowedInterval(long allowedInterval)
Sets the interval between connections from a client. This value is measured in milliseconds.- Parameters:
allowedInterval- The number of milliseconds a client is allowed to wait before making another successful connection
-
isConnectionOk
protected boolean isConnectionOk(IoSession session)
Method responsible for deciding if a connection is OK to continue- Parameters:
session- The new session that will be verified- Returns:
- True if the session meets the criteria, otherwise false
-
sessionCreated
public void sessionCreated(IoFilter.NextFilter nextFilter, IoSession session) throws Exception
Description copied from class:IoFilterAdapterFiltersIoHandler.sessionCreated(IoSession)event.- Specified by:
sessionCreatedin interfaceIoFilter- Overrides:
sessionCreatedin classIoFilterAdapter- Parameters:
nextFilter- theIoFilter.NextFilterfor this filter. You can reuse this object until this filter is removed from the chain.session- TheIoSessionwhich has received this event- Throws:
Exception- If an error occurred while processing the event
-
-