Search in sources :

Example 1 with AlterConfigsResult

use of org.apache.kafka.clients.admin.AlterConfigsResult in project ksql by confluentinc.

the class KafkaTopicClientImplTest method alterTopicConfigResponse.

private static AlterConfigsResult alterTopicConfigResponse(final Exception cause) {
    final AlterConfigsResult response = mock(AlterConfigsResult.class);
    expect(response.all()).andReturn(failedFuture(cause));
    replay(response);
    return response;
}
Also used : AlterConfigsResult(org.apache.kafka.clients.admin.AlterConfigsResult)

Example 2 with AlterConfigsResult

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

the class ControllerIT method alterTopicConfig.

private void alterTopicConfig(TestContext context, String topicName, String configMapName) throws InterruptedException, ExecutionException {
    // Get the topic config
    ConfigResource configResource = topicConfigResource(topicName);
    org.apache.kafka.clients.admin.Config config = getTopicConfig(configResource);
    String key = "compression.type";
    Map<String, ConfigEntry> m = new HashMap<>();
    for (ConfigEntry entry : config.entries()) {
        m.put(entry.name(), entry);
    }
    final String changedValue;
    if ("snappy".equals(m.get(key).value())) {
        changedValue = "lz4";
    } else {
        changedValue = "snappy";
    }
    m.put(key, new ConfigEntry(key, changedValue));
    LOGGER.info("Changing topic config {} to {}", key, changedValue);
    // Update the topic config
    AlterConfigsResult cgf = adminClient.alterConfigs(singletonMap(configResource, new org.apache.kafka.clients.admin.Config(m.values())));
    cgf.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 config change", configMapName);
        String gotValue = TopicSerialization.fromConfigMap(cm).getConfig().get(key);
        LOGGER.info("Got value {}", gotValue);
        return changedValue.equals(gotValue);
    }, timeout, "Expected the configmap to have been deleted by now");
}
Also used : ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) HashMap(java.util.HashMap) ConfigResource(org.apache.kafka.common.config.ConfigResource) ConfigEntry(org.apache.kafka.clients.admin.ConfigEntry) AlterConfigsResult(org.apache.kafka.clients.admin.AlterConfigsResult)

Example 3 with AlterConfigsResult

use of org.apache.kafka.clients.admin.AlterConfigsResult in project ksql by confluentinc.

the class KafkaTopicClientImplTest method alterTopicConfigResponse.

private static AlterConfigsResult alterTopicConfigResponse() {
    final AlterConfigsResult response = mock(AlterConfigsResult.class);
    expect(response.all()).andReturn(KafkaFuture.completedFuture(null));
    replay(response);
    return response;
}
Also used : AlterConfigsResult(org.apache.kafka.clients.admin.AlterConfigsResult)

Aggregations

AlterConfigsResult (org.apache.kafka.clients.admin.AlterConfigsResult)3 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)1 HashMap (java.util.HashMap)1 ConfigEntry (org.apache.kafka.clients.admin.ConfigEntry)1 ConfigResource (org.apache.kafka.common.config.ConfigResource)1