1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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 }