Search in sources :

Example 6 with DescribeConfigsResponse

use of org.apache.kafka.common.requests.DescribeConfigsResponse in project kafka by apache.

the class KafkaAdminClientTest method testDescribeBrokerConfigs.

@Test
public void testDescribeBrokerConfigs() throws Exception {
    ConfigResource broker0Resource = new ConfigResource(ConfigResource.Type.BROKER, "0");
    ConfigResource broker1Resource = new ConfigResource(ConfigResource.Type.BROKER, "1");
    try (AdminClientUnitTestEnv env = mockClientEnv()) {
        env.kafkaClient().setNodeApiVersions(NodeApiVersions.create());
        env.kafkaClient().prepareResponseFrom(new DescribeConfigsResponse(new DescribeConfigsResponseData().setResults(asList(new DescribeConfigsResponseData.DescribeConfigsResult().setResourceName(broker0Resource.name()).setResourceType(broker0Resource.type().id()).setErrorCode(Errors.NONE.code()).setConfigs(emptyList())))), env.cluster().nodeById(0));
        env.kafkaClient().prepareResponseFrom(new DescribeConfigsResponse(new DescribeConfigsResponseData().setResults(asList(new DescribeConfigsResponseData.DescribeConfigsResult().setResourceName(broker1Resource.name()).setResourceType(broker1Resource.type().id()).setErrorCode(Errors.NONE.code()).setConfigs(emptyList())))), env.cluster().nodeById(1));
        Map<ConfigResource, KafkaFuture<Config>> result = env.adminClient().describeConfigs(asList(broker0Resource, broker1Resource)).values();
        assertEquals(new HashSet<>(asList(broker0Resource, broker1Resource)), result.keySet());
        result.get(broker0Resource).get();
        result.get(broker1Resource).get();
    }
}
Also used : DescribeConfigsResponseData(org.apache.kafka.common.message.DescribeConfigsResponseData) KafkaFuture(org.apache.kafka.common.KafkaFuture) ConfigResource(org.apache.kafka.common.config.ConfigResource) DescribeConfigsResponse(org.apache.kafka.common.requests.DescribeConfigsResponse) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 7 with DescribeConfigsResponse

use of org.apache.kafka.common.requests.DescribeConfigsResponse in project kafka by apache.

the class KafkaAdminClientTest method testDescribeConfigsUnrequested.

@Test
public void testDescribeConfigsUnrequested() throws Exception {
    ConfigResource topic = new ConfigResource(ConfigResource.Type.TOPIC, "topic");
    ConfigResource unrequested = new ConfigResource(ConfigResource.Type.TOPIC, "unrequested");
    try (AdminClientUnitTestEnv env = mockClientEnv()) {
        env.kafkaClient().setNodeApiVersions(NodeApiVersions.create());
        env.kafkaClient().prepareResponse(new DescribeConfigsResponse(new DescribeConfigsResponseData().setResults(asList(new DescribeConfigsResponseData.DescribeConfigsResult().setResourceName(topic.name()).setResourceType(topic.type().id()).setErrorCode(Errors.NONE.code()).setConfigs(emptyList()), new DescribeConfigsResponseData.DescribeConfigsResult().setResourceName(unrequested.name()).setResourceType(unrequested.type().id()).setErrorCode(Errors.NONE.code()).setConfigs(emptyList())))));
        Map<ConfigResource, KafkaFuture<Config>> result = env.adminClient().describeConfigs(asList(topic)).values();
        assertEquals(new HashSet<>(asList(topic)), result.keySet());
        assertNotNull(result.get(topic).get());
        assertNull(result.get(unrequested));
    }
}
Also used : DescribeConfigsResponseData(org.apache.kafka.common.message.DescribeConfigsResponseData) KafkaFuture(org.apache.kafka.common.KafkaFuture) ConfigResource(org.apache.kafka.common.config.ConfigResource) DescribeConfigsResponse(org.apache.kafka.common.requests.DescribeConfigsResponse) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 8 with DescribeConfigsResponse

use of org.apache.kafka.common.requests.DescribeConfigsResponse in project kafka by apache.

the class KafkaAdminClientTest method testDescribeBrokerAndLogConfigs.

@Test
public void testDescribeBrokerAndLogConfigs() throws Exception {
    ConfigResource brokerResource = new ConfigResource(ConfigResource.Type.BROKER, "0");
    ConfigResource brokerLoggerResource = new ConfigResource(ConfigResource.Type.BROKER_LOGGER, "0");
    try (AdminClientUnitTestEnv env = mockClientEnv()) {
        env.kafkaClient().setNodeApiVersions(NodeApiVersions.create());
        env.kafkaClient().prepareResponseFrom(new DescribeConfigsResponse(new DescribeConfigsResponseData().setResults(asList(new DescribeConfigsResponseData.DescribeConfigsResult().setResourceName(brokerResource.name()).setResourceType(brokerResource.type().id()).setErrorCode(Errors.NONE.code()).setConfigs(emptyList()), new DescribeConfigsResponseData.DescribeConfigsResult().setResourceName(brokerLoggerResource.name()).setResourceType(brokerLoggerResource.type().id()).setErrorCode(Errors.NONE.code()).setConfigs(emptyList())))), env.cluster().nodeById(0));
        Map<ConfigResource, KafkaFuture<Config>> result = env.adminClient().describeConfigs(asList(brokerResource, brokerLoggerResource)).values();
        assertEquals(new HashSet<>(asList(brokerResource, brokerLoggerResource)), result.keySet());
        result.get(brokerResource).get();
        result.get(brokerLoggerResource).get();
    }
}
Also used : DescribeConfigsResponseData(org.apache.kafka.common.message.DescribeConfigsResponseData) KafkaFuture(org.apache.kafka.common.KafkaFuture) ConfigResource(org.apache.kafka.common.config.ConfigResource) DescribeConfigsResponse(org.apache.kafka.common.requests.DescribeConfigsResponse) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Aggregations

ConfigResource (org.apache.kafka.common.config.ConfigResource)8 DescribeConfigsResponse (org.apache.kafka.common.requests.DescribeConfigsResponse)8 KafkaFuture (org.apache.kafka.common.KafkaFuture)6 DescribeConfigsResponseData (org.apache.kafka.common.message.DescribeConfigsResponseData)5 HashMap (java.util.HashMap)3 Test (org.junit.jupiter.api.Test)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 Map (java.util.Map)2 UnknownServerException (org.apache.kafka.common.errors.UnknownServerException)2 KafkaFutureImpl (org.apache.kafka.common.internals.KafkaFutureImpl)2 MetricConfig (org.apache.kafka.common.metrics.MetricConfig)2 ChannelBuilder (org.apache.kafka.common.network.ChannelBuilder)2 AbstractResponse (org.apache.kafka.common.requests.AbstractResponse)2 Test (org.junit.Test)2 InetSocketAddress (java.net.InetSocketAddress)1 InvalidKeyException (java.security.InvalidKeyException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1