Search in sources :

Example 1 with CreatePartitionsResult

use of org.apache.kafka.clients.admin.CreatePartitionsResult in project strimzi by strimzi.

the class ControllerIT method alterTopicNumPartitions.

private void alterTopicNumPartitions(TestContext context, String topicName, String configMapName) throws InterruptedException, ExecutionException {
    int changedValue = 2;
    NewPartitions newPartitions = NewPartitions.increaseTo(changedValue);
    Map<String, NewPartitions> map = new HashMap<>(1);
    map.put(topicName, newPartitions);
    CreatePartitionsResult createPartitionsResult = adminClient.createPartitions(map);
    createPartitionsResult.all().get();
    // Wait for the configmap to be modified
    waitFor(context, () -> {
        ConfigMap cm = kubeClient.configMaps().inNamespace(NAMESPACE).withName(configMapName).get();
        LOGGER.info("Polled configmap {}, waiting for partitions change", configMapName);
        int gotValue = TopicSerialization.fromConfigMap(cm).getNumPartitions();
        LOGGER.info("Got value {}", gotValue);
        return changedValue == gotValue;
    }, timeout, "Expected the configmap to have been deleted by now");
}
Also used : ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) NewPartitions(org.apache.kafka.clients.admin.NewPartitions) HashMap(java.util.HashMap) CreatePartitionsResult(org.apache.kafka.clients.admin.CreatePartitionsResult)

Example 2 with CreatePartitionsResult

use of org.apache.kafka.clients.admin.CreatePartitionsResult in project druid by druid-io.

the class KafkaAdminClient method updatePartitionCount.

/**
 * This method can only increase the partition count of {@param streamName} to have a final partition
 * count of {@param newPartitionCount}
 * If {@param blocksUntilStarted} is set to true, then this method will blocks until the partitioning
 * started (but not nessesary finished), otherwise, the method will returns right after issue the
 * repartitioning command
 */
@Override
public void updatePartitionCount(String streamName, int newPartitionCount, boolean blocksUntilStarted) throws Exception {
    Map<String, NewPartitions> counts = new HashMap<>();
    counts.put(streamName, NewPartitions.increaseTo(newPartitionCount));
    CreatePartitionsResult createPartitionsResult = adminClient.createPartitions(counts);
    if (blocksUntilStarted) {
        createPartitionsResult.values().get(streamName).get();
    }
}
Also used : NewPartitions(org.apache.kafka.clients.admin.NewPartitions) HashMap(java.util.HashMap) CreatePartitionsResult(org.apache.kafka.clients.admin.CreatePartitionsResult)

Aggregations

HashMap (java.util.HashMap)2 CreatePartitionsResult (org.apache.kafka.clients.admin.CreatePartitionsResult)2 NewPartitions (org.apache.kafka.clients.admin.NewPartitions)2 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)1