use of org.apache.kafka.common.message.ProduceResponseData in project kafka by apache.
the class ProduceResponse method toData.
private static ProduceResponseData toData(Map<TopicPartition, PartitionResponse> responses, int throttleTimeMs) {
ProduceResponseData data = new ProduceResponseData().setThrottleTimeMs(throttleTimeMs);
responses.forEach((tp, response) -> {
ProduceResponseData.TopicProduceResponse tpr = data.responses().find(tp.topic());
if (tpr == null) {
tpr = new ProduceResponseData.TopicProduceResponse().setName(tp.topic());
data.responses().add(tpr);
}
tpr.partitionResponses().add(new ProduceResponseData.PartitionProduceResponse().setIndex(tp.partition()).setBaseOffset(response.baseOffset).setLogStartOffset(response.logStartOffset).setLogAppendTimeMs(response.logAppendTime).setErrorMessage(response.errorMessage).setErrorCode(response.error.code()).setRecordErrors(response.recordErrors.stream().map(e -> new ProduceResponseData.BatchIndexAndErrorMessage().setBatchIndex(e.batchIndex).setBatchIndexErrorMessage(e.message)).collect(Collectors.toList())));
});
return data;
}
Aggregations