Search in sources :

Example 1 with DescribeQuorumResponseData

use of org.apache.kafka.common.message.DescribeQuorumResponseData in project kafka by apache.

the class DescribeQuorumRequest method getPartitionLevelErrorResponse.

public static DescribeQuorumResponseData getPartitionLevelErrorResponse(DescribeQuorumRequestData data, Errors error) {
    short errorCode = error.code();
    List<DescribeQuorumResponseData.TopicData> topicResponses = new ArrayList<>();
    for (DescribeQuorumRequestData.TopicData topic : data.topics()) {
        topicResponses.add(new DescribeQuorumResponseData.TopicData().setTopicName(topic.topicName()).setPartitions(topic.partitions().stream().map(requestPartition -> new DescribeQuorumResponseData.PartitionData().setPartitionIndex(requestPartition.partitionIndex()).setErrorCode(errorCode)).collect(Collectors.toList())));
    }
    return new DescribeQuorumResponseData().setTopics(topicResponses);
}
Also used : TopicPartition(org.apache.kafka.common.TopicPartition) List(java.util.List) ByteBufferAccessor(org.apache.kafka.common.protocol.ByteBufferAccessor) DescribeQuorumResponseData(org.apache.kafka.common.message.DescribeQuorumResponseData) Errors(org.apache.kafka.common.protocol.Errors) DescribeQuorumRequestData(org.apache.kafka.common.message.DescribeQuorumRequestData) ApiKeys(org.apache.kafka.common.protocol.ApiKeys) Collections(java.util.Collections) Collectors(java.util.stream.Collectors) ByteBuffer(java.nio.ByteBuffer) ArrayList(java.util.ArrayList) DescribeQuorumRequestData(org.apache.kafka.common.message.DescribeQuorumRequestData) DescribeQuorumResponseData(org.apache.kafka.common.message.DescribeQuorumResponseData) ArrayList(java.util.ArrayList)

Example 2 with DescribeQuorumResponseData

use of org.apache.kafka.common.message.DescribeQuorumResponseData in project kafka by apache.

the class RaftClientTestContext method assertSentDescribeQuorumResponse.

int assertSentDescribeQuorumResponse(int leaderId, int leaderEpoch, long highWatermark, List<ReplicaState> voterStates, List<ReplicaState> observerStates) {
    List<RaftResponse.Outbound> sentMessages = drainSentResponses(ApiKeys.DESCRIBE_QUORUM);
    assertEquals(1, sentMessages.size());
    RaftResponse.Outbound raftMessage = sentMessages.get(0);
    assertTrue(raftMessage.data() instanceof DescribeQuorumResponseData, "Unexpected request type " + raftMessage.data());
    DescribeQuorumResponseData response = (DescribeQuorumResponseData) raftMessage.data();
    DescribeQuorumResponseData expectedResponse = DescribeQuorumResponse.singletonResponse(metadataPartition, leaderId, leaderEpoch, highWatermark, voterStates, observerStates);
    assertEquals(expectedResponse, response);
    return raftMessage.correlationId();
}
Also used : DescribeQuorumResponseData(org.apache.kafka.common.message.DescribeQuorumResponseData)

Aggregations

DescribeQuorumResponseData (org.apache.kafka.common.message.DescribeQuorumResponseData)2 ByteBuffer (java.nio.ByteBuffer)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 TopicPartition (org.apache.kafka.common.TopicPartition)1 DescribeQuorumRequestData (org.apache.kafka.common.message.DescribeQuorumRequestData)1 ApiKeys (org.apache.kafka.common.protocol.ApiKeys)1 ByteBufferAccessor (org.apache.kafka.common.protocol.ByteBufferAccessor)1 Errors (org.apache.kafka.common.protocol.Errors)1