Module org.elasticsearch.server
Class ContinuousComputation<T>
java.lang.Object
org.elasticsearch.cluster.routing.allocation.allocator.ContinuousComputation<T>
Asynchronously runs some computation using at most one thread but expects the input value changes over time as it's running. Newer input
values are assumed to be fresher and trigger a recomputation. If a computation never starts before a fresher value arrives then it is
skipped.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleancompareAndEnqueue(T expectedLatestKnownInput, T input) enqueuesinputifexpectedLatestKnownInputis the latest known input.protected booleanvoidonNewInput(T input) Called when the input value has changed.protected abstract voidprocessInput(T input) Process the given input.
-
Constructor Details
-
ContinuousComputation
- Parameters:
executor- theExecutorwith which to execute the computation
-
-
Method Details
-
onNewInput
Called when the input value has changed. If no newer value is received then eventually either the computation will run on this value. -
compareAndEnqueue
enqueuesinputifexpectedLatestKnownInputis the latest known input. Neither of the parameters can be null. -
isFresh
- Returns:
trueiff the giveninputis the latest known input.
-
processInput
Process the given input.- Parameters:
input- the value that was last received byonNewInput(T)orcompareAndEnqueue(T, T)before invocation.
-