Search in sources :

Example 1 with MetadataRequestTopic

use of org.apache.kafka.common.message.MetadataRequestData.MetadataRequestTopic in project kafka by apache.

the class MetadataRequest method getErrorResponse.

@Override
public AbstractResponse getErrorResponse(int throttleTimeMs, Throwable e) {
    Errors error = Errors.forException(e);
    MetadataResponseData responseData = new MetadataResponseData();
    if (data.topics() != null) {
        for (MetadataRequestTopic topic : data.topics()) {
            // the response does not allow null, so convert to empty string if necessary
            String topicName = topic.name() == null ? "" : topic.name();
            responseData.topics().add(new MetadataResponseData.MetadataResponseTopic().setName(topicName).setTopicId(topic.topicId()).setErrorCode(error.code()).setIsInternal(false).setPartitions(Collections.emptyList()));
        }
    }
    responseData.setThrottleTimeMs(throttleTimeMs);
    return new MetadataResponse(responseData, true);
}
Also used : Errors(org.apache.kafka.common.protocol.Errors) MetadataRequestTopic(org.apache.kafka.common.message.MetadataRequestData.MetadataRequestTopic) MetadataResponseData(org.apache.kafka.common.message.MetadataResponseData)

Aggregations

MetadataRequestTopic (org.apache.kafka.common.message.MetadataRequestData.MetadataRequestTopic)1 MetadataResponseData (org.apache.kafka.common.message.MetadataResponseData)1 Errors (org.apache.kafka.common.protocol.Errors)1