@Test public void testSummed() { SampledCounterConfig configSec = new SampledCounterConfig(1, 10, true, 0); SampledCounterImpl counter1 = new SampledCounterImpl(configSec); SampledCounterImpl counter2 = new SampledCounterImpl(configSec); SampledCounterImpl counter3 = new SampledCounterImpl(configSec); SummedSampledCounter summedCounter = new SummedSampledCounter(configSec, counter1, counter2, counter3); counter1.setValue(0); counter2.setValue(0); counter3.setValue(0); Assert.assertEquals(0, summedCounter.getValue()); counter1.setValue(10); Assert.assertEquals(10, summedCounter.getValue()); summedCounter.setValue(-10); Assert.assertEquals(10, summedCounter.getValue()); Assert.assertEquals(10, summedCounter.getAndReset()); Assert.assertEquals(10, summedCounter.getValue()); counter2.setValue(20); counter3.setValue(30); summedCounter.recordSample(); counter1.getAndReset(); counter2.getAndReset(); counter3.getAndReset(); summedCounter.recordSample(); System.out.println("summed"); for (TimeStampedCounterValue tscv : summedCounter.getAllSampleValues()) { System.out.println("\t" + tscv); } Assert.assertEquals(0, summedCounter.getMostRecentSample().getCounterValue()); Assert.assertEquals(0, summedCounter.getAllSampleValues()[0].getCounterValue()); Assert.assertEquals(60, summedCounter.getAllSampleValues()[1].getCounterValue()); Assert.assertEquals(0, summedCounter.getAllSampleValues()[2].getCounterValue()); }
@Override public long getValue() { long l = 0; for (SampledCounter sc : delegates) { l = l + sc.getValue(); } return l; }
SummedSampledCounter extends DerivedSampledCounterImpl { @Override public long getValue() { long l = 0; for (SampledCounter sc : delegates) { l = l + sc.getValue(); } return l; } }
SummedSampledCounter extends DerivedSampledCounterImpl { @Override public long getValue() { long l = 0; for (SampledCounter sc : delegates) { l = l + sc.getValue(); } return l; } SummedSampledCounter(SampledCounterConfig config, SampledCounter... delegates); }
SummedSampledCounter extends DerivedSampledCounterImpl { @Override public long getValue() { long l = 0; for (SampledCounter sc : delegates) { l = l + sc.getValue(); } return l; } SummedSampledCounter(SampledCounterConfig config, SampledCounter... delegates); @Override long getValue(); }
SummedSampledCounter extends DerivedSampledCounterImpl { @Override public long getValue() { long l = 0; for (SampledCounter sc : delegates) { l = l + sc.getValue(); } return l; } SummedSampledCounter(SampledCounterConfig config, SampledCounter... delegates); @Override long getValue();  }