org.apache.hadoop.metrics.spi.AbstractMetricsContext.MetricMap Java Examples

The following examples show how to use org.apache.hadoop.metrics.spi.AbstractMetricsContext.MetricMap. 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: MetricsServlet.java    From hadoop with Apache License 2.0 6 votes vote down vote up
/**
 * Collects all metric data, and returns a map:
 *   contextName -> recordName -> [ (tag->tagValue), (metric->metricValue) ].
 * The values are either String or Number.  The final value is implemented
 * as a list of TagsMetricsPair.
 */
 Map<String, Map<String, List<TagsMetricsPair>>> makeMap(
     Collection<MetricsContext> contexts) throws IOException {
  Map<String, Map<String, List<TagsMetricsPair>>> map = 
    new TreeMap<String, Map<String, List<TagsMetricsPair>>>();

  for (MetricsContext context : contexts) {
    Map<String, List<TagsMetricsPair>> records = 
      new TreeMap<String, List<TagsMetricsPair>>();
    map.put(context.getContextName(), records);
  
    for (Map.Entry<String, Collection<OutputRecord>> r : 
        context.getAllRecords().entrySet()) {
      List<TagsMetricsPair> metricsAndTags = 
        new ArrayList<TagsMetricsPair>();
      records.put(r.getKey(), metricsAndTags);
      for (OutputRecord outputRecord : r.getValue()) {
        TagMap tagMap = outputRecord.getTagsCopy();
        MetricMap metricMap = outputRecord.getMetricsCopy();
        metricsAndTags.add(new TagsMetricsPair(tagMap, metricMap));
      }
    }
  }
  return map;
}
 
Example #2
Source File: MetricsServlet.java    From big-c with Apache License 2.0 6 votes vote down vote up
/**
 * Collects all metric data, and returns a map:
 *   contextName -> recordName -> [ (tag->tagValue), (metric->metricValue) ].
 * The values are either String or Number.  The final value is implemented
 * as a list of TagsMetricsPair.
 */
 Map<String, Map<String, List<TagsMetricsPair>>> makeMap(
     Collection<MetricsContext> contexts) throws IOException {
  Map<String, Map<String, List<TagsMetricsPair>>> map = 
    new TreeMap<String, Map<String, List<TagsMetricsPair>>>();

  for (MetricsContext context : contexts) {
    Map<String, List<TagsMetricsPair>> records = 
      new TreeMap<String, List<TagsMetricsPair>>();
    map.put(context.getContextName(), records);
  
    for (Map.Entry<String, Collection<OutputRecord>> r : 
        context.getAllRecords().entrySet()) {
      List<TagsMetricsPair> metricsAndTags = 
        new ArrayList<TagsMetricsPair>();
      records.put(r.getKey(), metricsAndTags);
      for (OutputRecord outputRecord : r.getValue()) {
        TagMap tagMap = outputRecord.getTagsCopy();
        MetricMap metricMap = outputRecord.getMetricsCopy();
        metricsAndTags.add(new TagsMetricsPair(tagMap, metricMap));
      }
    }
  }
  return map;
}
 
Example #3
Source File: MetricsServlet.java    From RDFS with Apache License 2.0 6 votes vote down vote up
/**
 * Collects all metric data, and returns a map:
 *   contextName -> recordName -> [ (tag->tagValue), (metric->metricValue) ].
 * The values are either String or Number.  The final value is implemented
 * as a list of TagsMetricsPair.
 */
 Map<String, Map<String, List<TagsMetricsPair>>> makeMap(
     Collection<MetricsContext> contexts) throws IOException {
  Map<String, Map<String, List<TagsMetricsPair>>> map = 
    new TreeMap<String, Map<String, List<TagsMetricsPair>>>();

  for (MetricsContext context : contexts) {
    Map<String, List<TagsMetricsPair>> records = 
      new TreeMap<String, List<TagsMetricsPair>>();
    map.put(context.getContextName(), records);
  
    for (Map.Entry<String, Collection<OutputRecord>> r : 
        context.getAllRecords().entrySet()) {
      List<TagsMetricsPair> metricsAndTags = 
        new ArrayList<TagsMetricsPair>();
      records.put(r.getKey(), metricsAndTags);
      for (OutputRecord outputRecord : r.getValue()) {
        TagMap tagMap = outputRecord.getTagsCopy();
        MetricMap metricMap = outputRecord.getMetricsCopy();
        metricsAndTags.add(new TagsMetricsPair(tagMap, metricMap));
      }
    }
  }
  return map;
}
 
Example #4
Source File: TestOutputRecord.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public void testCopy() {
  TagMap tags = new TagMap();
  tags.put("tagkey", "tagval");
  MetricMap metrics = new MetricMap();
  metrics.put("metrickey", 123.4);
  OutputRecord r = new OutputRecord(tags, metrics);
  
  assertEquals(tags, r.getTagsCopy());    
  assertNotSame(tags, r.getTagsCopy());
  assertEquals(metrics, r.getMetricsCopy());
  assertNotSame(metrics, r.getMetricsCopy());
}
 
Example #5
Source File: TestOutputRecord.java    From big-c with Apache License 2.0 5 votes vote down vote up
public void testCopy() {
  TagMap tags = new TagMap();
  tags.put("tagkey", "tagval");
  MetricMap metrics = new MetricMap();
  metrics.put("metrickey", 123.4);
  OutputRecord r = new OutputRecord(tags, metrics);
  
  assertEquals(tags, r.getTagsCopy());    
  assertNotSame(tags, r.getTagsCopy());
  assertEquals(metrics, r.getMetricsCopy());
  assertNotSame(metrics, r.getMetricsCopy());
}
 
Example #6
Source File: TestOutputRecord.java    From RDFS with Apache License 2.0 5 votes vote down vote up
public void testCopy() {
  TagMap tags = new TagMap();
  tags.put("tagkey", "tagval");
  MetricMap metrics = new MetricMap();
  metrics.put("metrickey", 123.4);
  OutputRecord r = new OutputRecord(tags, metrics);
  
  assertEquals(tags, r.getTagsCopy());    
  assertNotSame(tags, r.getTagsCopy());
  assertEquals(metrics, r.getMetricsCopy());
  assertNotSame(metrics, r.getMetricsCopy());
}
 
Example #7
Source File: OutputRecord.java    From hadoop with Apache License 2.0 4 votes vote down vote up
/** Creates a new instance of OutputRecord */
OutputRecord(TagMap tagMap, MetricMap metricMap) {
  this.tagMap = tagMap;
  this.metricMap = metricMap;
}
 
Example #8
Source File: OutputRecord.java    From hadoop with Apache License 2.0 4 votes vote down vote up
/**
 * Returns a copy of this record's metrics.
 */
public MetricMap getMetricsCopy() {
  return new MetricMap(metricMap);
}
 
Example #9
Source File: MetricsServlet.java    From hadoop with Apache License 2.0 4 votes vote down vote up
public TagsMetricsPair(TagMap tagMap, MetricMap metricMap) {
  this.tagMap = tagMap;
  this.metricMap = metricMap;
}
 
Example #10
Source File: OutputRecord.java    From big-c with Apache License 2.0 4 votes vote down vote up
/** Creates a new instance of OutputRecord */
OutputRecord(TagMap tagMap, MetricMap metricMap) {
  this.tagMap = tagMap;
  this.metricMap = metricMap;
}
 
Example #11
Source File: OutputRecord.java    From big-c with Apache License 2.0 4 votes vote down vote up
/**
 * Returns a copy of this record's metrics.
 */
public MetricMap getMetricsCopy() {
  return new MetricMap(metricMap);
}
 
Example #12
Source File: MetricsServlet.java    From big-c with Apache License 2.0 4 votes vote down vote up
public TagsMetricsPair(TagMap tagMap, MetricMap metricMap) {
  this.tagMap = tagMap;
  this.metricMap = metricMap;
}
 
Example #13
Source File: OutputRecord.java    From RDFS with Apache License 2.0 4 votes vote down vote up
/** Creates a new instance of OutputRecord */
OutputRecord(TagMap tagMap, MetricMap metricMap) {
  this.tagMap = tagMap;
  this.metricMap = metricMap;
}
 
Example #14
Source File: OutputRecord.java    From RDFS with Apache License 2.0 4 votes vote down vote up
/**
 * Returns a copy of this record's metrics.
 */
public MetricMap getMetricsCopy() {
  return new MetricMap(metricMap);
}
 
Example #15
Source File: MetricsServlet.java    From RDFS with Apache License 2.0 4 votes vote down vote up
public TagsMetricsPair(TagMap tagMap, MetricMap metricMap) {
  this.tagMap = tagMap;
  this.metricMap = metricMap;
}
 
Example #16
Source File: OutputRecord.java    From hadoop-gpu with Apache License 2.0 4 votes vote down vote up
/** Creates a new instance of OutputRecord */
OutputRecord(TagMap tagMap, MetricMap metricMap) {
  this.tagMap = tagMap;
  this.metricMap = metricMap;
}