Skip to content

Dump config#1160

Closed
reddycharan wants to merge 2 commits into
apache:masterfrom
reddycharan:dumpconfig
Closed

Dump config#1160
reddycharan wants to merge 2 commits into
apache:masterfrom
reddycharan:dumpconfig

Conversation

@reddycharan
Copy link
Copy Markdown
Contributor

Descriptions of the changes in this PR:

Dump config

  • add utility method to AbstractConfiguration to return config as string and log it
  • dump the config during the start of the BookieServer

- add utility method to AbstractConfiguration to return config as string and log it
- dump the config during the start of the BookieServer
* @param separator
* separator to separate the configs in string
*/
public String configAsString(String separator) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

http configuration service is also dumping config. can we reuse (or consolidate) the logic of these two places.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

not sure what you are referring to? where is Http configuration used and how it can be reused?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this is what I am referring to : https://github.com/apache/bookkeeper/blob/master/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/ConfigurationService.java#L52

I was thinking of adding String asJson() in AbstractConfiguration. so it can be used in 1) configuration service and 2) logging purpose as here. that is what I was talking about consolidating the logic on how we dump the configuration. so we don't need to have multiple logic on dumping configuration.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am ok for the json version, but it can be a second change.
I have this method which dumps the config in several projects.
I have an additional use case:
I start the bookie programmatically and then I dump the actual configuration to a file so that it is possible to use bookkeeper shell commands.
So I like this function

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

well - if you are saving an configuration object to a file, you should consider using PropertiesConfiguration to save the composite configuration. commons configuration already provides extensive utils for this purpose. why do you want to reinvent this again?

I think the point here is - if we want this configuration to be dumped, it is good to have one implementation rather than multiple implementations.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

PropertiesConfiguration -> I never noticed this utility, thank you

I think having the config in JSON format inside log files is not very intuitive, but I can live with it, as far as they are "pretty printed"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

the config here is just plain key/value pairs. so there is no much difference between a properties-like format and a json format. and yes, they are pretty printed if you check this: https://github.com/apache/bookkeeper/blob/master/bookkeeper-server/src/main/java/org/apache/bookkeeper/util/JsonUtil.java#L34

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

okay for JSON for me

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ok..will add "String asJson()" in AbstractConfiguration class and will de-dupe the code.

- add utility method to AbstractConfiguration to return string representation of JSON string format of this config and log it
- de-dupe the code
Copy link
Copy Markdown
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.

+1 looks good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants