MultiWindowRate implements ReadableMultiWindowRate, WritableMultiWindowStat { public MultiWindowRate merge(MultiWindowRate rate) { return new MultiWindowRate( (CompositeSum) allTimeCounter.merge(rate.allTimeCounter), (CompositeSum) hourCounter.merge(rate.hourCounter), (CompositeSum) tenMinuteCounter.merge(rate.tenMinuteCounter), (CompositeSum) minuteCounter.merge(rate.minuteCounter), start.isBefore(rate.start) ? start : rate.start, timeBucketSizeMillis); } MultiWindowRate(int timeBucketSizeMillis);   MultiWindowRate(
      CompositeSum allTimeCounter,
      CompositeSum hourCounter,
      CompositeSum tenMinuteCounter,
      CompositeSum minuteCounter,
      ReadableDateTime start,
      int timeBucketSizeMillis);  MultiWindowRate(); @Override void add(long delta); @Override long getMinuteSum(); @Override long getMinuteRate(); @Override long getTenMinuteSum(); @Override long getTenMinuteRate(); @Override long getHourSum(); @Override long getHourRate(); @Override long getAllTimeSum(); @Override long getAllTimeRate(); MultiWindowRate merge(MultiWindowRate rate);  }
@Test(groups = "fast") public void testMerge() throws Exception { MultiWindowRate rate1 = new MultiWindowRate(); MultiWindowRate rate2 = new MultiWindowRate(); rate1.add(1); rate2.add(2); Assert.assertEquals(rate1.merge(rate2).getAllTimeSum(), 3); Assert.assertEquals(rate1.merge(rate2).getHourSum(), 3); Assert.assertEquals(rate1.merge(rate2).getTenMinuteSum(), 3); Assert.assertEquals(rate1.merge(rate2).getMinuteSum(), 3); }