Search in sources :

Example 1 with EarliestDeadlineFunction

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;
    });
}
Also used : EarliestDeadlineFunction(org.apache.kafka.queue.EventQueue.EarliestDeadlineFunction) UnknownServerException(org.apache.kafka.common.errors.UnknownServerException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) NotControllerException(org.apache.kafka.common.errors.NotControllerException)

Aggregations

RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1 NotControllerException (org.apache.kafka.common.errors.NotControllerException)1 UnknownServerException (org.apache.kafka.common.errors.UnknownServerException)1 EarliestDeadlineFunction (org.apache.kafka.queue.EventQueue.EarliestDeadlineFunction)1