INT-3035 Fix ExponentialMovingAverageRate 'window'

'window' constructor arg was not used.

Add test.
This commit is contained in:
Gary Russell
2013-05-27 11:24:58 -04:00
committed by Mark Fisher
parent 91afaedbe2
commit 50e728f9e0
2 changed files with 17 additions and 7 deletions

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2009-2010 the original author or authors.
*
* Copyright 2009-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
@@ -25,9 +25,10 @@ package org.springframework.integration.monitor;
* <li>per measurement according to the lapse window supplied: <code>weight = exp(-i/L)</code> where <code>L</code> is
* the lapse window and <code>i</code> is the sequence number of the measurement.</li>
* </ul>
*
*
* @author Dave Syer
*
* @author Gary Russell
*
*/
public class ExponentialMovingAverageRate {
@@ -54,7 +55,7 @@ public class ExponentialMovingAverageRate {
* @param window the exponential lapse window (number of measurements)
*/
public ExponentialMovingAverageRate(double period, double lapsePeriod, int window) {
rates = new ExponentialMovingAverage(10);
rates = new ExponentialMovingAverage(window);
this.lapse = lapsePeriod > 0 ? 0.001 / lapsePeriod : 0; // convert to milliseconds
this.period = period * 1000; // convert to milliseconds
}