Skip to content

Commit

Permalink
[Proxy] Remove unnecessary blocking DNS lookup in LookupProxyHandler (a…
Browse files Browse the repository at this point in the history
…pache#15415)

* [Proxy] Remove unnecessary blocking DNS lookup in LookupProxyHandler

* Use existing code pattern for creating address

(cherry picked from commit 7373a51)
(cherry picked from commit 85f0767)
  • Loading branch information
lhotari authored and nicoloboschi committed May 10, 2022
1 parent de3fef3 commit d0105df
Showing 1 changed file with 8 additions and 12 deletions.
Expand Up @@ -215,20 +215,16 @@ public void handlePartitionMetadataResponse(CommandPartitionedTopicMetadata part
private void handlePartitionMetadataResponse(CommandPartitionedTopicMetadata partitionMetadata,
long clientRequestId) {
TopicName topicName = TopicName.get(partitionMetadata.getTopic());
URI brokerURI;
try {
String availableBrokerServiceURL = getBrokerServiceUrl(clientRequestId);
if (availableBrokerServiceURL == null) {
log.warn("No available broker for {} to lookup partition metadata", topicName);
return;
}
brokerURI = new URI(availableBrokerServiceURL);
} catch (URISyntaxException e) {
proxyConnection.ctx().writeAndFlush(Commands.newPartitionMetadataResponse(ServerError.MetadataError,
e.getMessage(), clientRequestId));

String serviceUrl = getBrokerServiceUrl(clientRequestId);
if (serviceUrl == null) {
log.warn("No available broker for {} to lookup partition metadata", topicName);
return;
}
InetSocketAddress addr = getAddr(serviceUrl, clientRequestId);
if (addr == null) {
return;
}
InetSocketAddress addr = new InetSocketAddress(brokerURI.getHost(), brokerURI.getPort());

if (log.isDebugEnabled()) {
log.debug("Getting connections to '{}' for Looking up topic '{}' with clientReq Id '{}'", addr,
Expand Down

0 comments on commit d0105df

Please sign in to comment.