Search in sources :

Example 1 with AlterReplicaLogDirCollection

use of org.apache.kafka.common.message.AlterReplicaLogDirsRequestData.AlterReplicaLogDirCollection in project kafka by apache.

the class AlterReplicaLogDirsRequestTest method testErrorResponse.

@Test
public void testErrorResponse() {
    AlterReplicaLogDirsRequestData data = new AlterReplicaLogDirsRequestData().setDirs(new AlterReplicaLogDirCollection(singletonList(new AlterReplicaLogDir().setPath("/data0").setTopics(new AlterReplicaLogDirTopicCollection(singletonList(new AlterReplicaLogDirTopic().setName("topic").setPartitions(asList(0, 1, 2))).iterator()))).iterator()));
    AlterReplicaLogDirsResponse errorResponse = new AlterReplicaLogDirsRequest.Builder(data).build().getErrorResponse(123, new LogDirNotFoundException("/data0"));
    assertEquals(1, errorResponse.data().results().size());
    AlterReplicaLogDirTopicResult topicResponse = errorResponse.data().results().get(0);
    assertEquals("topic", topicResponse.topicName());
    assertEquals(3, topicResponse.partitions().size());
    for (int i = 0; i < 3; i++) {
        assertEquals(i, topicResponse.partitions().get(i).partitionIndex());
        assertEquals(Errors.LOG_DIR_NOT_FOUND.code(), topicResponse.partitions().get(i).errorCode());
    }
}
Also used : AlterReplicaLogDir(org.apache.kafka.common.message.AlterReplicaLogDirsRequestData.AlterReplicaLogDir) AlterReplicaLogDirTopicCollection(org.apache.kafka.common.message.AlterReplicaLogDirsRequestData.AlterReplicaLogDirTopicCollection) AlterReplicaLogDirsRequestData(org.apache.kafka.common.message.AlterReplicaLogDirsRequestData) LogDirNotFoundException(org.apache.kafka.common.errors.LogDirNotFoundException) AlterReplicaLogDirTopicResult(org.apache.kafka.common.message.AlterReplicaLogDirsResponseData.AlterReplicaLogDirTopicResult) AlterReplicaLogDirTopic(org.apache.kafka.common.message.AlterReplicaLogDirsRequestData.AlterReplicaLogDirTopic) AlterReplicaLogDirCollection(org.apache.kafka.common.message.AlterReplicaLogDirsRequestData.AlterReplicaLogDirCollection) Test(org.junit.jupiter.api.Test)

Example 2 with AlterReplicaLogDirCollection

use of org.apache.kafka.common.message.AlterReplicaLogDirsRequestData.AlterReplicaLogDirCollection in project kafka by apache.

the class AlterReplicaLogDirsRequestTest method testPartitionDir.

@Test
public void testPartitionDir() {
    AlterReplicaLogDirsRequestData data = new AlterReplicaLogDirsRequestData().setDirs(new AlterReplicaLogDirCollection(asList(new AlterReplicaLogDir().setPath("/data0").setTopics(new AlterReplicaLogDirTopicCollection(asList(new AlterReplicaLogDirTopic().setName("topic").setPartitions(asList(0, 1)), new AlterReplicaLogDirTopic().setName("topic2").setPartitions(asList(7))).iterator())), new AlterReplicaLogDir().setPath("/data1").setTopics(new AlterReplicaLogDirTopicCollection(asList(new AlterReplicaLogDirTopic().setName("topic3").setPartitions(asList(12))).iterator()))).iterator()));
    AlterReplicaLogDirsRequest request = new AlterReplicaLogDirsRequest.Builder(data).build();
    Map<TopicPartition, String> expect = new HashMap<>();
    expect.put(new TopicPartition("topic", 0), "/data0");
    expect.put(new TopicPartition("topic", 1), "/data0");
    expect.put(new TopicPartition("topic2", 7), "/data0");
    expect.put(new TopicPartition("topic3", 12), "/data1");
    assertEquals(expect, request.partitionDirs());
}
Also used : AlterReplicaLogDir(org.apache.kafka.common.message.AlterReplicaLogDirsRequestData.AlterReplicaLogDir) AlterReplicaLogDirTopicCollection(org.apache.kafka.common.message.AlterReplicaLogDirsRequestData.AlterReplicaLogDirTopicCollection) HashMap(java.util.HashMap) AlterReplicaLogDirsRequestData(org.apache.kafka.common.message.AlterReplicaLogDirsRequestData) TopicPartition(org.apache.kafka.common.TopicPartition) AlterReplicaLogDirTopic(org.apache.kafka.common.message.AlterReplicaLogDirsRequestData.AlterReplicaLogDirTopic) AlterReplicaLogDirCollection(org.apache.kafka.common.message.AlterReplicaLogDirsRequestData.AlterReplicaLogDirCollection) Test(org.junit.jupiter.api.Test)

Aggregations

AlterReplicaLogDirsRequestData (org.apache.kafka.common.message.AlterReplicaLogDirsRequestData)2 AlterReplicaLogDir (org.apache.kafka.common.message.AlterReplicaLogDirsRequestData.AlterReplicaLogDir)2 AlterReplicaLogDirCollection (org.apache.kafka.common.message.AlterReplicaLogDirsRequestData.AlterReplicaLogDirCollection)2 AlterReplicaLogDirTopic (org.apache.kafka.common.message.AlterReplicaLogDirsRequestData.AlterReplicaLogDirTopic)2 AlterReplicaLogDirTopicCollection (org.apache.kafka.common.message.AlterReplicaLogDirsRequestData.AlterReplicaLogDirTopicCollection)2 Test (org.junit.jupiter.api.Test)2 HashMap (java.util.HashMap)1 TopicPartition (org.apache.kafka.common.TopicPartition)1 LogDirNotFoundException (org.apache.kafka.common.errors.LogDirNotFoundException)1 AlterReplicaLogDirTopicResult (org.apache.kafka.common.message.AlterReplicaLogDirsResponseData.AlterReplicaLogDirTopicResult)1