Java Code Examples for org.apache.hadoop.metrics.spi.OutputRecord#getMetricNames()

The following examples show how to use org.apache.hadoop.metrics.spi.OutputRecord#getMetricNames() . 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: GangliaContext.java    From RDFS with Apache License 2.0 6 votes vote down vote up
public void emitRecord(String contextName, String recordName,
  OutputRecord outRec) 
throws IOException {
  // Setup so that the records have the proper leader names so they are
  // unambiguous at the ganglia level, and this prevents a lot of rework
  StringBuilder sb = new StringBuilder();
  sb.append(contextName);
  sb.append('.');
  sb.append(recordName);
  sb.append('.');
  int sbBaseLen = sb.length();

  // emit each metric in turn
  for (String metricName : outRec.getMetricNames()) {
    Object metric = outRec.getMetric(metricName);
    String type = typeTable.get(metric.getClass());
    if (type != null) {
      sb.append(metricName);
      emitMetric(sb.toString(), type, metric.toString());
      sb.setLength(sbBaseLen);
    } else {
      LOG.warn("Unknown metrics type: " + metric.getClass());
    }
  }
}
 
Example 2
Source File: FileContext.java    From hadoop-gpu with Apache License 2.0 6 votes vote down vote up
/**
 * Emits a metrics record to a file.
 */
public void emitRecord(String contextName, String recordName, OutputRecord outRec) {
  writer.print(contextName);
  writer.print(".");
  writer.print(recordName);
  String separator = ": ";
  for (String tagName : outRec.getTagNames()) {
    writer.print(separator);
    separator = ", ";
    writer.print(tagName);
    writer.print("=");
    writer.print(outRec.getTag(tagName));
  }
  for (String metricName : outRec.getMetricNames()) {
    writer.print(separator);
    separator = ", ";
    writer.print(metricName);
    writer.print("=");
    writer.print(outRec.getMetric(metricName));
  }
  writer.println();
}
 
Example 3
Source File: GangliaContext.java    From hadoop-gpu with Apache License 2.0 6 votes vote down vote up
public void emitRecord(String contextName, String recordName,
  OutputRecord outRec) 
throws IOException {
  // Setup so that the records have the proper leader names so they are
  // unambiguous at the ganglia level, and this prevents a lot of rework
  StringBuilder sb = new StringBuilder();
  sb.append(contextName);
  sb.append('.');
  sb.append(recordName);
  sb.append('.');
  int sbBaseLen = sb.length();

  // emit each metric in turn
  for (String metricName : outRec.getMetricNames()) {
    Object metric = outRec.getMetric(metricName);
    String type = typeTable.get(metric.getClass());
    if (type != null) {
      sb.append(metricName);
      emitMetric(sb.toString(), type, metric.toString());
      sb.setLength(sbBaseLen);
    } else {
      LOG.warn("Unknown metrics type: " + metric.getClass());
    }
  }
}
 
Example 4
Source File: GangliaContext.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
@InterfaceAudience.Private
public void emitRecord(String contextName, String recordName,
  OutputRecord outRec) 
throws IOException {
  // Setup so that the records have the proper leader names so they are
  // unambiguous at the ganglia level, and this prevents a lot of rework
  StringBuilder sb = new StringBuilder();
  sb.append(contextName);
  sb.append('.');

  if (contextName.equals("jvm") && outRec.getTag("processName") != null) {
    sb.append(outRec.getTag("processName"));
    sb.append('.');
  }

  sb.append(recordName);
  sb.append('.');
  int sbBaseLen = sb.length();

  // emit each metric in turn
  for (String metricName : outRec.getMetricNames()) {
    Object metric = outRec.getMetric(metricName);
    String type = typeTable.get(metric.getClass());
    if (type != null) {
      sb.append(metricName);
      emitMetric(sb.toString(), type, metric.toString());
      sb.setLength(sbBaseLen);
    } else {
      LOG.warn("Unknown metrics type: " + metric.getClass());
    }
  }
}
 
Example 5
Source File: GangliaContext.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
@InterfaceAudience.Private
public void emitRecord(String contextName, String recordName,
  OutputRecord outRec) 
throws IOException {
  // Setup so that the records have the proper leader names so they are
  // unambiguous at the ganglia level, and this prevents a lot of rework
  StringBuilder sb = new StringBuilder();
  sb.append(contextName);
  sb.append('.');

  if (contextName.equals("jvm") && outRec.getTag("processName") != null) {
    sb.append(outRec.getTag("processName"));
    sb.append('.');
  }

  sb.append(recordName);
  sb.append('.');
  int sbBaseLen = sb.length();

  // emit each metric in turn
  for (String metricName : outRec.getMetricNames()) {
    Object metric = outRec.getMetric(metricName);
    String type = typeTable.get(metric.getClass());
    if (type != null) {
      sb.append(metricName);
      emitMetric(sb.toString(), type, metric.toString());
      sb.setLength(sbBaseLen);
    } else {
      LOG.warn("Unknown metrics type: " + metric.getClass());
    }
  }
}
 
Example 6
Source File: JMXContextMBean.java    From RDFS with Apache License 2.0 5 votes vote down vote up
public void processMetricsRecord(OutputRecord outRec) {

    for (String metricName : outRec.getMetricNames()) {
      Number metricValue = outRec.getMetric(metricName);
      metrics.put(metricName, metricValue);
    }
  }