This project has retired. For details please refer to its Attic page.
ChukwaConfiguration xref
View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * 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 and
16   * limitations under the License.
17   */
18  
19  package org.apache.hadoop.chukwa.conf;
20  
21  
22  import java.io.File;
23  import org.apache.hadoop.conf.Configuration;
24  import org.apache.hadoop.fs.Path;
25  import org.apache.log4j.Logger;
26  
27  public class ChukwaConfiguration extends Configuration {
28    static Logger log = Logger.getLogger(ChukwaConfiguration.class);
29  
30    private String chukwaHome, chukwaConf;
31    
32    public String getChukwaHome() {
33      return chukwaHome;
34    }
35    
36    public String getChukwaConf() {
37      return chukwaConf;
38    }
39    
40    public ChukwaConfiguration() {
41      this(true);
42    }
43  
44    public ChukwaConfiguration(boolean loadDefaults) {
45      super();
46      if (loadDefaults) {
47  
48        chukwaHome = System.getenv("CHUKWA_HOME");
49        if (chukwaHome == null) {
50          chukwaHome = ".";
51        }
52  
53        if (!chukwaHome.endsWith("/")) {
54          chukwaHome = chukwaHome + File.separator;
55        }
56        chukwaConf = System.getenv("CHUKWA_CONF_DIR");
57        if (chukwaConf == null) {
58          chukwaConf = chukwaHome + "conf" + File.separator;
59        }
60  
61        log.info("chukwaConf is " + chukwaConf);
62  
63        super.addResource(new Path(chukwaConf + "/chukwa-common.xml"));
64        log.debug("added chukwa-agent-conf.xml to ChukwaConfiguration");
65  
66        super.addResource(new Path(chukwaConf + "/chukwa-agent-conf.xml"));
67        log.debug("added chukwa-agent-conf.xml to ChukwaConfiguration");
68  
69        super.addResource(new Path(chukwaConf + "/chukwa-collector-conf.xml"));
70        log.debug("added chukwa-collector-conf.xml to ChukwaConfiguration");
71  
72        super.addResource(new Path(chukwaConf + "/chukwa-demux-conf.xml"));
73        log.debug("added chukwa-demux-conf.xml to ChukwaConfiguration");
74      }
75    }
76  
77  }