use of org.apache.hadoop.metrics2.MetricsInfo in project hbase by apache.
the class DynamicMetricsRegistry method tag.
/**
* Add a tag to the metrics
* @param info metadata of the tag
* @param value of the tag
* @param override existing tag if true
* @return the registry (for keep adding tags etc.)
*/
public DynamicMetricsRegistry tag(MetricsInfo info, String value, boolean override) {
MetricsTag tag = Interns.tag(info, value);
if (!override) {
MetricsTag existing = tagsMap.putIfAbsent(info.name(), tag);
if (existing != null) {
throw new MetricsException("Tag " + info.name() + " already exists!");
}
return this;
}
tagsMap.put(info.name(), tag);
return this;
}
use of org.apache.hadoop.metrics2.MetricsInfo in project hbase by apache.
the class HBaseMetrics2HadoopMetricsAdapter method addGauge.
private void addGauge(String name, Gauge<?> gauge, MetricsRecordBuilder builder) {
final MetricsInfo info = Interns.info(name, EMPTY_STRING);
final Object o = gauge.getValue();
// Figure out which gauge types metrics2 supports and call the right method
if (o instanceof Integer) {
builder.addGauge(info, (int) o);
} else if (o instanceof Long) {
builder.addGauge(info, (long) o);
} else if (o instanceof Float) {
builder.addGauge(info, (float) o);
} else if (o instanceof Double) {
builder.addGauge(info, (double) o);
} else {
LOG.warn("Ignoring Gauge (" + name + ") with unhandled type: " + o.getClass());
}
}
use of org.apache.hadoop.metrics2.MetricsInfo in project hbase by apache.
the class HBaseMetrics2HadoopMetricsAdapter method addCounter.
private void addCounter(String name, Counter counter, MetricsRecordBuilder builder) {
MetricsInfo info = Interns.info(name, EMPTY_STRING);
builder.addCounter(info, counter.getCount());
}
use of org.apache.hadoop.metrics2.MetricsInfo in project hbase by apache.
the class Interns method info.
/**
* Get a metric info object
*
* @return an interned metric info object
*/
public static MetricsInfo info(String name, String description) {
Map<String, MetricsInfo> map = infoCache.getUnchecked(name);
MetricsInfo info = map.get(description);
if (info == null) {
info = new MetricsInfoImpl(name, description);
map.put(description, info);
}
return info;
}
use of org.apache.hadoop.metrics2.MetricsInfo in project hbase by apache.
the class Interns method tag.
/**
* Get a metrics tag
*
* @param info of the tag
* @param value of the tag
* @return an interned metrics tag
*/
public static MetricsTag tag(MetricsInfo info, String value) {
Map<String, MetricsTag> map = tagCache.getUnchecked(info);
MetricsTag tag = map.get(value);
if (tag == null) {
tag = new MetricsTag(info, value);
map.put(value, tag);
}
return tag;
}
Aggregations