java.lang.Object
org.elasticsearch.cluster.routing.allocation.allocator.ContinuousComputation<T>

public abstract class ContinuousComputation<T> extends Object
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 Details

    • ContinuousComputation

      public ContinuousComputation(Executor executor)
      Parameters:
      executor - the Executor with which to execute the computation
  • Method Details

    • onNewInput

      public void onNewInput(T input)
      Called when the input value has changed. If no newer value is received then eventually either the computation will run on this value.
    • isFresh

      protected boolean isFresh(T input)
      Returns:
      true iff the given input is the latest known input.
    • processInput

      protected abstract void processInput(T input)
      Process the given input.
      Parameters:
      input - the value that was last received by onNewInput(T) before invocation.