public final class KafkaEventQueue extends Object implements EventQueue
EventQueue.DeadlineFunction, EventQueue.EarliestDeadlineFunction, EventQueue.Event, EventQueue.EventInsertionType, EventQueue.FailureLoggingEvent, EventQueue.NoDeadlineFunction, EventQueue.VoidEvent| Constructor and Description |
|---|
KafkaEventQueue(org.apache.kafka.common.utils.Time time,
org.apache.kafka.common.utils.LogContext logContext,
String threadNamePrefix) |
KafkaEventQueue(org.apache.kafka.common.utils.Time time,
org.apache.kafka.common.utils.LogContext logContext,
String threadNamePrefix,
EventQueue.Event cleanupEvent) |
| Modifier and Type | Method and Description |
|---|---|
void |
beginShutdown(String source)
Asynchronously shut down the event queue.
|
void |
cancelDeferred(String tag)
Cancel a deferred event.
|
void |
close()
Synchronously close the event queue and wait for any threads to be joined.
|
void |
enqueue(EventQueue.EventInsertionType insertionType,
String tag,
Function<OptionalLong,OptionalLong> deadlineNsCalculator,
EventQueue.Event event)
Add an event to the queue.
|
int |
size() |
org.apache.kafka.common.utils.Time |
time() |
void |
wakeup()
This method is used during unit tests where MockTime is in use.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitappend, appendWithDeadline, isEmpty, prepend, scheduleDeferredpublic KafkaEventQueue(org.apache.kafka.common.utils.Time time,
org.apache.kafka.common.utils.LogContext logContext,
String threadNamePrefix)
public KafkaEventQueue(org.apache.kafka.common.utils.Time time,
org.apache.kafka.common.utils.LogContext logContext,
String threadNamePrefix,
EventQueue.Event cleanupEvent)
public org.apache.kafka.common.utils.Time time()
public void enqueue(EventQueue.EventInsertionType insertionType, String tag, Function<OptionalLong,OptionalLong> deadlineNsCalculator, EventQueue.Event event)
EventQueueenqueue in interface EventQueueinsertionType - How to insert the event.
PREPEND means insert the event as the first thing
to run. APPEND means insert the event as the last
thing to run. DEFERRED means insert the event to
run after a delay.tag - If this is non-null, the unique tag to use for
this event. If an event with this tag already
exists, it will be cancelled.deadlineNsCalculator - If this is non-null, it is a function which takes
as an argument the existing deadline for the
event with this tag (or null if the event has no
tag, or if there is none such), and produces the
deadline to use for this event (or empty to use
none.) Events whose deadlines are only a few
nanoseconds apart may be executed in any order.event - The event to enqueue.public void cancelDeferred(String tag)
EventQueuecancelDeferred in interface EventQueuetag - The unique tag for the event to be cancelled. Must be
non-null. If the event with the tag has not been
scheduled, this call will be ignored.public void beginShutdown(String source)
EventQueuebeginShutdown in interface EventQueuesource - The source of the shutdown.public int size()
size in interface EventQueuepublic void wakeup()
EventQueuewakeup in interface EventQueuepublic void close()
throws InterruptedException
EventQueueclose in interface AutoCloseableclose in interface EventQueueInterruptedException