use of org.apache.kafka.common.errors.NotControllerException 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;
});
}
use of org.apache.kafka.common.errors.NotControllerException in project ksql by confluentinc.
the class KafkaTopicClientImplTest method listTopicResultWithNotControllerException.
@SuppressWarnings("unchecked")
private ListTopicsResult listTopicResultWithNotControllerException() {
ListTopicsResult listTopicsResult = mock(ListTopicsResult.class);
expect(listTopicsResult.names()).andReturn(failedFuture(new NotControllerException("Not Controller")));
replay(listTopicsResult);
return listTopicsResult;
}
use of org.apache.kafka.common.errors.NotControllerException in project kafka by apache.
the class ApiErrorTest method parameters.
private static Collection<Arguments> parameters() {
List<Arguments> arguments = new ArrayList<>();
arguments.add(Arguments.of(new UnknownServerException("Don't leak sensitive information "), Errors.UNKNOWN_SERVER_ERROR, null));
arguments.add(Arguments.of(new NotEnoughReplicasException(), Errors.NOT_ENOUGH_REPLICAS, null));
// avoid populating the error message if it's a generic one
arguments.add(Arguments.of(new UnknownTopicOrPartitionException(Errors.UNKNOWN_TOPIC_OR_PARTITION.message()), Errors.UNKNOWN_TOPIC_OR_PARTITION, null));
String notCoordinatorErrorMsg = "Not coordinator";
arguments.add(Arguments.of(new NotCoordinatorException(notCoordinatorErrorMsg), Errors.NOT_COORDINATOR, notCoordinatorErrorMsg));
String notControllerErrorMsg = "Not controller";
// test the NotControllerException is wrapped in the CompletionException, should return correct error
arguments.add(Arguments.of(new CompletionException(new NotControllerException(notControllerErrorMsg)), Errors.NOT_CONTROLLER, notControllerErrorMsg));
String requestTimeoutErrorMsg = "request time out";
// test the TimeoutException is wrapped in the ExecutionException, should return correct error
arguments.add(Arguments.of(new ExecutionException(new TimeoutException(requestTimeoutErrorMsg)), Errors.REQUEST_TIMED_OUT, requestTimeoutErrorMsg));
// test the exception not in the Errors list, should return UNKNOWN_SERVER_ERROR
arguments.add(Arguments.of(new IOException(), Errors.UNKNOWN_SERVER_ERROR, null));
return arguments;
}
Aggregations