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
AIoFilter
which 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 boolean
isConnectionOk(IoSession session)
Method responsible for deciding if a connection is OK to continuevoid
sessionCreated(IoFilter.NextFilter nextFilter, IoSession session)
FiltersIoHandler.sessionCreated(IoSession)
event.void
setAllowedInterval(long allowedInterval)
Sets the interval between connections from a client.-
Methods inherited from class org.apache.mina.core.filterchain.IoFilterAdapter
destroy, 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:IoFilterAdapter
FiltersIoHandler.sessionCreated(IoSession)
event.- Specified by:
sessionCreated
in interfaceIoFilter
- Overrides:
sessionCreated
in classIoFilterAdapter
- Parameters:
nextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.session
- TheIoSession
which has received this event- Throws:
Exception
- If an error occurred while processing the event
-
-