Package org.apache.mina.filter.executor
Class IoEventQueueThrottle
- java.lang.Object
-
- org.apache.mina.filter.executor.IoEventQueueThrottle
-
- All Implemented Interfaces:
EventListener
,IoEventQueueHandler
public class IoEventQueueThrottle extends Object implements IoEventQueueHandler
Throttles incoming or outgoing events.- Author:
- Apache MINA Project
-
-
Field Summary
-
Fields inherited from interface org.apache.mina.filter.executor.IoEventQueueHandler
NOOP
-
-
Constructor Summary
Constructors Constructor Description IoEventQueueThrottle()
Creates a new IoEventQueueThrottle instanceIoEventQueueThrottle(int threshold)
Creates a new IoEventQueueThrottle instanceIoEventQueueThrottle(IoEventSizeEstimator eventSizeEstimator, int threshold)
Creates a new IoEventQueueThrottle instance
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
accept(Object source, IoEvent event)
protected void
block()
int
getCounter()
IoEventSizeEstimator
getEventSizeEstimator()
int
getThreshold()
void
offered(Object source, IoEvent event)
Invoked after the specified event has been offered to the event queue.void
polled(Object source, IoEvent event)
Invoked after the specified event has been polled from the event queue.void
setThreshold(int threshold)
Sets the events thresholdprotected void
unblock()
-
-
-
Constructor Detail
-
IoEventQueueThrottle
public IoEventQueueThrottle()
Creates a new IoEventQueueThrottle instance
-
IoEventQueueThrottle
public IoEventQueueThrottle(int threshold)
Creates a new IoEventQueueThrottle instance- Parameters:
threshold
- The events threshold
-
IoEventQueueThrottle
public IoEventQueueThrottle(IoEventSizeEstimator eventSizeEstimator, int threshold)
Creates a new IoEventQueueThrottle instance- Parameters:
eventSizeEstimator
- The IoEventSizeEstimator instancethreshold
- The events threshold
-
-
Method Detail
-
getEventSizeEstimator
public IoEventSizeEstimator getEventSizeEstimator()
- Returns:
- The IoEventSizeEstimator instance
-
getThreshold
public int getThreshold()
- Returns:
- The events threshold
-
getCounter
public int getCounter()
- Returns:
- The number of events currently held
-
setThreshold
public void setThreshold(int threshold)
Sets the events threshold- Parameters:
threshold
- The events threshold
-
accept
public boolean accept(Object source, IoEvent event)
- Specified by:
accept
in interfaceIoEventQueueHandler
- Parameters:
source
- The source of eventevent
- The received event- Returns:
- true if and only if the specified event is allowed to be offered to the event queue. The event is dropped if false is returned.
-
offered
public void offered(Object source, IoEvent event)
Invoked after the specified event has been offered to the event queue.- Specified by:
offered
in interfaceIoEventQueueHandler
- Parameters:
source
- The source of eventevent
- The received event
-
polled
public void polled(Object source, IoEvent event)
Invoked after the specified event has been polled from the event queue.- Specified by:
polled
in interfaceIoEventQueueHandler
- Parameters:
source
- The source of eventevent
- The received event
-
block
protected void block()
-
unblock
protected void unblock()
-
-