@Private
public class RollingWindow
extends java.lang.Object
getSum(long) method.
Assumptions:
(1) Concurrent invocation of incAt(long, long) method are possible
(2) The time parameter of two consecutive invocation of incAt(long, long) could
be in any given order
(3) The buffering delays are not more than the window length, i.e., after two
consecutive invocation incAt(long time1, long) and
incAt(long time2, long), time1 < time2 || time1 - time2 <
windowLenMs.
This assumption helps avoiding unnecessary synchronizations.
Thread-safety is built in the RollingWindow.Bucket
| Modifier and Type | Method | Description |
|---|---|---|
long |
getSum(long time) |
Get value represented by this window at the specified time
|
void |
incAt(long time,
long delta) |
When an event occurs at the specified time, this method reflects that in
the rolling window.
|
public void incAt(long time,
long delta)
time - the time at which the event occurreddelta - the delta that will be added to the windowpublic long getSum(long time)
If time lags behind the latest update time, the new updates are still included in the sum
time - Copyright © 2008–2025 Apache Software Foundation. All rights reserved.