Search in sources :

Example 1 with CreatePartitionsResponseData

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

the class RequestResponseTest method createCreatePartitionsResponse.

private CreatePartitionsResponse createCreatePartitionsResponse() {
    List<CreatePartitionsTopicResult> results = new LinkedList<>();
    results.add(new CreatePartitionsTopicResult().setName("my_topic").setErrorCode(Errors.INVALID_REPLICA_ASSIGNMENT.code()));
    results.add(new CreatePartitionsTopicResult().setName("my_topic").setErrorCode(Errors.NONE.code()));
    CreatePartitionsResponseData data = new CreatePartitionsResponseData().setThrottleTimeMs(42).setResults(results);
    return new CreatePartitionsResponse(data);
}
Also used : CreatePartitionsTopicResult(org.apache.kafka.common.message.CreatePartitionsResponseData.CreatePartitionsTopicResult) LinkedList(java.util.LinkedList) CreatePartitionsResponseData(org.apache.kafka.common.message.CreatePartitionsResponseData)

Example 2 with CreatePartitionsResponseData

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

the class CreatePartitionsRequest method getErrorResponse.

@Override
public AbstractResponse getErrorResponse(int throttleTimeMs, Throwable e) {
    CreatePartitionsResponseData response = new CreatePartitionsResponseData();
    response.setThrottleTimeMs(throttleTimeMs);
    ApiError apiError = ApiError.fromThrowable(e);
    for (CreatePartitionsTopic topic : data.topics()) {
        response.results().add(new CreatePartitionsTopicResult().setName(topic.name()).setErrorCode(apiError.error().code()).setErrorMessage(apiError.message()));
    }
    return new CreatePartitionsResponse(response);
}
Also used : CreatePartitionsTopic(org.apache.kafka.common.message.CreatePartitionsRequestData.CreatePartitionsTopic) CreatePartitionsTopicResult(org.apache.kafka.common.message.CreatePartitionsResponseData.CreatePartitionsTopicResult) CreatePartitionsResponseData(org.apache.kafka.common.message.CreatePartitionsResponseData)

Aggregations

CreatePartitionsResponseData (org.apache.kafka.common.message.CreatePartitionsResponseData)2 CreatePartitionsTopicResult (org.apache.kafka.common.message.CreatePartitionsResponseData.CreatePartitionsTopicResult)2 LinkedList (java.util.LinkedList)1 CreatePartitionsTopic (org.apache.kafka.common.message.CreatePartitionsRequestData.CreatePartitionsTopic)1