Marton Elek created HDDS-2413: --------------------------------- Summary: 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
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: hdfs-dev-unsubscr...@hadoop.apache.org For additional commands, e-mail: hdfs-dev-h...@hadoop.apache.org