1/*2 * Licensed to the Apache Software Foundation (ASF) under one3 * or more contributor license agreements. See the NOTICE file4 * distributed with this work for additional information5 * regarding copyright ownership. The ASF licenses this file6 * to you under the Apache License, Version 2.0 (the7 * "License"); you may not use this file except in compliance8 * with the License. You may obtain a copy of the License at9 *10 * http://www.apache.org/licenses/LICENSE-2.011 *12 * Unless required by applicable law or agreed to in writing, software13 * distributed under the License is distributed on an "AS IS" BASIS,14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.15 * See the License for the specific language governing permissions and16 * limitations under the License.17 */1819package org.apache.hadoop.chukwa.conf;
202122import java.io.File;
23import org.apache.hadoop.conf.Configuration;
24import org.apache.hadoop.fs.Path;
25import org.apache.log4j.Logger;
2627publicclassChukwaConfigurationextends Configuration {
28static Logger log = Logger.getLogger(ChukwaConfiguration.class);
2930private String chukwaHome, chukwaConf;
3132public String getChukwaHome() {
33return chukwaHome;
34 }
3536public String getChukwaConf() {
37return chukwaConf;
38 }
3940publicChukwaConfiguration() {
41this(true);
42 }
4344publicChukwaConfiguration(boolean loadDefaults) {
45super();
46if (loadDefaults) {
4748 chukwaHome = System.getenv("CHUKWA_HOME");
49if (chukwaHome == null) {
50 chukwaHome = ".";
51 }
5253if (!chukwaHome.endsWith("/")) {
54 chukwaHome = chukwaHome + File.separator;
55 }
56 chukwaConf = System.getenv("CHUKWA_CONF_DIR");
57if (chukwaConf == null) {
58 chukwaConf = chukwaHome + "conf" + File.separator;
59 }
6061 log.info("chukwaConf is " + chukwaConf);
6263super.addResource(new Path(chukwaConf + "/chukwa-common.xml"));
64 log.debug("added chukwa-agent-conf.xml to ChukwaConfiguration");
6566super.addResource(new Path(chukwaConf + "/chukwa-agent-conf.xml"));
67 log.debug("added chukwa-agent-conf.xml to ChukwaConfiguration");
6869super.addResource(new Path(chukwaConf + "/chukwa-collector-conf.xml"));
70 log.debug("added chukwa-collector-conf.xml to ChukwaConfiguration");
7172super.addResource(new Path(chukwaConf + "/chukwa-demux-conf.xml"));
73 log.debug("added chukwa-demux-conf.xml to ChukwaConfiguration");
74 }
75 }
7677 }