use of org.apache.kafka.common.message.DescribeProducersResponseData.TopicResponse in project kafka by apache.
the class DescribeProducersRequest method getErrorResponse.
@Override
public DescribeProducersResponse getErrorResponse(int throttleTimeMs, Throwable e) {
Errors error = Errors.forException(e);
DescribeProducersResponseData response = new DescribeProducersResponseData();
for (TopicRequest topicRequest : data.topics()) {
TopicResponse topicResponse = new TopicResponse().setName(topicRequest.name());
for (int partitionId : topicRequest.partitionIndexes()) {
topicResponse.partitions().add(new PartitionResponse().setPartitionIndex(partitionId).setErrorCode(error.code()));
}
response.topics().add(topicResponse);
}
return new DescribeProducersResponse(response);
}
use of org.apache.kafka.common.message.DescribeProducersResponseData.TopicResponse in project kafka by apache.
the class DescribeProducersHandlerTest method describeProducersResponse.
private DescribeProducersResponse describeProducersResponse(Map<TopicPartition, PartitionResponse> partitionResponses) {
DescribeProducersResponseData response = new DescribeProducersResponseData();
Map<String, Map<Integer, PartitionResponse>> partitionResponsesByTopic = CollectionUtils.groupPartitionDataByTopic(partitionResponses);
for (Map.Entry<String, Map<Integer, PartitionResponse>> topicEntry : partitionResponsesByTopic.entrySet()) {
String topic = topicEntry.getKey();
Map<Integer, PartitionResponse> topicPartitionResponses = topicEntry.getValue();
TopicResponse topicResponse = new TopicResponse().setName(topic);
response.topics().add(topicResponse);
for (Map.Entry<Integer, PartitionResponse> partitionEntry : topicPartitionResponses.entrySet()) {
Integer partitionId = partitionEntry.getKey();
PartitionResponse partitionResponse = partitionEntry.getValue();
topicResponse.partitions().add(partitionResponse.setPartitionIndex(partitionId));
}
}
return new DescribeProducersResponse(response);
}
Aggregations