List of usage examples for org.apache.commons.configuration SubsetConfiguration getBoolean
public boolean getBoolean(String key, boolean defaultValue)
From source file:org.apache.hadoop.metrics2.sink.ganglia.AbstractGangliaSink.java
public void init(SubsetConfiguration conf) { LOG.debug("Initializing the GangliaSink for Ganglia metrics."); this.conf = conf; // Take the hostname from the DNS class. if (conf.getString("slave.host.name") != null) { hostName = conf.getString("slave.host.name"); } else {/* www .j a va 2 s . co m*/ try { hostName = DNS.getDefaultHost(conf.getString("dfs.datanode.dns.interface", "default"), conf.getString("dfs.datanode.dns.nameserver", "default")); } catch (UnknownHostException uhe) { LOG.error(uhe); hostName = "UNKNOWN.example.com"; } } // load the gannglia servers from properties metricsServers = Servers.parse(conf.getString(SERVERS_PROPERTY), DEFAULT_PORT); // extract the Ganglia conf per metrics gangliaConfMap = new HashMap<String, GangliaConf>(); loadGangliaConf(GangliaConfType.units); loadGangliaConf(GangliaConfType.tmax); loadGangliaConf(GangliaConfType.dmax); loadGangliaConf(GangliaConfType.slope); try { datagramSocket = new DatagramSocket(); } catch (SocketException se) { LOG.error(se); } // see if sparseMetrics is supported. Default is false supportSparseMetrics = conf.getBoolean(SUPPORT_SPARSE_METRICS_PROPERTY, SUPPORT_SPARSE_METRICS_DEFAULT); }
From source file:org.apache.hadoop.metrics2.sink.StatsDSink.java
@Override public void init(SubsetConfiguration conf) { // Get StatsD host configurations. final String serverHost = conf.getString(SERVER_HOST_KEY); final int serverPort = Integer.parseInt(conf.getString(SERVER_PORT_KEY)); skipHostname = conf.getBoolean(SKIP_HOSTNAME_KEY, false); if (!skipHostname) { hostName = conf.getString(HOST_NAME_KEY, null); if (null == hostName) { hostName = NetUtils.getHostname(); }// w w w . j a va2 s .c om } serviceName = conf.getString(SERVICE_NAME_KEY, null); statsd = new StatsD(serverHost, serverPort); }