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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
append, appendWithDeadline, isEmpty, prepend, scheduleDeferred
public 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)
EventQueue
enqueue
in interface EventQueue
insertionType
- 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)
EventQueue
cancelDeferred
in interface EventQueue
tag
- 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)
EventQueue
beginShutdown
in interface EventQueue
source
- The source of the shutdown.public int size()
size
in interface EventQueue
public void wakeup()
EventQueue
wakeup
in interface EventQueue
public void close() throws InterruptedException
EventQueue
close
in interface AutoCloseable
close
in interface EventQueue
InterruptedException