本文整理了Java中org.apache.hadoop.metrics2.lib.MetricsRegistry.get()
方法的一些代码示例,展示了MetricsRegistry.get()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MetricsRegistry.get()
方法的具体详情如下:
包路径:org.apache.hadoop.metrics2.lib.MetricsRegistry
类名称:MetricsRegistry
方法名:get
[英]Get a metric by name
[中]按名称获取度量
代码示例来源:origin: org.apache.hadoop/hadoop-aws
/**
* Look up a metric from both the registered set and the lighter weight
* stream entries.
* @param name metric name
* @return the metric or null
*/
public MutableMetric lookupMetric(String name) {
MutableMetric metric = getRegistry().get(name);
return metric;
}
代码示例来源:origin: com.github.jiayuhan-it/hadoop-common
/**
* Test various factory methods
*/
@Test public void testNewMetrics() {
final MetricsRegistry r = new MetricsRegistry("test");
r.newCounter("c1", "c1 desc", 1);
r.newCounter("c2", "c2 desc", 2L);
r.newGauge("g1", "g1 desc", 3);
r.newGauge("g2", "g2 desc", 4L);
r.newStat("s1", "s1 desc", "ops", "time");
assertEquals("num metrics in registry", 5, r.metrics().size());
assertTrue("c1 found", r.get("c1") instanceof MutableCounterInt);
assertTrue("c2 found", r.get("c2") instanceof MutableCounterLong);
assertTrue("g1 found", r.get("g1") instanceof MutableGaugeInt);
assertTrue("g2 found", r.get("g2") instanceof MutableGaugeLong);
assertTrue("s1 found", r.get("s1") instanceof MutableStat);
expectMetricsException("Metric name c1 already exists", new Runnable() {
@Override
public void run() { r.newCounter("c1", "test dup", 0); }
});
}
代码示例来源:origin: ch.cern.hadoop/hadoop-common
/**
* Test various factory methods
*/
@Test public void testNewMetrics() {
final MetricsRegistry r = new MetricsRegistry("test");
r.newCounter("c1", "c1 desc", 1);
r.newCounter("c2", "c2 desc", 2L);
r.newGauge("g1", "g1 desc", 3);
r.newGauge("g2", "g2 desc", 4L);
r.newStat("s1", "s1 desc", "ops", "time");
assertEquals("num metrics in registry", 5, r.metrics().size());
assertTrue("c1 found", r.get("c1") instanceof MutableCounterInt);
assertTrue("c2 found", r.get("c2") instanceof MutableCounterLong);
assertTrue("g1 found", r.get("g1") instanceof MutableGaugeInt);
assertTrue("g2 found", r.get("g2") instanceof MutableGaugeLong);
assertTrue("s1 found", r.get("s1") instanceof MutableStat);
expectMetricsException("Metric name c1 already exists", new Runnable() {
@Override
public void run() { r.newCounter("c1", "test dup", 0); }
});
}
代码示例来源:origin: ch.cern.hadoop/hadoop-common
MutableStat s2 = (MutableStat) registry.get("s2");
代码示例来源:origin: com.github.jiayuhan-it/hadoop-common
MutableStat s2 = (MutableStat) registry.get("s2");
代码示例来源:origin: com.github.jiayuhan-it/hadoop-common
/**
* Test the add by name method
*/
@Test public void testAddByName() {
MetricsRecordBuilder rb = mockMetricsRecordBuilder();
final MetricsRegistry r = new MetricsRegistry("test");
r.add("s1", 42);
r.get("s1").snapshot(rb);
verify(rb).addCounter(info("S1NumOps", "Number of ops for s1"), 1L);
verify(rb).addGauge(info("S1AvgTime", "Average time for s1"), 42.0);
r.newCounter("c1", "test add", 1);
r.newGauge("g1", "test add", 1);
expectMetricsException("Unsupported add", new Runnable() {
@Override
public void run() { r.add("c1", 42); }
});
expectMetricsException("Unsupported add", new Runnable() {
@Override
public void run() { r.add("g1", 42); }
});
}
代码示例来源:origin: ch.cern.hadoop/hadoop-common
/**
* Test the add by name method
*/
@Test public void testAddByName() {
MetricsRecordBuilder rb = mockMetricsRecordBuilder();
final MetricsRegistry r = new MetricsRegistry("test");
r.add("s1", 42);
r.get("s1").snapshot(rb);
verify(rb).addCounter(info("S1NumOps", "Number of ops for s1"), 1L);
verify(rb).addGauge(info("S1AvgTime", "Average time for s1"), 42.0);
r.newCounter("c1", "test add", 1);
r.newGauge("g1", "test add", 1);
expectMetricsException("Unsupported add", new Runnable() {
@Override
public void run() { r.add("c1", 42); }
});
expectMetricsException("Unsupported add", new Runnable() {
@Override
public void run() { r.add("g1", 42); }
});
}
内容来源于网络,如有侵权,请联系作者删除!