Package org.apache.mina.filter.executor
Class IoEventQueueThrottle
- java.lang.Object
-
- org.apache.mina.filter.executor.IoEventQueueThrottle
-
- All Implemented Interfaces:
java.util.EventListener,IoEventQueueHandler
public class IoEventQueueThrottle extends java.lang.Object implements IoEventQueueHandler
Throttles incoming or outgoing events.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.atomic.AtomicIntegercounterThe number of events we holdprivate IoEventSizeEstimatoreventSizeEstimatorThe event size estimator instanceprivate java.lang.Objectlockprivate static org.slf4j.LoggerLOGGERA logger for this classprivate intthresholdprivate intwaiters-
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 booleanaccept(java.lang.Object source, IoEvent event)protected voidblock()private intestimateSize(IoEvent event)intgetCounter()IoEventSizeEstimatorgetEventSizeEstimator()intgetThreshold()private voidlogState()voidoffered(java.lang.Object source, IoEvent event)Invoked after the specifiedeventhas been offered to the event queue.voidpolled(java.lang.Object source, IoEvent event)Invoked after the specifiedeventhas been polled from the event queue.voidsetThreshold(int threshold)Sets the events thresholdprotected voidunblock()
-
-
-
Field Detail
-
LOGGER
private static final org.slf4j.Logger LOGGER
A logger for this class
-
eventSizeEstimator
private final IoEventSizeEstimator eventSizeEstimator
The event size estimator instance
-
threshold
private volatile int threshold
-
lock
private final java.lang.Object lock
-
counter
private final java.util.concurrent.atomic.AtomicInteger counter
The number of events we hold
-
waiters
private int waiters
-
-
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(java.lang.Object source, IoEvent event)- Specified by:
acceptin interfaceIoEventQueueHandler- Parameters:
source- The source of eventevent- The received event- Returns:
trueif and only if the specified>eventis allowed to be offered to the event queue. Theeventis dropped iffalseis returned.
-
offered
public void offered(java.lang.Object source, IoEvent event)Invoked after the specifiedeventhas been offered to the event queue.- Specified by:
offeredin interfaceIoEventQueueHandler- Parameters:
source- The source of eventevent- The received event
-
polled
public void polled(java.lang.Object source, IoEvent event)Invoked after the specifiedeventhas been polled from the event queue.- Specified by:
polledin interfaceIoEventQueueHandler- Parameters:
source- The source of eventevent- The received event
-
estimateSize
private int estimateSize(IoEvent event)
-
logState
private void logState()
-
block
protected void block()
-
unblock
protected void unblock()
-
-