Class IoEventQueueThrottle
java.lang.Object
org.apache.mina.filter.executor.IoEventQueueThrottle
- All Implemented Interfaces:
EventListener, IoEventQueueHandler
Throttles incoming or outgoing events.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AtomicIntegerThe number of events we holdprivate final IoEventSizeEstimatorThe event size estimator instanceprivate final Objectprivate static final org.slf4j.LoggerA logger for this classprivate intprivate intFields inherited from interface IoEventQueueHandler
NOOP -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new IoEventQueueThrottle instanceIoEventQueueThrottle(int threshold) Creates a new IoEventQueueThrottle instanceIoEventQueueThrottle(IoEventSizeEstimator eventSizeEstimator, int threshold) Creates a new IoEventQueueThrottle instance -
Method Summary
Modifier and TypeMethodDescriptionbooleanprotected voidblock()private intestimateSize(IoEvent event) intintprivate voidlogState()voidInvoked after the specifiedeventhas been offered to the event queue.voidInvoked after the specifiedeventhas been polled from the event queue.voidsetThreshold(int threshold) Sets the events thresholdprotected voidunblock()
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGERA logger for this class -
eventSizeEstimator
The event size estimator instance -
threshold
private volatile int threshold -
lock
-
counter
The number of events we hold -
waiters
private int waiters
-
-
Constructor Details
-
IoEventQueueThrottle
public IoEventQueueThrottle()Creates a new IoEventQueueThrottle instance -
IoEventQueueThrottle
public IoEventQueueThrottle(int threshold) Creates a new IoEventQueueThrottle instance- Parameters:
threshold- The events threshold
-
IoEventQueueThrottle
Creates a new IoEventQueueThrottle instance- Parameters:
eventSizeEstimator- The IoEventSizeEstimator instancethreshold- The events threshold
-
-
Method Details
-
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
- 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
Invoked after the specifiedeventhas been offered to the event queue.- Specified by:
offeredin interfaceIoEventQueueHandler- Parameters:
source- The source of eventevent- The received event
-
polled
Invoked after the specifiedeventhas been polled from the event queue.- Specified by:
polledin interfaceIoEventQueueHandler- Parameters:
source- The source of eventevent- The received event
-
estimateSize
-
logState
private void logState() -
block
protected void block() -
unblock
protected void unblock()
-