use of org.apache.hadoop.metrics2.MetricsInfo in project hive by apache.
the class JvmMetrics method getGcUsage.
private void getGcUsage(MetricsRecordBuilder rb) {
long count = 0;
long timeMillis = 0;
for (GarbageCollectorMXBean gcBean : gcBeans) {
long c = gcBean.getCollectionCount();
long t = gcBean.getCollectionTime();
MetricsInfo[] gcInfo = getGcInfo(gcBean.getName());
rb.addCounter(gcInfo[0], c).addCounter(gcInfo[1], t);
count += c;
timeMillis += t;
}
rb.addCounter(GcCount, count).addCounter(GcTimeMillis, timeMillis);
if (pauseMonitor != null) {
rb.addCounter(GcNumWarnThresholdExceeded, pauseMonitor.getNumGcWarnThreadholdExceeded());
rb.addCounter(GcNumInfoThresholdExceeded, pauseMonitor.getNumGcInfoThresholdExceeded());
rb.addCounter(GcTotalExtraSleepTime, pauseMonitor.getTotalGcExtraSleepTime());
}
}
use of org.apache.hadoop.metrics2.MetricsInfo in project hadoop by apache.
the class JvmMetrics method getGcUsage.
private void getGcUsage(MetricsRecordBuilder rb) {
long count = 0;
long timeMillis = 0;
for (GarbageCollectorMXBean gcBean : gcBeans) {
long c = gcBean.getCollectionCount();
long t = gcBean.getCollectionTime();
MetricsInfo[] gcInfo = getGcInfo(gcBean.getName());
rb.addCounter(gcInfo[0], c).addCounter(gcInfo[1], t);
count += c;
timeMillis += t;
}
rb.addCounter(GcCount, count).addCounter(GcTimeMillis, timeMillis);
if (pauseMonitor != null) {
rb.addCounter(GcNumWarnThresholdExceeded, pauseMonitor.getNumGcWarnThresholdExceeded());
rb.addCounter(GcNumInfoThresholdExceeded, pauseMonitor.getNumGcInfoThresholdExceeded());
rb.addCounter(GcTotalExtraSleepTime, pauseMonitor.getTotalGcExtraSleepTime());
}
}
use of org.apache.hadoop.metrics2.MetricsInfo in project hadoop by apache.
the class MutableMetricsFactory method newForMethod.
MutableMetric newForMethod(Object source, Method method, Metric annotation, MetricsRegistry registry) {
if (LOG.isDebugEnabled()) {
LOG.debug("method " + method + " with annotation " + annotation);
}
MetricsInfo info = getInfo(annotation, method);
MutableMetric metric = newForMethod(source, method, annotation);
metric = metric != null ? metric : new MethodMetric(source, method, info, annotation.type());
registry.add(info.name(), metric);
return metric;
}
use of org.apache.hadoop.metrics2.MetricsInfo in project hadoop by apache.
the class MutableMetricsFactory method newForField.
MutableMetric newForField(Field field, Metric annotation, MetricsRegistry registry) {
if (LOG.isDebugEnabled()) {
LOG.debug("field " + field + " with annotation " + annotation);
}
MetricsInfo info = getInfo(annotation, field);
MutableMetric metric = newForField(field, annotation);
if (metric != null) {
registry.add(info.name(), metric);
return metric;
}
final Class<?> cls = field.getType();
if (cls == MutableCounterInt.class) {
return registry.newCounter(info, 0);
}
if (cls == MutableCounterLong.class) {
return registry.newCounter(info, 0L);
}
if (cls == MutableGaugeInt.class) {
return registry.newGauge(info, 0);
}
if (cls == MutableGaugeLong.class) {
return registry.newGauge(info, 0L);
}
if (cls == MutableRate.class) {
return registry.newRate(info.name(), info.description(), annotation.always());
}
if (cls == MutableRates.class) {
return new MutableRates(registry);
}
if (cls == MutableRatesWithAggregation.class) {
return registry.newRatesWithAggregation(info.name());
}
if (cls == MutableStat.class) {
return registry.newStat(info.name(), info.description(), annotation.sampleName(), annotation.valueName(), annotation.always());
}
throw new MetricsException("Unsupported metric field " + field.getName() + " of type " + field.getType().getName());
}
use of org.apache.hadoop.metrics2.MetricsInfo in project hadoop by apache.
the class RollingAverages method snapshot.
@Override
public void snapshot(MetricsRecordBuilder builder, boolean all) {
if (all || changed()) {
for (final Entry<String, LinkedBlockingDeque<SumAndCount>> entry : averages.entrySet()) {
final String name = entry.getKey();
final MetricsInfo avgInfo = info(String.format(avgInfoNameTemplate, StringUtils.capitalize(name)), String.format(avgInfoDescTemplate, StringUtils.uncapitalize(name)));
double totalSum = 0;
long totalCount = 0;
for (final SumAndCount sumAndCount : entry.getValue()) {
totalCount += sumAndCount.getCount();
totalSum += sumAndCount.getSum();
}
if (totalCount != 0) {
builder.addGauge(avgInfo, totalSum / totalCount);
}
}
if (changed()) {
clearChanged();
}
}
}
Aggregations