Java Code Examples for org.apache.commons.configuration.SubsetConfiguration#getString()

The following examples show how to use org.apache.commons.configuration.SubsetConfiguration#getString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GraphiteSink.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public void init(SubsetConfiguration conf) {
    // Get Graphite host configurations.
    final String serverHost = conf.getString(SERVER_HOST_KEY);
    final int serverPort = Integer.parseInt(conf.getString(SERVER_PORT_KEY));

    // Get Graphite metrics graph prefix.
    metricsPrefix = conf.getString(METRICS_PREFIX);
    if (metricsPrefix == null)
        metricsPrefix = "";

    graphite = new Graphite(serverHost, serverPort);
    graphite.connect();
}
 
Example 2
Source File: FileSink.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public void init(SubsetConfiguration conf) {
  String filename = conf.getString(FILENAME_KEY);
  try {
    writer = filename == null ? System.out
        : new PrintStream(new FileOutputStream(new File(filename)),
                          true, "UTF-8");
  } catch (Exception e) {
    throw new MetricsException("Error creating "+ filename, e);
  }
}
 
Example 3
Source File: GraphiteSink.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public void init(SubsetConfiguration conf) {
    // Get Graphite host configurations.
    final String serverHost = conf.getString(SERVER_HOST_KEY);
    final int serverPort = Integer.parseInt(conf.getString(SERVER_PORT_KEY));

    // Get Graphite metrics graph prefix.
    metricsPrefix = conf.getString(METRICS_PREFIX);
    if (metricsPrefix == null)
        metricsPrefix = "";

    graphite = new Graphite(serverHost, serverPort);
    graphite.connect();
}
 
Example 4
Source File: FileSink.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public void init(SubsetConfiguration conf) {
  String filename = conf.getString(FILENAME_KEY);
  try {
    writer = filename == null ? System.out
        : new PrintStream(new FileOutputStream(new File(filename)),
                          true, "UTF-8");
  } catch (Exception e) {
    throw new MetricsException("Error creating "+ filename, e);
  }
}
 
Example 5
Source File: AbstractGangliaSink.java    From hadoop with Apache License 2.0 4 votes vote down vote up
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 {
    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);
  multicastEnabled = conf.getBoolean(MULTICAST_ENABLED_PROPERTY,
          DEFAULT_MULTICAST_ENABLED);
  multicastTtl = conf.getInt(MULTICAST_TTL_PROPERTY, DEFAULT_MULTICAST_TTL);

  // extract the Ganglia conf per metrics
  gangliaConfMap = new HashMap<String, GangliaConf>();
  loadGangliaConf(GangliaConfType.units);
  loadGangliaConf(GangliaConfType.tmax);
  loadGangliaConf(GangliaConfType.dmax);
  loadGangliaConf(GangliaConfType.slope);

  try {
    if (multicastEnabled) {
      LOG.info("Enabling multicast for Ganglia with TTL " + multicastTtl);
      datagramSocket = new MulticastSocket();
      ((MulticastSocket) datagramSocket).setTimeToLive(multicastTtl);
    } else {
      datagramSocket = new DatagramSocket();
    }
  } catch (IOException e) {
    LOG.error(e);
  }

  // see if sparseMetrics is supported. Default is false
  supportSparseMetrics = conf.getBoolean(SUPPORT_SPARSE_METRICS_PROPERTY,
      SUPPORT_SPARSE_METRICS_DEFAULT);
}
 
Example 6
Source File: AbstractGangliaSink.java    From big-c with Apache License 2.0 4 votes vote down vote up
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 {
    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);
  multicastEnabled = conf.getBoolean(MULTICAST_ENABLED_PROPERTY,
          DEFAULT_MULTICAST_ENABLED);
  multicastTtl = conf.getInt(MULTICAST_TTL_PROPERTY, DEFAULT_MULTICAST_TTL);

  // extract the Ganglia conf per metrics
  gangliaConfMap = new HashMap<String, GangliaConf>();
  loadGangliaConf(GangliaConfType.units);
  loadGangliaConf(GangliaConfType.tmax);
  loadGangliaConf(GangliaConfType.dmax);
  loadGangliaConf(GangliaConfType.slope);

  try {
    if (multicastEnabled) {
      LOG.info("Enabling multicast for Ganglia with TTL " + multicastTtl);
      datagramSocket = new MulticastSocket();
      ((MulticastSocket) datagramSocket).setTimeToLive(multicastTtl);
    } else {
      datagramSocket = new DatagramSocket();
    }
  } catch (IOException e) {
    LOG.error(e);
  }

  // see if sparseMetrics is supported. Default is false
  supportSparseMetrics = conf.getBoolean(SUPPORT_SPARSE_METRICS_PROPERTY,
      SUPPORT_SPARSE_METRICS_DEFAULT);
}