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);
}
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));
}
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));
}
Aggregations