Support multiple advertisedListener for HTTP protocol #17063
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
PIP 61 and PIP 95 supports multiple advertised address for binary port.
For HTTP port, currently we do not have a way to support multiple advertised address.
Consider we are deploying a broker that can be accessed through both private network (for example 192.168.0.1) and public network (for example 10.175.100.1), we could configure multiple advertised listener for binary port, Pulsar client could access broker through both private and public network with correct listener name. For HTTP address, we could only configure one advertised address through internal listener:
pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java
Line 1613 in 0cf2a75
If we configure private address(192.168.0.1) for HTTP address, we may not execute some PulsarAdmin API from public network, since some http request (for example get topics' stats) may get 307 response code and redirect to another broker's private address.
Modifications
Configure multiple advertised http address in
advertisedListeners
together with binary address.Broker:
For HTTP request, get listener name from request header
X-Pulsar-ListenerName
, use the listener name for topic lookup and topic owner verification, return advertised http address in case of http redirect.Pulsar Admin:
Add
listenerName
toPulsarAdminBuilder
, and set listener name to HTTP request headerX-Pulsar-ListenerName
.Verifying this change
This change added tests and can be verified as follows:
MultiHTTPAdvertisedListenersTest
Documentation
Check the box below or label this PR directly.
Need to update docs?
doc-required
Need to update doc for configuration multiple HTTP address after PR accecpt.