Jagger
 All Classes Namespaces Files Functions Variables Groups Pages
Custom aggregators

Aggregators main page

  1. Create class which implements MetricAggregatorProvider
    This class should provide instance of your aggregator - class that implements interface MetricAggregator<C extends Number>
    // begin: following section is used for docu generation - custom aggregator source
    public class MaxMetricAggregatorProvider implements MetricAggregatorProvider{
    @Override
    public MetricAggregator provide() {
    return new MaxMetricAggregator();
    }
    private static class MaxMetricAggregator implements MetricAggregator<Number> {
    private Double value = null;
    @Override
    public void append(Number calculated) {
    if (value == null) {
    value = calculated.doubleValue();
    }
    else {
    value = Math.max(value,calculated.doubleValue());
    }
    }
    @Override
    public Double getAggregated() {
    return value;
    }
    @Override
    public void reset() {
    value = null;
    }
    @Override
    public String getName() {
    return "max";
    }
    }
    }
    // end: following section is used for docu generation - custom aggregator source

  2. Create bean of this class in some configuration file. Put some id for it.
    <!--begin: following section is used for docu generation - custom aggregator-->
    <bean id="maxAggregator" class="metric.aggregator.MaxMetricAggregatorProvider"/>
    <!--end: following section is used for docu generation - custom aggregator-->

  3. Add metric aggregator of type metric-aggregator-ref to you metric-custom block.
    <!--begin: following section is used for docu generation - custom aggregator usage-->
    <metric id="sin2" xsi:type="metric-custom" calculator="sin" plotData="true" saveSummary="true">
    <metric-aggregator xsi:type="metric-aggregator-ref" ref="maxAggregator"/>
    <metric-aggregator xsi:type="metric-aggregator-ref" ref="minAggregator"/>
    </metric>
    <!--end: following section is used for docu generation - custom aggregator usage-->