|
|
|
@ -49,28 +49,6 @@ public class BufferMetricReader implements MetricReader, PrefixMetricReader {
|
|
|
|
|
this.gauges = gauges;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Iterable<Metric<?>> findAll(String prefix) {
|
|
|
|
|
final List<Metric<?>> metrics = new ArrayList<Metric<?>>();
|
|
|
|
|
this.counters.forEach(Pattern.compile(prefix + ".*").asPredicate(),
|
|
|
|
|
new BiConsumer<String, LongBuffer>() {
|
|
|
|
|
@Override
|
|
|
|
|
public void accept(String name, LongBuffer value) {
|
|
|
|
|
metrics.add(new Metric<Long>(name, value.getValue(), new Date(
|
|
|
|
|
value.getTimestamp())));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
this.gauges.forEach(Pattern.compile(prefix + ".*").asPredicate(),
|
|
|
|
|
new BiConsumer<String, DoubleBuffer>() {
|
|
|
|
|
@Override
|
|
|
|
|
public void accept(String name, DoubleBuffer value) {
|
|
|
|
|
metrics.add(new Metric<Double>(name, value.getValue(), new Date(
|
|
|
|
|
value.getTimestamp())));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return metrics;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Metric<?> findOne(final String name) {
|
|
|
|
|
LongBuffer buffer = this.counters.find(name);
|
|
|
|
@ -88,27 +66,40 @@ public class BufferMetricReader implements MetricReader, PrefixMetricReader {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Iterable<Metric<?>> findAll() {
|
|
|
|
|
return findAll(this.all);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Iterable<Metric<?>> findAll(String prefix) {
|
|
|
|
|
return findAll(Pattern.compile(prefix + ".*").asPredicate());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public long count() {
|
|
|
|
|
return this.counters.count() + this.gauges.count();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Iterable<Metric<?>> findAll(Predicate<String> predicate) {
|
|
|
|
|
final List<Metric<?>> metrics = new ArrayList<Metric<?>>();
|
|
|
|
|
this.counters.forEach(this.all, new BiConsumer<String, LongBuffer>() {
|
|
|
|
|
this.counters.forEach(predicate, new BiConsumer<String, LongBuffer>() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void accept(String name, LongBuffer value) {
|
|
|
|
|
metrics.add(new Metric<Long>(name, value.getValue(), new Date(value
|
|
|
|
|
.getTimestamp())));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
this.gauges.forEach(this.all, new BiConsumer<String, DoubleBuffer>() {
|
|
|
|
|
this.gauges.forEach(predicate, new BiConsumer<String, DoubleBuffer>() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void accept(String name, DoubleBuffer value) {
|
|
|
|
|
metrics.add(new Metric<Double>(name, value.getValue(), new Date(value
|
|
|
|
|
.getTimestamp())));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
return metrics;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public long count() {
|
|
|
|
|
return this.counters.count() + this.gauges.count();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|