Search in sources :

Example 11 with ListOffsetsTopic

use of org.apache.kafka.common.message.ListOffsetsRequestData.ListOffsetsTopic in project kafka by apache.

the class FetcherTest method listOffsetMatchesExpectedReset.

private boolean listOffsetMatchesExpectedReset(TopicPartition tp, OffsetResetStrategy strategy, AbstractRequest request) {
    assertTrue(request instanceof ListOffsetsRequest);
    ListOffsetsRequest req = (ListOffsetsRequest) request;
    assertEquals(singleton(tp.topic()), req.data().topics().stream().map(ListOffsetsTopic::name).collect(Collectors.toSet()));
    ListOffsetsTopic listTopic = req.data().topics().get(0);
    assertEquals(singleton(tp.partition()), listTopic.partitions().stream().map(ListOffsetsPartition::partitionIndex).collect(Collectors.toSet()));
    ListOffsetsPartition listPartition = listTopic.partitions().get(0);
    if (strategy == OffsetResetStrategy.EARLIEST) {
        assertEquals(ListOffsetsRequest.EARLIEST_TIMESTAMP, listPartition.timestamp());
    } else if (strategy == OffsetResetStrategy.LATEST) {
        assertEquals(ListOffsetsRequest.LATEST_TIMESTAMP, listPartition.timestamp());
    }
    return true;
}
Also used : ListOffsetsPartition(org.apache.kafka.common.message.ListOffsetsRequestData.ListOffsetsPartition) ListOffsetsTopic(org.apache.kafka.common.message.ListOffsetsRequestData.ListOffsetsTopic) ListOffsetsRequest(org.apache.kafka.common.requests.ListOffsetsRequest)

Aggregations

ListOffsetsPartition (org.apache.kafka.common.message.ListOffsetsRequestData.ListOffsetsPartition)11 ListOffsetsTopic (org.apache.kafka.common.message.ListOffsetsRequestData.ListOffsetsTopic)11 Test (org.junit.jupiter.api.Test)6 TopicPartition (org.apache.kafka.common.TopicPartition)5 ListOffsetsPartitionResponse (org.apache.kafka.common.message.ListOffsetsResponseData.ListOffsetsPartitionResponse)5 ListOffsetsTopicResponse (org.apache.kafka.common.message.ListOffsetsResponseData.ListOffsetsTopicResponse)5 ListOffsetsResponseData (org.apache.kafka.common.message.ListOffsetsResponseData)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Map (java.util.Map)2 ListOffsetsRequest (org.apache.kafka.common.requests.ListOffsetsRequest)2 InetSocketAddress (java.net.InetSocketAddress)1 InvalidKeyException (java.security.InvalidKeyException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 Duration (java.time.Duration)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 HashSet (java.util.HashSet)1