Search in sources :

Example 16 with TaskMigratedException

use of org.apache.kafka.streams.errors.TaskMigratedException in project apache-kafka-on-k8s by banzaicloud.

the class AssignedStreamsTasksTest method shouldCloseTaskOnCommitIfTaskMigratedException.

@Test
public void shouldCloseTaskOnCommitIfTaskMigratedException() {
    mockTaskInitialization();
    t1.commit();
    EasyMock.expectLastCall().andThrow(new TaskMigratedException(t1));
    t1.close(false, true);
    EasyMock.expectLastCall();
    EasyMock.replay(t1);
    addAndInitTask();
    try {
        assignedTasks.commit();
        fail("Should have thrown TaskMigratedException.");
    } catch (final TaskMigratedException expected) {
    /* ignore */
    }
    assertThat(assignedTasks.runningTaskIds(), equalTo(Collections.EMPTY_SET));
    EasyMock.verify(t1);
}
Also used : TaskMigratedException(org.apache.kafka.streams.errors.TaskMigratedException) Test(org.junit.Test)

Aggregations

TaskMigratedException (org.apache.kafka.streams.errors.TaskMigratedException)16 Test (org.junit.Test)9 TopicPartition (org.apache.kafka.common.TopicPartition)6 HashMap (java.util.HashMap)4 ProducerFencedException (org.apache.kafka.common.errors.ProducerFencedException)4 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 Set (java.util.Set)3 StreamsException (org.apache.kafka.streams.errors.StreamsException)3 Map (java.util.Map)2 MockConsumer (org.apache.kafka.clients.consumer.MockConsumer)2 StreamsConfig (org.apache.kafka.streams.StreamsConfig)2 InternalStreamsBuilderTest (org.apache.kafka.streams.kstream.internals.InternalStreamsBuilderTest)2 TaskId (org.apache.kafka.streams.processor.TaskId)2 List (java.util.List)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 CommitFailedException (org.apache.kafka.clients.consumer.CommitFailedException)1 ConsumerRecord (org.apache.kafka.clients.consumer.ConsumerRecord)1 InvalidOffsetException (org.apache.kafka.clients.consumer.InvalidOffsetException)1 OffsetAndMetadata (org.apache.kafka.clients.consumer.OffsetAndMetadata)1