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