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);
}
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();
}
Aggregations