-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[refactor][proxy] Refactor Proxy code and fix connection stalling by …
…switching to auto read mode (#14713) ### Motivation Refactor Proxy code to make it easier to understand and maintain. In addition, switch to use auto read mode since the proxies connections seem to stall in some cases since the proxied connection doesn't use Netty's auto read mode and the read handling doesn't seem complete. Currently, the proxy calls `.read()` when a message is written to the connection. There might be more messages flowing in the other direction and it could result in a blocked connection with the current solution that doesn't use Netty's auto read mode. Currently auto read is disabled in DirectProxyHandler for the connection between the proxy and the broker: https://github.com/apache/pulsar/blob/a26905371749798ec5288fb07a69978a36aacfaa/pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/DirectProxyHandler.java#L112 ### Modifications - replace broker host parsing with a simple solution - pass remote host name to ProxyBackendHandler in the constructor - rename "targetBrokerUrl" to "brokerHostAndPort" since the "targetBrokerUrl" is really "hostname:port" string - move HA proxy message handling to ProxyBackendHandle and extract the logic to a method - remove the static "inboundOutboundChannelMap" which was used for log level 2 - make it obsolete by passing the peer channel id to ParserProxyHandler - Enable auto read in proxy and remove `ctx.read()` / `channel.read()` calls - prepare for IPv6 support (reported as #14732) by improving the `host:port` parsing (pick last `:` since IPv6 address might contains multiple `:` characters) - Handle backpressure properly by switching auto read off when channel writability changes - change auto read of the proxy-broker connection based on the writability of the client-proxy connection - change auto read of the client-proxy connection based on the writability of the proxy-broker connection - Consistently handle write errors by delegating exception handling to exceptionCaught method by using `.addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE)` (cherry picked from commit a1037c7)
- Loading branch information
Showing
5 changed files
with
126 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.