Java Code Examples for org.apache.hadoop.metrics.spi.NoEmitMetricsContext

The following examples show how to use org.apache.hadoop.metrics.spi.NoEmitMetricsContext. These examples are extracted from open source projects. 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 Project: hadoop   Source File: TestMetricsServlet.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Initializes, for testing, two NoEmitMetricsContext's, and adds one value 
 * to the first of them.
 */
@Override
public void setUp() throws IOException {
  nc1 = new NoEmitMetricsContext();
  nc1.init("test1", ContextFactory.getFactory());
  nc2 = new NoEmitMetricsContext();
  nc2.init("test2", ContextFactory.getFactory());
  contexts = new ArrayList<MetricsContext>();
  contexts.add(nc1);
  contexts.add(nc2);

  MetricsRecord r = nc1.createRecord("testRecord");
  
  r.setTag("testTag1", "testTagValue1");
  r.setTag("testTag2", "testTagValue2");
  r.setMetric("testMetric1", 1);
  r.setMetric("testMetric2", 33);
  r.update();

  Map<String, Collection<OutputRecord>> m = nc1.getAllRecords();
  assertEquals(1, m.size());
  assertEquals(1, m.values().size());
  Collection<OutputRecord> outputRecords = m.values().iterator().next();
  assertEquals(1, outputRecords.size());
  outputRecord = outputRecords.iterator().next();
}
 
Example 2
Source Project: big-c   Source File: TestMetricsServlet.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Initializes, for testing, two NoEmitMetricsContext's, and adds one value 
 * to the first of them.
 */
@Override
public void setUp() throws IOException {
  nc1 = new NoEmitMetricsContext();
  nc1.init("test1", ContextFactory.getFactory());
  nc2 = new NoEmitMetricsContext();
  nc2.init("test2", ContextFactory.getFactory());
  contexts = new ArrayList<MetricsContext>();
  contexts.add(nc1);
  contexts.add(nc2);

  MetricsRecord r = nc1.createRecord("testRecord");
  
  r.setTag("testTag1", "testTagValue1");
  r.setTag("testTag2", "testTagValue2");
  r.setMetric("testMetric1", 1);
  r.setMetric("testMetric2", 33);
  r.update();

  Map<String, Collection<OutputRecord>> m = nc1.getAllRecords();
  assertEquals(1, m.size());
  assertEquals(1, m.values().size());
  Collection<OutputRecord> outputRecords = m.values().iterator().next();
  assertEquals(1, outputRecords.size());
  outputRecord = outputRecords.iterator().next();
}
 
Example 3
Source Project: RDFS   Source File: TestMetricsServlet.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Initializes, for testing, two NoEmitMetricsContext's, and adds one value 
 * to the first of them.
 */
public void setUp() throws IOException {
  nc1 = new NoEmitMetricsContext();
  nc1.init("test1", ContextFactory.getFactory());
  nc2 = new NoEmitMetricsContext();
  nc2.init("test2", ContextFactory.getFactory());
  contexts = new ArrayList<MetricsContext>();
  contexts.add(nc1);
  contexts.add(nc2);

  MetricsRecord r = nc1.createRecord("testRecord");
  
  r.setTag("testTag1", "testTagValue1");
  r.setTag("testTag2", "testTagValue2");
  r.setMetric("testMetric1", 1);
  r.setMetric("testMetric2", 33);
  r.update();

  Map<String, Collection<OutputRecord>> m = nc1.getAllRecords();
  assertEquals(1, m.size());
  assertEquals(1, m.values().size());
  Collection<OutputRecord> outputRecords = m.values().iterator().next();
  assertEquals(1, outputRecords.size());
  outputRecord = outputRecords.iterator().next();
}
 
Example 4
Source Project: RDFS   Source File: MiniCoronaCluster.java    License: Apache License 2.0 4 votes vote down vote up
private void setNoEmitMetricsContext() throws IOException {
  ContextFactory factory = ContextFactory.getFactory();
  factory.setAttribute(ClusterManagerMetrics.CONTEXT_NAME + ".class",
      NoEmitMetricsContext.class.getName());
}
 
Example 5
Source Project: RDFS   Source File: ClusterManagerTestable.java    License: Apache License 2.0 4 votes vote down vote up
private void setNoEmitMetricsContext() throws IOException {
  ContextFactory factory = ContextFactory.getFactory();
  factory.setAttribute(ClusterManagerMetrics.CONTEXT_NAME + ".class",
      NoEmitMetricsContext.class.getName());
}