use of org.apache.kafka.common.message.DescribeConfigsResponseData in project kafka by apache.
the class KafkaAdminClientTest method testDescribeConfigsPartialResponse.
@Test
public void testDescribeConfigsPartialResponse() throws Exception {
ConfigResource topic = new ConfigResource(ConfigResource.Type.TOPIC, "topic");
ConfigResource topic2 = new ConfigResource(ConfigResource.Type.TOPIC, "topic2");
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())))));
Map<ConfigResource, KafkaFuture<Config>> result = env.adminClient().describeConfigs(asList(topic, topic2)).values();
assertEquals(new HashSet<>(asList(topic, topic2)), result.keySet());
result.get(topic);
TestUtils.assertFutureThrows(result.get(topic2), ApiException.class);
}
}
use of org.apache.kafka.common.message.DescribeConfigsResponseData 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.message.DescribeConfigsResponseData 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();
}
}
use of org.apache.kafka.common.message.DescribeConfigsResponseData 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();
}
}
Aggregations