use of org.apache.kafka.common.errors.AuthorizationException in project kafka by apache.
the class AbstractTaskTest method shouldThrowProcessorStateExceptionOnInitializeOffsetsWhenAuthorizationException.
@Test(expected = ProcessorStateException.class)
public void shouldThrowProcessorStateExceptionOnInitializeOffsetsWhenAuthorizationException() throws Exception {
final Consumer consumer = mockConsumer(new AuthorizationException("blah"));
final AbstractTask task = createTask(consumer);
task.initializeOffsetLimits();
}
use of org.apache.kafka.common.errors.AuthorizationException in project kafka by apache.
the class AbstractTask method initializeOffsetLimits.
protected void initializeOffsetLimits() {
for (TopicPartition partition : partitions) {
try {
// TODO: batch API?
OffsetAndMetadata metadata = consumer.committed(partition);
stateMgr.putOffsetLimit(partition, metadata != null ? metadata.offset() : 0L);
} catch (AuthorizationException e) {
throw new ProcessorStateException(String.format("task [%s] AuthorizationException when initializing offsets for %s", id, partition), e);
} catch (WakeupException e) {
throw e;
} catch (KafkaException e) {
throw new ProcessorStateException(String.format("task [%s] Failed to initialize offsets for %s", id, partition), e);
}
}
}
Aggregations