showuon commented on code in PR #14306: URL: https://github.com/apache/kafka/pull/14306#discussion_r1314398152
########## core/src/main/scala/kafka/server/AuthHelper.scala: ########## @@ -130,4 +134,57 @@ class AuthHelper(authorizer: Option[Authorizer]) { } } + def computeDescribeClusterResponse( + request: RequestChannel.Request, + expectedEndpointType: EndpointType, + clusterId: String, + getNodes: () => DescribeClusterBrokerCollection, + getControllerId: () => Int + ): DescribeClusterResponseData = { + val describeClusterRequest = request.body[DescribeClusterRequest] + val requestEndpointType = EndpointType.fromId(describeClusterRequest.data().endpointType()) + if (requestEndpointType.equals(EndpointType.UNKNOWN)) { + return new DescribeClusterResponseData(). + setErrorCode(if (request.header.data().requestApiVersion() == 0) { + Errors.INVALID_REQUEST.code() + } else { + Errors.UNSUPPORTED_ENDPOINT_TYPE.code() + }). + setErrorMessage("Unsupported endpoint type " + describeClusterRequest.data().endpointType().toInt) + } else if (!expectedEndpointType.equals(requestEndpointType)) { + return new DescribeClusterResponseData(). + setErrorCode(if (request.header.data().requestApiVersion() == 0) { + Errors.INVALID_REQUEST.code() + } else { + Errors.MISMATCHED_ENDPOINT_TYPE.code() + }). + setErrorMessage("The request was sent to an endpoint of type " + expectedEndpointType + + ", but we wanted an endpoint of type " + requestEndpointType) + } Review Comment: OK, thanks. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org