-
Notifications
You must be signed in to change notification settings - Fork 587
HDDS-12777. Use module-specific name for generated config files #8475
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
Changes from 4 commits
304775d
9471bba
9d210c7
41eab9e
1e8145a
d9ab1a9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,7 +23,6 @@ | |
| import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_CONTAINER_COPY_WORKDIR; | ||
|
|
||
| import com.google.common.base.Preconditions; | ||
| import java.io.IOException; | ||
| import java.net.URL; | ||
| import java.util.ArrayList; | ||
| import java.util.Arrays; | ||
|
|
@@ -105,42 +104,10 @@ public static <T> T newInstanceOf(Class<T> configurationClass) { | |
| } | ||
|
|
||
| public OzoneConfiguration() { | ||
| OzoneConfiguration.activate(); | ||
| loadDefaults(); | ||
| } | ||
|
|
||
| public OzoneConfiguration(Configuration conf) { | ||
| super(conf); | ||
| //load the configuration from the classloader of the original conf. | ||
| setClassLoader(conf.getClassLoader()); | ||
| if (!(conf instanceof OzoneConfiguration)) { | ||
| loadDefaults(); | ||
| addResource(conf); | ||
| } | ||
| } | ||
|
|
||
| private void loadDefaults() { | ||
| try { | ||
| //there could be multiple ozone-default-generated.xml files on the | ||
| // classpath, which are generated by the annotation processor. | ||
| // Here we add all of them to the list of the available configuration. | ||
| Enumeration<URL> generatedDefaults = | ||
| OzoneConfiguration.class.getClassLoader().getResources( | ||
| "ozone-default-generated.xml"); | ||
| while (generatedDefaults.hasMoreElements()) { | ||
| addResource(generatedDefaults.nextElement()); | ||
| } | ||
| } catch (IOException e) { | ||
| e.printStackTrace(); | ||
| } | ||
| addResource("ozone-default.xml"); | ||
| // Adding core-site here because properties from core-site are | ||
| // distributed to executors by spark driver. Ozone properties which are | ||
| // added to core-site, will be overridden by properties from adding Resource | ||
| // ozone-default.xml. So, adding core-site again will help to resolve | ||
| // this override issue. | ||
| addResource("core-site.xml"); | ||
| addResource("ozone-site.xml"); | ||
| } | ||
|
|
||
| public List<Property> readPropertyFromXml(URL url) throws JAXBException { | ||
|
|
@@ -242,10 +209,25 @@ public boolean equals(Object obj) { | |
| } | ||
| } | ||
|
|
||
| /** Add default resources. */ | ||
| public static void activate() { | ||
| // adds the default resources | ||
| Configuration.addDefaultResource("hdfs-default.xml"); | ||
| Configuration.addDefaultResource("hdfs-site.xml"); | ||
| // core-default and core-site are added by parent class | ||
| addDefaultResource("hdfs-default.xml"); | ||
| addDefaultResource("hdfs-site.xml"); | ||
|
|
||
| // One generated file per module | ||
| addDefaultResource("hdds-common-default.xml"); | ||
|
||
| addDefaultResource("hdds-client-default.xml"); | ||
| addDefaultResource("hdds-container-service-default.xml"); | ||
| addDefaultResource("hdds-server-framework-default.xml"); | ||
| addDefaultResource("hdds-server-scm-default.xml"); | ||
| addDefaultResource("ozone-common-default.xml"); | ||
| addDefaultResource("ozone-manager-default.xml"); | ||
| addDefaultResource("ozone-recon-default.xml"); | ||
|
|
||
| // Non-generated configs | ||
| addDefaultResource("ozone-default.xml"); | ||
| addDefaultResource("ozone-site.xml"); | ||
| } | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -334,6 +334,20 @@ | |
|
|
||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>com.coderplus.maven.plugins</groupId> | ||
| <artifactId>copy-rename-maven-plugin</artifactId> | ||
| <executions> | ||
| <execution> | ||
| <id>rename-generated-config</id> | ||
| <phase>process-classes</phase> | ||
| </execution> | ||
| <execution> | ||
| <id>rename-generated-test-config</id> | ||
| <phase>process-test-classes</phase> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the two modules, famework and common, who has this extra "process-test-classes", will both the two generated xml files be loaded during OzoneConfiguration activation?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The config file for test is created in |
||
| </execution> | ||
| </executions> | ||
| </plugin> | ||
| <plugin> | ||
| <groupId>com.github.spotbugs</groupId> | ||
| <artifactId>spotbugs-maven-plugin</artifactId> | ||
|
|
||
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.
@adoroszlai have checked the above comment why we added again core-site.xml here? Just wanted to make sure we are not skipping anything!
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.
@umamaheswararao Please see the "Remove the hack introduced by HDDS-3871" point in PR description.
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.
Thanks @adoroszlai for pointing it.