Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PIP 95][Issue 12040][broker] Multiple bind addresses for Pulsar protocol #12056

Merged
merged 8 commits into from
Oct 14, 2021

Conversation

EronWright
Copy link
Contributor

@EronWright EronWright commented Sep 16, 2021

Master Issue: #12040

Motivation

Add a new configuration setting bindAddresses to open additional server ports on the broker. Note that these are in addition to brokerServicePort / brokerServicePortTls for compatibility reasons.

Each new-style bind address is associated with an advertised listener, to be used as the default listener for topic lookup requests. See #12040 for details. A given listener may be associated with numerous bindings.

The scheme indicates the protocol handler and whether to use TLS on the server channel. This PR is focused on the Pulsar protocol handler, but it is anticipated that other protocols may be supported in future.

For example:

bindAddresses=external:pulsar://0.0.0.0:6652,external:pulsar+ssl://0.0.0.0:6653
bindAddress=0.0.0.0
brokerServicePort=6650
brokerServicePortTls=6651
advertisedListeners=cluster:pulsar://broker-1.local:6650,cluster:pulsar+ssl://broker-1.local:6651,external:pulsar://broker-1.example.dev:6652,external:pulsar+ssl://broker-1.example.dev:6653
internalListenerName=cluster

The above would produce three server sockets, with 6650 having no associated listener name (thus retaining existing lookup behavior of returning the internal listener), and with 6652 and 6653 having an association with listener name external. Given a lookup request on 6652 or 6653, the external listener address would be returned.

Modifications

  • added configuration property bindAddresses
  • implementing parsing and validation logic
  • factored some utility code for formatting broker/web addresses

Verifying this change

  • Make sure that the change passes the CI checks.
  • Adhoc testing as outlined in PIP 95.

This change added tests and can be verified as follows:

  • Added unit tests for configuration validation logic.

Does this pull request potentially affect one of the following parts:

  • Anything that affects deployment: yes - new optional configuration properties

Documentation

Check the box below and label this PR (if you have committer privilege).

Need to update docs?

  • doc-required


Optional<Integer> tlsPort = serviceConfig.getBrokerServicePortTls();
if (tlsPort.isPresent()) {
ServerBootstrap tlsBootstrap = bootstrap.clone();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An oddity in the old code is that bootstrap is cloned here, though it has the non-TLS child handler attached already. I assume the handler is replaced. I would expect the defaultServerBootstrap to be cloned, rather than taking a clone of a clone. See new code.

@Anonymitaet Anonymitaet added the doc Your PR contains doc changes, no matter whether the changes are in markdown or code files. label Sep 18, 2021
@Anonymitaet
Copy link
Member

@EronWright thanks for your contribution!
One quick question: need to add the configuration and descriptions to Pulsar docs (https://pulsar.apache.org/docs/en/next/reference-configuration/)?

@codelipenghui codelipenghui added this to the 2.9.0 milestone Sep 18, 2021
Copy link
Contributor

@codelipenghui codelipenghui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

LGTM, just left a few comments.

@eolivelli eolivelli changed the title [Issue 12040][broker] Multiple bind addresses for Pulsar protocol [PIP 95][Issue 12040][broker] Multiple bind addresses for Pulsar protocol Sep 20, 2021
@EronWright
Copy link
Contributor Author

I've addressed the feedback, please take another look.

Copy link
Contributor

@Huanli-Meng Huanli-Meng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A minor comment. PTAL. Thanks

site2/docs/reference-configuration.md Show resolved Hide resolved
@eolivelli eolivelli modified the milestones: 2.9.0, 2.10.0 Oct 6, 2021
Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

We can merge to 2.9 if CI passes, I have restarted the failed jobs

cc @codelipenghui

@codelipenghui codelipenghui modified the milestones: 2.10.0, 2.9.0 Oct 11, 2021
@codelipenghui
Copy link
Contributor

/pulsarbot run-failure-checks

1 similar comment
@BewareMyPower
Copy link
Contributor

/pulsarbot run-failure-checks

@eolivelli
Copy link
Contributor

CI error is related to this patch

please fix

testMalformed(org.apache.pulsar.broker.validator.BindAddressValidatorTest)  Time elapsed: 0.033 s  <<< FAILURE!
java.lang.IllegalArgumentException: bindAddresses: malformed: internal:
	at org.apache.pulsar.broker.validator.BindAddressValidator.lambda$validateBindAddresses$0(BindAddressValidator.java:56)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
	at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234
```)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)

@EronWright
Copy link
Contributor Author

I believe this PR is ready to merge. The intermittent test failure seem unrelated.

Run 2: TopicPoliciesTest.testPolicyOverwrittenByNamespaceLevel:1034 » ConditionTimeout

@codelipenghui codelipenghui merged commit 3a337b8 into apache:master Oct 14, 2021
zeo1995 pushed a commit to zeo1995/pulsar that referenced this pull request Oct 14, 2021
* up/master: (26 commits)
  [pulsar-admin] Allow setting --forward-source-message-property to false when updating a pulsar function (apache#12128)
  [website][upgrade]feat: docs migration - Development (apache#12320)
  Update delete inactive topic configuration documentation (apache#12350)
  [PIP 95][Issue 12040][broker] Multiple bind addresses for Pulsar protocol (apache#12056)
  Added Debezium Source for MS SQL Server (apache#12256)
  Fix: flaky oracle tests (apache#12306)
  [C++] Use URL encoded content type for OAuth 2.0 authentication (apache#12341)
  [C++] Handle OAuth 2.0 exceptional cases gracefully (apache#12335)
  feat(cli): add restart command to pulsar-daemon (apache#12279)
  [client-tools] Remove redundant initial value (apache#12296)
  Make AuthenticationTokenTest to run on windows (apache#12329)
  [offload] fix FileSystemManagedLedgerOffloader can not cleanup outdated ledger data (apache#12309)
  [Doc]--Update contents for Pulsar adaptor for Apache Spark (apache#12338)
  [PIP 95][Issue 12040][broker] Improved multi-listener in standalone mode (apache#12066)
  [website][upgrade]feat: docs migration - Cookbooks (apache#12319)
  [testclient] Make --payload-file take effect in PerformanceClient (apache#12187)
  [website][upgrade]feat: docs migration - adaptor (apache#12318)
  [pulsar-client] Add partition-change api for producer/consumer interceptors (apache#12287)
  [Transaction]Fix lowWaterMark of TopicTransactionBuffer (apache#12312)
  [pulsar-admin] New option takes precedence over deprecated option (apache#12260)
  ...

# Conflicts:
#	site2/website-next/docusaurus.config.js
#	site2/website-next/versions.json
zeo1995 pushed a commit to zeo1995/pulsar that referenced this pull request Oct 14, 2021
* up/master: (37 commits)
  re-enabling integration tests for Sinks (apache#12307)
  [PIP 95][Issue 12040][web] Topic lookup with listener header (apache#12072)
  Fix the master CI broken with update dispatch rate block issue (apache#12360)
  Fix message being ignored when the non-persistent topic reader reconnect. (apache#12348)
  Fix log format. (apache#12346)
  [website][upgrade]feat: docs migration - version-2.7.2 Concepts and Architecture (apache#12354)
  [website][upgrade] feat: full docs migration for version 2.8.0 (apache#12359)
  [website][upgrade]feat: dynamic replace version info before build (apache#12337)
  Fix flaky tests: ElasticSearchClientTests (apache#12347)
  Use asyncCloseCursorLedger to replace cursorLedger.asyncClose method in the ManagedCursorImpl.VoidCallback#operationComplete (apache#12113)
  fix-npe-ZkBookieRackAffinityMapping (apache#11947)
  [pulsar-admin] Allow setting --forward-source-message-property to false when updating a pulsar function (apache#12128)
  [website][upgrade]feat: docs migration - Development (apache#12320)
  Update delete inactive topic configuration documentation (apache#12350)
  [PIP 95][Issue 12040][broker] Multiple bind addresses for Pulsar protocol (apache#12056)
  Added Debezium Source for MS SQL Server (apache#12256)
  Fix: flaky oracle tests (apache#12306)
  [C++] Use URL encoded content type for OAuth 2.0 authentication (apache#12341)
  [C++] Handle OAuth 2.0 exceptional cases gracefully (apache#12335)
  feat(cli): add restart command to pulsar-daemon (apache#12279)
  ...

# Conflicts:
#	site2/website-next/docusaurus.config.js
#	site2/website-next/versioned_sidebars/version-2.7.2-sidebars.json
#	site2/website-next/versions.json
bharanic-dev pushed a commit to bharanic-dev/pulsar that referenced this pull request Mar 18, 2022
…ocol (apache#12056)

Master Issue: apache#12040

### Motivation

Add a new configuration setting `bindAddresses` to open additional server ports on the broker.  Note that these are in addition to `brokerServicePort` / `brokerServicePortTls` for compatibility reasons.

Each new-style bind address is associated with an advertised listener, to be used as the default listener for topic lookup requests.   See apache#12040 for details.  A given listener may be associated with numerous bindings.

The scheme indicates the protocol handler and whether to use TLS on the server channel.  This PR is focused on the Pulsar protocol handler, but it is anticipated that other protocols may be supported in future.

For example:
```
bindAddresses=external:pulsar://0.0.0.0:6652,external:pulsar+ssl://0.0.0.0:6653
bindAddress=0.0.0.0
brokerServicePort=6650
brokerServicePortTls=6651
advertisedListeners=cluster:pulsar://broker-1.local:6650,cluster:pulsar+ssl://broker-1.local:6651,external:pulsar://broker-1.example.dev:6652,external:pulsar+ssl://broker-1.example.dev:6653
internalListenerName=cluster
```

The above would produce three server sockets, with `6650` having no associated listener name (thus retaining existing lookup behavior of returning the internal listener), and with `6652` and `6653` having an association with listener name `external`.  Given a lookup request on `6652` or `6653`, the `external` listener address would be returned.

### Modifications

- added configuration property `bindAddresses`
- implementing parsing and validation logic
- factored some utility code for formatting broker/web addresses
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Your PR contains doc changes, no matter whether the changes are in markdown or code files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants