merlimat commented on a change in pull request #14078:
URL: https://github.com/apache/pulsar/pull/14078#discussion_r801914768
##########
File path:
pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ProxyConnection.java
##########
@@ -243,14 +254,51 @@ private synchronized void completeConnect(AuthData
clientData) throws PulsarClie
}
LOG.info("[{}] complete connection, init proxy handler. authenticated
with {} role {}, hasProxyToBrokerUrl: {}",
- remoteAddress, authMethod, clientAuthRole, hasProxyToBrokerUrl);
+ remoteAddress, authMethod, clientAuthRole,
hasProxyToBrokerUrl);
if (hasProxyToBrokerUrl) {
- // Client already knows which broker to connect. Let's open a
- // connection there and just pass bytes in both directions
- state = State.ProxyConnectionToBroker;
- directProxyHandler = new DirectProxyHandler(service, this,
proxyToBrokerUrl,
- protocolVersionToAdvertise, sslHandlerSupplier);
- cancelKeepAliveTask();
+ // Optimize proxy connection to fail-fast if the target broker
isn't active
+ // Pulsar client will retry connecting after a back off timeout
+ if (service.getConfiguration().isCheckActiveBrokers()
+ && !isBrokerActive(proxyToBrokerUrl)) {
+ state = State.Closing;
+ LOG.warn("[{}] Target broker '{}' isn't available.
authenticated with {} role {}.",
+ remoteAddress, proxyToBrokerUrl, authMethod,
clientAuthRole);
+ ctx()
+ .writeAndFlush(
+ Commands.newError(-1,
ServerError.ServiceNotReady, "Target broker isn't available."))
+ .addListener(future -> ctx().close());
+ return;
+ }
+
+ brokerProxyValidator.resolveAndCheckTargetAddress(proxyToBrokerUrl)
Review comment:
Why do we need to due DNS resolution here? Wouldn't it be better to just
match the hostnames instead of IPs (if the advertised address is based on
hostnames).
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]