You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "Attila Doroszlai (Jira)" <ji...@apache.org> on 2020/06/22 10:00:01 UTC

[jira] [Commented] (HDDS-2413) Set configuration variables from annotated java objects

    [ https://issues.apache.org/jira/browse/HDDS-2413?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17141877#comment-17141877 ] 

Attila Doroszlai commented on HDDS-2413:
----------------------------------------

[~elek] do you mind if I start working on this?

> Set configuration variables from annotated java objects
> -------------------------------------------------------
>
>                 Key: HDDS-2413
>                 URL: https://issues.apache.org/jira/browse/HDDS-2413
>             Project: Hadoop Distributed Data Store
>          Issue Type: Task
>            Reporter: Marton Elek
>            Assignee: Marton Elek
>            Priority: Major
>
> HDDS-1469 introduced a new method to handle configuration. Configuration can be injected directly to java objects which makes all the java constants unnecessary.
>  
> Almost.
>  
> To read the configuration it's enough to have an annotated java object. For example:
>  
> {code:java}
> @ConfigGroup(prefix = "hdds.scm")
> public class ScmConfig {
>   private String principal;
>   private String keytab;  @Config(key = "kerberos.principal",
>         type = ConfigType.STRING,
>         defaultValue = "",
>         tags = { ConfigTag.SECURITY, ConfigTag.OZONE },
>         description = "This Kerberos principal is used by the SCM service."
>   )
>   public void setKerberosPrincipal(String kerberosPrincipal) {
>     this.principal = kerberosPrincipal; {code}
> And the configuration can be set in ozone-site.xml
> Unfortunately during the unit testing we need to inject the configuration variables programmatically which requires a String constant:
> {code:java}
> configuration.set(ScmConfig.ConfigStrings.HDDS_SCM_KERBEROS_PRINCIPAL_KEY,      
>             "scm/" + host + "@" + realm); {code}
> I propose to implement a simple setter in the OzoneConfiguration which may help to set configuration based on an annotated configuration object instance:
> {code:java}
> OzoneConfiguration conf = new OzoneConfiguration();
> SCMHTTPServerConfig httpConfig = SCMHTTPServerConfig(principal1,...);
> conf.setFromObject(httpConfig){code}
> This is the opposite direction of the existing OzoneConfiguration.getObject() and can be implemented with a similar approach.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: ozone-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: ozone-issues-help@hadoop.apache.org