Search in sources :

Example 1 with AlterReplicaLogDirsResponseData

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

the class RequestResponseTest method createAlterReplicaLogDirsResponse.

private AlterReplicaLogDirsResponse createAlterReplicaLogDirsResponse() {
    AlterReplicaLogDirsResponseData data = new AlterReplicaLogDirsResponseData();
    data.results().add(new AlterReplicaLogDirsResponseData.AlterReplicaLogDirTopicResult().setTopicName("topic").setPartitions(singletonList(new AlterReplicaLogDirsResponseData.AlterReplicaLogDirPartitionResult().setPartitionIndex(0).setErrorCode(Errors.NONE.code()))));
    return new AlterReplicaLogDirsResponse(data);
}
Also used : AlterReplicaLogDirsResponseData(org.apache.kafka.common.message.AlterReplicaLogDirsResponseData)

Example 2 with AlterReplicaLogDirsResponseData

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

the class AlterReplicaLogDirsResponseTest method testErrorCounts.

@Test
public void testErrorCounts() {
    AlterReplicaLogDirsResponseData data = new AlterReplicaLogDirsResponseData().setResults(asList(new AlterReplicaLogDirTopicResult().setTopicName("t0").setPartitions(asList(new AlterReplicaLogDirPartitionResult().setPartitionIndex(0).setErrorCode(Errors.LOG_DIR_NOT_FOUND.code()), new AlterReplicaLogDirPartitionResult().setPartitionIndex(1).setErrorCode(Errors.NONE.code()))), new AlterReplicaLogDirTopicResult().setTopicName("t1").setPartitions(asList(new AlterReplicaLogDirPartitionResult().setPartitionIndex(0).setErrorCode(Errors.LOG_DIR_NOT_FOUND.code())))));
    Map<Errors, Integer> counts = new AlterReplicaLogDirsResponse(data).errorCounts();
    assertEquals(2, counts.size());
    assertEquals(Integer.valueOf(2), counts.get(Errors.LOG_DIR_NOT_FOUND));
    assertEquals(Integer.valueOf(1), counts.get(Errors.NONE));
}
Also used : Errors(org.apache.kafka.common.protocol.Errors) AlterReplicaLogDirsResponseData(org.apache.kafka.common.message.AlterReplicaLogDirsResponseData) AlterReplicaLogDirTopicResult(org.apache.kafka.common.message.AlterReplicaLogDirsResponseData.AlterReplicaLogDirTopicResult) AlterReplicaLogDirPartitionResult(org.apache.kafka.common.message.AlterReplicaLogDirsResponseData.AlterReplicaLogDirPartitionResult) Test(org.junit.jupiter.api.Test)

Example 3 with AlterReplicaLogDirsResponseData

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

the class AlterReplicaLogDirsRequest method getErrorResponse.

public AlterReplicaLogDirsResponse getErrorResponse(int throttleTimeMs, Throwable e) {
    AlterReplicaLogDirsResponseData data = new AlterReplicaLogDirsResponseData();
    data.setResults(this.data.dirs().stream().flatMap(alterDir -> alterDir.topics().stream().map(topic -> new AlterReplicaLogDirTopicResult().setTopicName(topic.name()).setPartitions(topic.partitions().stream().map(partitionId -> new AlterReplicaLogDirsResponseData.AlterReplicaLogDirPartitionResult().setErrorCode(Errors.forException(e).code()).setPartitionIndex(partitionId)).collect(Collectors.toList())))).collect(Collectors.toList()));
    return new AlterReplicaLogDirsResponse(data.setThrottleTimeMs(throttleTimeMs));
}
Also used : TopicPartition(org.apache.kafka.common.TopicPartition) AlterReplicaLogDirTopicResult(org.apache.kafka.common.message.AlterReplicaLogDirsResponseData.AlterReplicaLogDirTopicResult) Map(java.util.Map) ByteBufferAccessor(org.apache.kafka.common.protocol.ByteBufferAccessor) Errors(org.apache.kafka.common.protocol.Errors) HashMap(java.util.HashMap) AlterReplicaLogDirsResponseData(org.apache.kafka.common.message.AlterReplicaLogDirsResponseData) AlterReplicaLogDirsRequestData(org.apache.kafka.common.message.AlterReplicaLogDirsRequestData) ApiKeys(org.apache.kafka.common.protocol.ApiKeys) Collectors(java.util.stream.Collectors) ByteBuffer(java.nio.ByteBuffer) AlterReplicaLogDirsResponseData(org.apache.kafka.common.message.AlterReplicaLogDirsResponseData) AlterReplicaLogDirTopicResult(org.apache.kafka.common.message.AlterReplicaLogDirsResponseData.AlterReplicaLogDirTopicResult)

Aggregations

AlterReplicaLogDirsResponseData (org.apache.kafka.common.message.AlterReplicaLogDirsResponseData)3 AlterReplicaLogDirTopicResult (org.apache.kafka.common.message.AlterReplicaLogDirsResponseData.AlterReplicaLogDirTopicResult)2 Errors (org.apache.kafka.common.protocol.Errors)2 ByteBuffer (java.nio.ByteBuffer)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 TopicPartition (org.apache.kafka.common.TopicPartition)1 AlterReplicaLogDirsRequestData (org.apache.kafka.common.message.AlterReplicaLogDirsRequestData)1 AlterReplicaLogDirPartitionResult (org.apache.kafka.common.message.AlterReplicaLogDirsResponseData.AlterReplicaLogDirPartitionResult)1 ApiKeys (org.apache.kafka.common.protocol.ApiKeys)1 ByteBufferAccessor (org.apache.kafka.common.protocol.ByteBufferAccessor)1 Test (org.junit.jupiter.api.Test)1