Skip to content

Commit 64bb29d

Browse files
authored
HDDS-12777. Use module-specific name for generated config files (apache#8475)
1 parent 54ed115 commit 64bb29d

File tree

26 files changed

+191
-230
lines changed

26 files changed

+191
-230
lines changed

hadoop-hdds/client/pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,16 @@
110110

111111
<build>
112112
<plugins>
113+
<plugin>
114+
<groupId>com.coderplus.maven.plugins</groupId>
115+
<artifactId>copy-rename-maven-plugin</artifactId>
116+
<executions>
117+
<execution>
118+
<id>rename-generated-config</id>
119+
<phase>process-classes</phase>
120+
</execution>
121+
</executions>
122+
</plugin>
113123
<plugin>
114124
<groupId>com.github.spotbugs</groupId>
115125
<artifactId>spotbugs-maven-plugin</artifactId>

hadoop-hdds/common/pom.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,20 @@
268268
</execution>
269269
</executions>
270270
</plugin>
271+
<plugin>
272+
<groupId>com.coderplus.maven.plugins</groupId>
273+
<artifactId>copy-rename-maven-plugin</artifactId>
274+
<executions>
275+
<execution>
276+
<id>rename-generated-config</id>
277+
<phase>process-classes</phase>
278+
</execution>
279+
<execution>
280+
<id>rename-generated-test-config</id>
281+
<phase>process-test-classes</phase>
282+
</execution>
283+
</executions>
284+
</plugin>
271285
<plugin>
272286
<groupId>com.github.spotbugs</groupId>
273287
<artifactId>spotbugs-maven-plugin</artifactId>

hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/conf/OzoneConfiguration.java

Lines changed: 24 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_CONTAINER_COPY_WORKDIR;
2424

2525
import com.google.common.base.Preconditions;
26-
import java.io.IOException;
2726
import java.net.URL;
2827
import java.util.ArrayList;
2928
import java.util.Arrays;
@@ -105,42 +104,10 @@ public static <T> T newInstanceOf(Class<T> configurationClass) {
105104
}
106105

107106
public OzoneConfiguration() {
108-
OzoneConfiguration.activate();
109-
loadDefaults();
110107
}
111108

112109
public OzoneConfiguration(Configuration conf) {
113110
super(conf);
114-
//load the configuration from the classloader of the original conf.
115-
setClassLoader(conf.getClassLoader());
116-
if (!(conf instanceof OzoneConfiguration)) {
117-
loadDefaults();
118-
addResource(conf);
119-
}
120-
}
121-
122-
private void loadDefaults() {
123-
try {
124-
//there could be multiple ozone-default-generated.xml files on the
125-
// classpath, which are generated by the annotation processor.
126-
// Here we add all of them to the list of the available configuration.
127-
Enumeration<URL> generatedDefaults =
128-
OzoneConfiguration.class.getClassLoader().getResources(
129-
"ozone-default-generated.xml");
130-
while (generatedDefaults.hasMoreElements()) {
131-
addResource(generatedDefaults.nextElement());
132-
}
133-
} catch (IOException e) {
134-
e.printStackTrace();
135-
}
136-
addResource("ozone-default.xml");
137-
// Adding core-site here because properties from core-site are
138-
// distributed to executors by spark driver. Ozone properties which are
139-
// added to core-site, will be overridden by properties from adding Resource
140-
// ozone-default.xml. So, adding core-site again will help to resolve
141-
// this override issue.
142-
addResource("core-site.xml");
143-
addResource("ozone-site.xml");
144111
}
145112

146113
public List<Property> readPropertyFromXml(URL url) throws JAXBException {
@@ -242,10 +209,31 @@ public boolean equals(Object obj) {
242209
}
243210
}
244211

212+
/** Add default resources. */
245213
public static void activate() {
246-
// adds the default resources
247-
Configuration.addDefaultResource("hdfs-default.xml");
248-
Configuration.addDefaultResource("hdfs-site.xml");
214+
// core-default and core-site are added by parent class
215+
addDefaultResource("hdfs-default.xml");
216+
addDefaultResource("hdfs-site.xml");
217+
218+
// Modules with @Config annotations. If new one is introduced, add it to this list.
219+
String[] modules = new String[] {
220+
"hdds-common",
221+
"hdds-client",
222+
"hdds-container-service",
223+
"hdds-server-framework",
224+
"hdds-server-scm",
225+
"ozone-common",
226+
"ozone-csi",
227+
"ozone-manager",
228+
"ozone-recon",
229+
};
230+
for (String module : modules) {
231+
addDefaultResource(module + "-default.xml");
232+
}
233+
234+
// Non-generated configs
235+
addDefaultResource("ozone-default.xml");
236+
addDefaultResource("ozone-site.xml");
249237
}
250238

251239
/**

hadoop-hdds/common/src/test/java/org/apache/hadoop/hdds/conf/TestGeneratedConfigurationOverwrite.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
public class TestGeneratedConfigurationOverwrite {
3636

3737
private final Path generatedConfigurationPath =
38-
Paths.get("target/test-classes/ozone-default-generated.xml");
38+
Paths.get("target/test-classes/hdds-common-default.xml");
3939
private final Path generatedConfigurationPathBak =
40-
Paths.get("target/test-classes/ozone-default-generated.xml.bak");
40+
Paths.get("target/test-classes/hdds-common-default.xml.bak");
4141

4242
private OzoneConfiguration conf;
4343

hadoop-hdds/container-service/pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,16 @@
261261

262262
<build>
263263
<plugins>
264+
<plugin>
265+
<groupId>com.coderplus.maven.plugins</groupId>
266+
<artifactId>copy-rename-maven-plugin</artifactId>
267+
<executions>
268+
<execution>
269+
<id>rename-generated-config</id>
270+
<phase>process-classes</phase>
271+
</execution>
272+
</executions>
273+
</plugin>
264274
<plugin>
265275
<groupId>com.github.spotbugs</groupId>
266276
<artifactId>spotbugs-maven-plugin</artifactId>

hadoop-hdds/framework/pom.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,20 @@
334334

335335
<build>
336336
<plugins>
337+
<plugin>
338+
<groupId>com.coderplus.maven.plugins</groupId>
339+
<artifactId>copy-rename-maven-plugin</artifactId>
340+
<executions>
341+
<execution>
342+
<id>rename-generated-config</id>
343+
<phase>process-classes</phase>
344+
</execution>
345+
<execution>
346+
<id>rename-generated-test-config</id>
347+
<phase>process-test-classes</phase>
348+
</execution>
349+
</executions>
350+
</plugin>
337351
<plugin>
338352
<groupId>com.github.spotbugs</groupId>
339353
<artifactId>spotbugs-maven-plugin</artifactId>

hadoop-hdds/server-scm/pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,16 @@
238238
</testResource>
239239
</testResources>
240240
<plugins>
241+
<plugin>
242+
<groupId>com.coderplus.maven.plugins</groupId>
243+
<artifactId>copy-rename-maven-plugin</artifactId>
244+
<executions>
245+
<execution>
246+
<id>rename-generated-config</id>
247+
<phase>process-classes</phase>
248+
</execution>
249+
</executions>
250+
</plugin>
241251
<plugin>
242252
<groupId>org.apache.maven.plugins</groupId>
243253
<artifactId>maven-compiler-plugin</artifactId>

hadoop-ozone/client/pom.xml

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -130,40 +130,9 @@
130130
<groupId>org.apache.maven.plugins</groupId>
131131
<artifactId>maven-compiler-plugin</artifactId>
132132
<configuration>
133-
<annotationProcessorPaths>
134-
<path>
135-
<groupId>org.apache.ozone</groupId>
136-
<artifactId>hdds-config</artifactId>
137-
<version>${hdds.version}</version>
138-
</path>
139-
</annotationProcessorPaths>
140-
<annotationProcessors>
141-
<annotationProcessor>org.apache.hadoop.hdds.conf.ConfigFileGenerator</annotationProcessor>
142-
</annotationProcessors>
133+
<proc>none</proc>
143134
</configuration>
144135
</plugin>
145-
<plugin>
146-
<groupId>org.apache.maven.plugins</groupId>
147-
<artifactId>maven-enforcer-plugin</artifactId>
148-
<executions>
149-
<execution>
150-
<id>ban-annotations</id>
151-
<!-- override default restriction from root POM -->
152-
<configuration>
153-
<rules>
154-
<restrictImports>
155-
<reason>Only selected annotation processors are enabled, see configuration of maven-compiler-plugin.</reason>
156-
<bannedImports>
157-
<bannedImport>org.apache.hadoop.ozone.om.request.validation.RequestFeatureValidator</bannedImport>
158-
<bannedImport>org.apache.hadoop.hdds.scm.metadata.Replicate</bannedImport>
159-
<bannedImport>org.kohsuke.MetaInfServices</bannedImport>
160-
</bannedImports>
161-
</restrictImports>
162-
</rules>
163-
</configuration>
164-
</execution>
165-
</executions>
166-
</plugin>
167136
</plugins>
168137
</build>
169138
</project>

hadoop-ozone/common/pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,16 @@
185185
</resource>
186186
</resources>
187187
<plugins>
188+
<plugin>
189+
<groupId>com.coderplus.maven.plugins</groupId>
190+
<artifactId>copy-rename-maven-plugin</artifactId>
191+
<executions>
192+
<execution>
193+
<id>rename-generated-config</id>
194+
<phase>process-classes</phase>
195+
</execution>
196+
</executions>
197+
</plugin>
188198
<plugin>
189199
<groupId>org.apache.hadoop</groupId>
190200
<artifactId>hadoop-maven-plugins</artifactId>

hadoop-ozone/csi/pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,16 @@
195195

196196
<build>
197197
<plugins>
198+
<plugin>
199+
<groupId>com.coderplus.maven.plugins</groupId>
200+
<artifactId>copy-rename-maven-plugin</artifactId>
201+
<executions>
202+
<execution>
203+
<id>rename-generated-config</id>
204+
<phase>process-classes</phase>
205+
</execution>
206+
</executions>
207+
</plugin>
198208
<plugin>
199209
<groupId>com.salesforce.servicelibs</groupId>
200210
<artifactId>proto-backwards-compatibility</artifactId>

0 commit comments

Comments
 (0)