|
23 | 23 | import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_CONTAINER_COPY_WORKDIR; |
24 | 24 |
|
25 | 25 | import com.google.common.base.Preconditions; |
26 | | -import java.io.IOException; |
27 | 26 | import java.net.URL; |
28 | 27 | import java.util.ArrayList; |
29 | 28 | import java.util.Arrays; |
@@ -105,42 +104,10 @@ public static <T> T newInstanceOf(Class<T> configurationClass) { |
105 | 104 | } |
106 | 105 |
|
107 | 106 | public OzoneConfiguration() { |
108 | | - OzoneConfiguration.activate(); |
109 | | - loadDefaults(); |
110 | 107 | } |
111 | 108 |
|
112 | 109 | public OzoneConfiguration(Configuration conf) { |
113 | 110 | 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"); |
144 | 111 | } |
145 | 112 |
|
146 | 113 | public List<Property> readPropertyFromXml(URL url) throws JAXBException { |
@@ -242,10 +209,31 @@ public boolean equals(Object obj) { |
242 | 209 | } |
243 | 210 | } |
244 | 211 |
|
| 212 | + /** Add default resources. */ |
245 | 213 | 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"); |
249 | 237 | } |
250 | 238 |
|
251 | 239 | /** |
|
0 commit comments