You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "michaeljmarshall (via GitHub)" <gi...@apache.org> on 2023/01/26 19:19:29 UTC
[GitHub] [pulsar] michaeljmarshall commented on a diff in pull request #19327: [fix][client] Set fields earlier for correct ClientCnx initialization
michaeljmarshall commented on code in PR #19327:
URL: https://github.com/apache/pulsar/pull/19327#discussion_r1088247891
##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarChannelInitializer.java:
##########
@@ -209,5 +209,33 @@ CompletableFuture<Channel> initSocks5IfConfig(Channel ch) {
return initSocks5Future;
}
+
+ CompletableFuture<Channel> initializeClientCnx(Channel ch,
+ InetSocketAddress logicalAddress,
+ InetSocketAddress resolvedPhysicalAddress) {
+ CompletableFuture<Channel> initFuture = new CompletableFuture<>();
+ ch.eventLoop().execute(() -> {
+ final ClientCnx cnx = (ClientCnx) ch.pipeline().get("handler");
+
+ if (cnx == null) {
+ initFuture
+ .completeExceptionally(new IllegalStateException("Missing ClientCnx. This should not happen."));
+ }
+
+ // Need to do our own equality because the physical address is resolved already
+ if (!(logicalAddress.getHostString().equalsIgnoreCase(resolvedPhysicalAddress.getHostString())
+ && logicalAddress.getPort() == resolvedPhysicalAddress.getPort())) {
+ // We are connecting through a proxy. We need to set the target broker in the ClientCnx object so that
+ // it can be specified when sending the CommandConnect.
+ cnx.setTargetBroker(logicalAddress);
+ }
+
+ cnx.setRemoteHostName(resolvedPhysicalAddress.getHostString());
+
+ initFuture.complete(ch);
+ });
Review Comment:
I didn't know about that one. That seems helpful. I'll look into it.
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org