CompositeMin extends AbstractCompositeCounter<EventCounter> implements EventCounter { @Override public synchronized long getValue() { trimIfNeeded(); long min = Long.MAX_VALUE; for (EventCounter eventCounter : getEventCounters()) { min = Math.min(min, eventCounter.getValue()); } return min; } CompositeMin(ReadableDuration maxLength, ReadableDuration maxChunkLength);  CompositeMin(ReadableDuration maxLength); @Override EventCounter merge(EventCounter counter); @Override synchronized long getValue();  }
@Test(groups = "fast") public void testSanity() throws Exception { TimeUtil.setNow(new DateTime("2012-01-01", DateTimeZone.UTC)); CompositeMin compositeMax = new CompositeMin(Duration.standardSeconds(30), Duration.standardSeconds(10)); compositeMax.add(2); compositeMax.add(3); Assert.assertEquals(compositeMax.getValue(), 2); TimeUtil.advanceNow(Duration.standardSeconds(10)); compositeMax.add(1); Assert.assertEquals(compositeMax.getValue(), 1); TimeUtil.advanceNow(Duration.standardSeconds(10)); compositeMax.add(6); Assert.assertEquals(compositeMax.getValue(), 1); TimeUtil.advanceNow(Duration.standardSeconds(30)); Assert.assertEquals(compositeMax.getValue(), 6); }