-
Notifications
You must be signed in to change notification settings - Fork 590
HDDS-2413. Set configuration variables from annotated java objects #1106
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
Conversation
|
|
||
| char[] getPassword(String key) throws IOException; | ||
|
|
||
| @Deprecated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really don't like the approach when the current port number (after using :0) is added to the configuration. It's easier if the configuration is immutable after loading.
I understand that the immutable is not possible with this injection and I accept that it's necessary.
One possible approach is to introduce two interfaces: ConfigSource (read-only) and ConfigDestination (write only). OzoneConfiguration can implement both. But there could be a specific ConfigSource (eg. EnvironmentVariableConfigSource) which would be read only.
But I am fine with committing this patch as is, but interested about opinion.
Also: it seems to be useful for testing to introduce an OzoneConfiguration.fromAnnotatedObject() method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One possible approach is to introduce two interfaces:
ConfigSource(read-only) andConfigDestination(write only).OzoneConfigurationcan implement both.
Thanks @elek for the suggestion. I was considering this, but needed this nudge to implement it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was considering this, but needed this nudge to implement it.
Oh, I see why. It makes the patch bigger because we use this dirty hack to store the port in the config.
elek
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 thanks the update, I didn't think it's such a big change (sorry, commenting is cheap and easy ;-) )
|
Thanks @elek for reviewing and committing it. |
What changes were proposed in this pull request?
Allow setting
Configurationfrom strongly-typed config objects (ie. ones annotated with@Config). This is the opposite direction of existingConfigurationSource.getObject().One caveat is that the config object needs to be created via
getObject()for default values from annotations to be properly set.https://issues.apache.org/jira/browse/HDDS-2413
How was this patch tested?
Added unit test. Also updated a single part of "real" code where this change makes string constants unnecessary (
DUFactory.ConfandTestDUFactory).https://github.com/adoroszlai/hadoop-ozone/runs/795413474