Class AveragingProgressTracker
ticksWorkedPerClosedTask
to compute delays.
This class has tasksOpenLimit
used as a (weak) limit,
as number of open tasks approaches that value, delays computed are increasing.
In order to keep estimateIsolatedDelay
values from raising unreasonably high,
defaultTicksPerTask
acts as a maximal value. openTask
may return
higher value if there are tasks above the limit.
On the other hand, there is no delay when number of open tasks is half the limit or less, in order to prevent backend from running out of tasks while there may be waiting frontend threads.
This class is NOT thread-safe.
- Author:
- Vratko Polak
-
Constructor Summary
ConstructorsConstructorDescriptionAveragingProgressTracker
(long limit) Create a default idle tracker with given limit.AveragingProgressTracker
(AveragingProgressTracker oldTracker, long now) Construct a new tracker suitable for a new task queue related to a "reconnect".AveragingProgressTracker
(ProgressTracker oldTracker, long limit, long now) Construct a new tracker suitable for a new task queue related to a "reconnect". -
Method Summary
Modifier and TypeMethodDescriptionprotected long
estimateIsolatedDelay
(long now) Give an estimate of a fair delay, assuming delays caused by other opened tasks are ignored.Methods inherited from class org.opendaylight.raft.spi.ProgressTracker
cancelDebt, closeTask, defaultTicksPerTask, openTask, ticksStalling, ticksWorkedPerClosedTask
-
Constructor Details
-
AveragingProgressTracker
public AveragingProgressTracker(long limit) Create a default idle tracker with given limit.- Parameters:
limit
- of open tasks to avoid exceeding
-
AveragingProgressTracker
Construct a new tracker suitable for a new task queue related to a "reconnect".The limit is set independently of the old tracker.
- Parameters:
oldTracker
- the tracker used for the previously used backendlimit
- of open tasks to avoid exceedingnow
- tick number corresponding to caller's present
-
AveragingProgressTracker
Construct a new tracker suitable for a new task queue related to a "reconnect".The limit is copied from the old tracker.
- Parameters:
oldTracker
- the tracker used for the previously used backendnow
- tick number corresponding to caller's present
-
-
Method Details
-
estimateIsolatedDelay
protected long estimateIsolatedDelay(long now) Give an estimate of a fair delay, assuming delays caused by other opened tasks are ignored.This implementation returns zero delay if number of open tasks is half of limit or less. Else the delay is computed, aiming to keep number of open tasks at 3/4 of limit, assuming backend throughput remains constant.
As the number of open tasks approaches the limit, the computed delay increases, but it never exceeds defaultTicksPerTask. That means the actual number of open tasks can exceed the limit.
- Specified by:
estimateIsolatedDelay
in classProgressTracker
- Parameters:
now
- tick number corresponding to caller's present- Returns:
- delay (in ticks) after which another openTask() would be fair to be called by the same thread again
-