use of org.apache.kafka.common.message.DescribeClusterResponseData in project kafka by apache.
the class KafkaAdminClientTest method testDescribeClusterHandleError.
@Test
public void testDescribeClusterHandleError() {
try (AdminClientUnitTestEnv env = new AdminClientUnitTestEnv(mockCluster(4, 0), AdminClientConfig.RETRIES_CONFIG, "2")) {
env.kafkaClient().setNodeApiVersions(NodeApiVersions.create());
// Prepare the describe cluster response used for the first describe cluster
String errorMessage = "my error";
env.kafkaClient().prepareResponse(new DescribeClusterResponse(new DescribeClusterResponseData().setErrorCode(Errors.INVALID_REQUEST.code()).setErrorMessage(errorMessage)));
final DescribeClusterResult result = env.adminClient().describeCluster();
TestUtils.assertFutureThrows(result.clusterId(), InvalidRequestException.class, errorMessage);
TestUtils.assertFutureThrows(result.controller(), InvalidRequestException.class, errorMessage);
TestUtils.assertFutureThrows(result.nodes(), InvalidRequestException.class, errorMessage);
TestUtils.assertFutureThrows(result.authorizedOperations(), InvalidRequestException.class, errorMessage);
}
}
use of org.apache.kafka.common.message.DescribeClusterResponseData in project kafka by apache.
the class KafkaAdminClientTest method prepareDescribeClusterResponse.
private static DescribeClusterResponse prepareDescribeClusterResponse(int throttleTimeMs, Collection<Node> brokers, String clusterId, int controllerId, int clusterAuthorizedOperations) {
DescribeClusterResponseData data = new DescribeClusterResponseData().setErrorCode(Errors.NONE.code()).setThrottleTimeMs(throttleTimeMs).setControllerId(controllerId).setClusterId(clusterId).setClusterAuthorizedOperations(clusterAuthorizedOperations);
brokers.forEach(broker -> data.brokers().add(new DescribeClusterBroker().setHost(broker.host()).setPort(broker.port()).setBrokerId(broker.id()).setRack(broker.rack())));
return new DescribeClusterResponse(data);
}
Aggregations