horsteff opened a new pull request #7533:
URL: https://github.com/apache/pulsar/pull/7533
Fixes #7492
### Motivation
`PulsarStandaloneBuilder.withConfig()` does effectively nothing because
provided config will be overwritten in `PulsarStandaloneBuilder.build()`. Any
values set on a configuration object set by `withConfig()` will be lost.
Additionally unlike in `PulsarStandaloneStarter` the
`PulsarStandaloneBuilder` does not evaluate the configuration file for the
`ServiceConfiguration`, so only options for `LocalBookkeeperEnsemble` (via the
`ServerConfiguration` class evaluation in `PulsarStandalone.start()`) will be
read from the configuration file, all other (e.g.
`managedLedgerDefaultEnsembleSize`) will be ignored.
And options for `LocalBookkeeperEnsemble` are only read from config file and
can't be changed by code.
### Modifications
This change drops `PulsarStandaloneBuilder.withConfig()` in favour of a new
`withConfigFile` method. The provided configuration file will be read in
`PulsarStandaloneBuilder.build()` and allows using it for
`ServiceConfiguration`. Changes to the configuration can be made after calling
`PulsarStandaloneBuilder.build()` and before `PulsarStandalone.start()`, making
it clear to the user that such changes overwrite values set in the
configuration file.
This change also introduces a `bkServerConfig` property into
`PulsarStandalone`. This allows to create a `ServerConfiguration` from the
configuration file in `PulsarStandaloneBuilder.build()` and changing the
configuration afterwards by code. If provided `PulsarStandalone` uses the
`bkServerConfig` property for the `LocalBookkeeperEnsemble` or creates a new
`ServerConfiguration` from the configuration file, if the property is not set,
to maintain compatibility with existing code.
### Verifying this change
This change added tests and can be verified as follows:
- Added a test for `PulsarStandaloneBuilder` to check, if configuration
objects are created and filled from configuration file
### Does this pull request potentially affect one of the following parts:
- The public API: *yes* (`PulsarStandaloneBuilder`)
### Documentation
- Does this pull request introduce a new feature? yes
(`PulsarStandaloneBuilder.withConfigFile`)
- If yes, how is the feature documented? (Java comments, self-explanatory)
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]