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

Configuration should be immutable #42

Closed
radekg opened this issue Sep 27, 2016 · 7 comments
Closed

Configuration should be immutable #42

radekg opened this issue Sep 27, 2016 · 7 comments

Comments

@radekg
Copy link
Contributor

radekg commented Sep 27, 2016

Expected behavior

Configuration should be immutable. Being able to update the configuration of the Pulsar instance by using provided set methods is not safe for the program. It also isn't consistent. Some changes have an effect, some do not.

Actual behavior

The current implementation is mutable.

System configuration

Pulsar version: 1.14

I would like to suggest Typesafe Config library: https://github.com/typesafehub/config.
It's written in Java, supports simple values, as well as lists (no sets), env variable expansion and more.

There would be a number of changes required in unit tests. Some of the unit tests mutate a single configuration instance. Preferably, all tests should run on a clean environment.

I have done some preliminary work on this but I'd need merge master into it and make sure all tests pass.

Generally, if Typesafe Config is an acceptable option, I'd be happy to take this one.

@radekg radekg changed the title Configuration should bd immutable Configuration should be immutable Sep 27, 2016
@merlimat
Copy link
Contributor

Typesafe config looks like a very nice written library.

For broker config, I'd be ok to use it to populate the ServiceConfiguration. I'd like to maintain to have a single point to have to update when adding a new config variable. Currently, ServiceConfiguration is a pojo, and you just need to add a new variable with default value and example in conf/broker.conf.

Alternatively, what about having ServiceConfiguration with only getters and adding a ServiceConfigurationBuilder?

@radekg
Copy link
Contributor Author

radekg commented Sep 28, 2016

Pushed the branch to remote but no pr, just so you can have a look. The most interesting points:

This isn't a finished PR, tests need much more work. Also, the validation of minValue and maxValue isn't implemented but would be rather straightforward to implement.

To comply with what Typesafe Config needs, we would have to add reference.conf file to the resources.

Have a look, let me know what you think.

@merlimat
Copy link
Contributor

For config file, would it be possible to maintain the same java properties format? That would keep it consistent with the other config files (client, bookkeeper, ..). It seems the only change is right now the pulsar {....} enclosing namespace.

I think that having to specify the config var name (either a string or a constant), makes a it bit more complicated to configure programmatically, since you have to lookup for the list of allowed variables, while with setters it's easy to discover all the options.

@merlimat
Copy link
Contributor

But other than the 2 notes above, it seems nice to combine multiple config sources

@radekg
Copy link
Contributor Author

radekg commented Sep 28, 2016

@merlimat I'd suggest using the hocon format across all configuration. The reason is that if someone builds software where Pulsar is only one of the components using Typesafe Config, they can single hocon file for all their components. We can keep the properties look and feel but, at least, I'd suggest prefixing all settings with pulsar. to give them a namespace.

As for having to know the property names, yes, this is slightly inconvenient but, I think, you are looking from the perspective of unit tests. Preferably, all configuration variants would come as a separate .conf file. Combined with a reference.conf, everything is covered. However, if that is not enough, we can always implement a builder which would construct the necessary properties. The base is what it is, how config properties are constructed, we can change that to a friendlier looking version.

Shall I come up with a full PR?

@merlimat
Copy link
Contributor

I would rather not break the config file compatibility unless is really necessary. Also, the other concern is that bookkeeper.conf and zookeeper.conf will still be in Java properties format and that cannot be easily changed.

sijie added a commit to sijie/pulsar that referenced this issue Mar 4, 2018
@ivankelly
Copy link
Contributor

This seems to have gone quiet. Closing. Please reopen if you want this work to continue.

hrsakai pushed a commit to hrsakai/pulsar that referenced this issue Dec 10, 2020
* [issue:40]Fix producer send protocol error

Signed-off-by: xiaolong.ran <ranxiaolong716@gmail.com>

* fix comments and check code format

Signed-off-by: xiaolong.ran <ranxiaolong716@gmail.com>
hangc0276 pushed a commit to hangc0276/pulsar that referenced this issue May 26, 2021
Fix #16 
In KoP we would like to keep batch message. In Kafka message passed into Broker in format `Records`, each `Records` contains 1 or more `Record`. This is similar to the batched Message in Pulsar.
But because we have to turn Kafka `Records` into Pulsar BatchedMessage to make message could both be recognized by both Pulsar and Kafka client , we have to read each Record out from Records, and turn into Pulsar Message, This may involve some overhead of un-batch/re-batch. 

changes:
- move message produce/consume logic from KafkaRequestHandler.java into separate files.
- add support for batch produce/consume.
- add support for message headers.
- change offset format in MessageRecordUtils.java to support batch index.
- add test for added code.
nicoloboschi referenced this issue in nicoloboschi/pulsar Mar 22, 2022
* [tests] Add Kinesis connector integration tests

* fixup
nicoloboschi referenced this issue in nicoloboschi/pulsar Mar 23, 2022
* [tests] Add Kinesis connector integration tests

* fixup
nicoloboschi referenced this issue in nicoloboschi/pulsar Apr 12, 2022
* [tests] Add Kinesis connector integration tests

* fixup

(cherry picked from commit 3d9ece1)
tisonkun added a commit to tisonkun/pulsar that referenced this issue Jul 12, 2023
Signed-off-by: tison <wander4096@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants