use of org.apache.kafka.queue.EventQueue.EarliestDeadlineFunction in project kafka by apache.
the class QuorumController method scheduleDeferredWriteEvent.
private <T> void scheduleDeferredWriteEvent(String name, long deadlineNs, ControllerWriteOperation<T> op) {
ControllerWriteEvent<T> event = new ControllerWriteEvent<>(name, op);
queue.scheduleDeferred(name, new EarliestDeadlineFunction(deadlineNs), event);
event.future.exceptionally(e -> {
if (e instanceof UnknownServerException && e.getCause() != null && e.getCause() instanceof RejectedExecutionException) {
log.error("Cancelling deferred write event {} because the event queue " + "is now closed.", name);
return null;
} else if (e instanceof NotControllerException) {
log.debug("Cancelling deferred write event {} because this controller " + "is no longer active.", name);
return null;
}
log.error("Unexpected exception while executing deferred write event {}. " + "Rescheduling for a minute from now.", name, e);
scheduleDeferredWriteEvent(name, deadlineNs + NANOSECONDS.convert(1, TimeUnit.MINUTES), op);
return null;
});
}
Aggregations