use of org.apache.hadoop.metrics2.MetricsInfo in project hadoop by apache.
the class MetricsSystemImpl method register.
@Override
public synchronized <T> T register(String name, String desc, T source) {
MetricsSourceBuilder sb = MetricsAnnotations.newSourceBuilder(source);
final MetricsSource s = sb.build();
MetricsInfo si = sb.info();
String name2 = name == null ? si.name() : name;
final String finalDesc = desc == null ? si.description() : desc;
final // be friendly to non-metrics tests
String finalName = DefaultMetricsSystem.sourceName(name2, !monitoring);
allSources.put(finalName, s);
LOG.debug(finalName + ", " + finalDesc);
if (monitoring) {
registerSource(finalName, finalDesc, s);
}
// We want to re-register the source to pick up new config when the
// metrics system restarts.
register(finalName, new AbstractCallback() {
@Override
public void postStart() {
registerSource(finalName, finalDesc, s);
}
});
return source;
}
use of org.apache.hadoop.metrics2.MetricsInfo in project hadoop by apache.
the class StartupProgressMetrics method addCounter.
/**
* Adds a counter with a name built by using the specified phase's name as
* prefix and then appending the specified suffix.
*
* @param builder MetricsRecordBuilder to receive counter
* @param phase Phase to add
* @param nameSuffix String suffix of metric name
* @param descSuffix String suffix of metric description
* @param value long counter value
*/
private static void addCounter(MetricsRecordBuilder builder, Phase phase, String nameSuffix, String descSuffix, long value) {
MetricsInfo metricsInfo = info(phase.getName() + nameSuffix, phase.getDescription() + descSuffix);
builder.addCounter(metricsInfo, value);
}
use of org.apache.hadoop.metrics2.MetricsInfo in project hadoop by apache.
the class StartupProgressMetrics method addGauge.
/**
* Adds a gauge with a name built by using the specified phase's name as prefix
* and then appending the specified suffix.
*
* @param builder MetricsRecordBuilder to receive counter
* @param phase Phase to add
* @param nameSuffix String suffix of metric name
* @param descSuffix String suffix of metric description
* @param value float gauge value
*/
private static void addGauge(MetricsRecordBuilder builder, Phase phase, String nameSuffix, String descSuffix, float value) {
MetricsInfo metricsInfo = info(phase.getName() + nameSuffix, phase.getDescription() + descSuffix);
builder.addGauge(metricsInfo, value);
}
use of org.apache.hadoop.metrics2.MetricsInfo in project hadoop by apache.
the class TestInterns method testInfoOverflow.
@Test
public void testInfoOverflow() {
MetricsInfo i0 = info("m0", "m desc");
for (int i = 0; i < MAX_INFO_NAMES + 1; ++i) {
info("m" + i, "m desc");
if (i < MAX_INFO_NAMES) {
assertSame("m0 is still there", i0, info("m0", "m desc"));
}
}
assertNotSame("m0 is gone", i0, info("m0", "m desc"));
MetricsInfo i1 = info("m1", "m desc");
for (int i = 0; i < MAX_INFO_DESCS; ++i) {
info("m1", "m desc" + i);
if (i < MAX_INFO_DESCS - 1) {
assertSame("i1 is still there", i1, info("m1", "m desc"));
}
}
assertNotSame("i1 is gone", i1, info("m1", "m desc"));
}
use of org.apache.hadoop.metrics2.MetricsInfo in project hadoop by apache.
the class TestInterns method testInfo.
@Test
public void testInfo() {
MetricsInfo info = info("m", "m desc");
assertSame("same info", info, info("m", "m desc"));
}
Aggregations