Search in sources :

Example 6 with OffsetFetchResponseGroup

use of org.apache.kafka.common.message.OffsetFetchResponseData.OffsetFetchResponseGroup in project kafka by apache.

the class MessageTest method testOffsetFetchV8AndAboveSingleGroup.

@Test
public void testOffsetFetchV8AndAboveSingleGroup() throws Exception {
    String groupId = "groupId";
    String topicName = "topic";
    List<OffsetFetchRequestTopics> topic = Collections.singletonList(new OffsetFetchRequestTopics().setName(topicName).setPartitionIndexes(Collections.singletonList(5)));
    OffsetFetchRequestData allPartitionData = new OffsetFetchRequestData().setGroups(Collections.singletonList(new OffsetFetchRequestGroup().setGroupId(groupId).setTopics(null)));
    OffsetFetchRequestData specifiedPartitionData = new OffsetFetchRequestData().setGroups(Collections.singletonList(new OffsetFetchRequestGroup().setGroupId(groupId).setTopics(topic))).setRequireStable(true);
    testAllMessageRoundTripsOffsetFetchV8AndAbove(allPartitionData);
    testAllMessageRoundTripsOffsetFetchV8AndAbove(specifiedPartitionData);
    for (short version : ApiKeys.OFFSET_FETCH.allVersions()) {
        if (version >= 8) {
            testAllMessageRoundTripsOffsetFetchFromVersionV8AndAbove(version, specifiedPartitionData);
            testAllMessageRoundTripsOffsetFetchFromVersionV8AndAbove(version, allPartitionData);
        }
    }
    Supplier<OffsetFetchResponseData> response = () -> new OffsetFetchResponseData().setGroups(Collections.singletonList(new OffsetFetchResponseGroup().setGroupId(groupId).setTopics(Collections.singletonList(new OffsetFetchResponseTopics().setPartitions(Collections.singletonList(new OffsetFetchResponsePartitions().setPartitionIndex(5).setMetadata(null).setCommittedOffset(100).setCommittedLeaderEpoch(3).setErrorCode(Errors.UNKNOWN_TOPIC_OR_PARTITION.code()))))).setErrorCode(Errors.NOT_COORDINATOR.code()))).setThrottleTimeMs(10);
    for (short version : ApiKeys.OFFSET_FETCH.allVersions()) {
        if (version >= 8) {
            OffsetFetchResponseData responseData = response.get();
            testAllMessageRoundTripsOffsetFetchFromVersionV8AndAbove(version, responseData);
        }
    }
}
Also used : OffsetFetchResponseTopics(org.apache.kafka.common.message.OffsetFetchResponseData.OffsetFetchResponseTopics) OffsetFetchRequestGroup(org.apache.kafka.common.message.OffsetFetchRequestData.OffsetFetchRequestGroup) OffsetFetchResponseGroup(org.apache.kafka.common.message.OffsetFetchResponseData.OffsetFetchResponseGroup) OffsetFetchRequestTopics(org.apache.kafka.common.message.OffsetFetchRequestData.OffsetFetchRequestTopics) OffsetFetchResponsePartitions(org.apache.kafka.common.message.OffsetFetchResponseData.OffsetFetchResponsePartitions) Test(org.junit.jupiter.api.Test)

Aggregations

OffsetFetchResponseGroup (org.apache.kafka.common.message.OffsetFetchResponseData.OffsetFetchResponseGroup)6 OffsetFetchResponsePartitions (org.apache.kafka.common.message.OffsetFetchResponseData.OffsetFetchResponsePartitions)6 OffsetFetchResponseTopics (org.apache.kafka.common.message.OffsetFetchResponseData.OffsetFetchResponseTopics)6 TopicPartition (org.apache.kafka.common.TopicPartition)4 Test (org.junit.jupiter.api.Test)4 OffsetFetchResponseData (org.apache.kafka.common.message.OffsetFetchResponseData)3 HashMap (java.util.HashMap)2 OffsetFetchRequestGroup (org.apache.kafka.common.message.OffsetFetchRequestData.OffsetFetchRequestGroup)2 OffsetFetchRequestTopics (org.apache.kafka.common.message.OffsetFetchRequestData.OffsetFetchRequestTopics)2 PartitionData (org.apache.kafka.common.requests.OffsetFetchResponse.PartitionData)2 ByteBuffer (java.nio.ByteBuffer)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 OffsetFetchResponsePartition (org.apache.kafka.common.message.OffsetFetchResponseData.OffsetFetchResponsePartition)1