Search in sources :

Example 6 with InvalidOffsetException

use of org.apache.kafka.clients.consumer.InvalidOffsetException in project apache-kafka-on-k8s by banzaicloud.

the class GlobalStateManagerImplTest method shouldRecoverFromInvalidOffsetExceptionAndRestoreRecords.

@Test
public void shouldRecoverFromInvalidOffsetExceptionAndRestoreRecords() {
    initializeConsumer(2, 1, t1);
    consumer.setException(new InvalidOffsetException("Try Again!") {

        public Set<TopicPartition> partitions() {
            return Collections.singleton(t1);
        }
    });
    stateManager.initialize();
    stateManager.register(store1, stateRestoreCallback);
    assertEquals(2, stateRestoreCallback.restored.size());
}
Also used : Set(java.util.Set) InvalidOffsetException(org.apache.kafka.clients.consumer.InvalidOffsetException) Test(org.junit.Test)

Aggregations

InvalidOffsetException (org.apache.kafka.clients.consumer.InvalidOffsetException)6 Set (java.util.Set)5 Test (org.junit.Test)4 TopicPartition (org.apache.kafka.common.TopicPartition)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 TestCondition (org.apache.kafka.test.TestCondition)2 List (java.util.List)1 Map (java.util.Map)1 ConsumerRecord (org.apache.kafka.clients.consumer.ConsumerRecord)1 MockConsumer (org.apache.kafka.clients.consumer.MockConsumer)1 PartitionInfo (org.apache.kafka.common.PartitionInfo)1 Bytes (org.apache.kafka.common.utils.Bytes)1 KeyValue (org.apache.kafka.streams.KeyValue)1 StreamsException (org.apache.kafka.streams.errors.StreamsException)1 TaskMigratedException (org.apache.kafka.streams.errors.TaskMigratedException)1 InternalStreamsBuilderTest (org.apache.kafka.streams.kstream.internals.InternalStreamsBuilderTest)1 BatchingStateRestoreCallback (org.apache.kafka.streams.processor.BatchingStateRestoreCallback)1 TaskId (org.apache.kafka.streams.processor.TaskId)1