Class CancellableTasksTracker<T>

java.lang.Object
org.elasticsearch.tasks.CancellableTasksTracker<T>

public class CancellableTasksTracker<T> extends Object
Tracks items that are associated with cancellable tasks, supporting efficient lookup by task ID and by parent task ID
  • Constructor Details

    • CancellableTasksTracker

      public CancellableTasksTracker()
  • Method Details

    • getChildrenByRequestId

      public Stream<T> getChildrenByRequestId(TaskId parentTaskId, long childRequestId)
      Gets the cancellable children of a parent task. Note: children of non-positive request IDs (e.g., -1) may be grouped together.
    • put

      public void put(Task task, long requestId, T item)
      Add an item for the given task. Should only be called once for each task, and item must be unique per task too.
    • get

      public T get(long id)
      Get the item that corresponds with the given task, or null if there is no such item.
    • remove

      public T remove(Task task)
      Remove (and return) the item that corresponds with the given task and request ID. Return null if not present. Safe to call multiple times for each task. However, getByParent(org.elasticsearch.tasks.TaskId) may return this task even after a call to this method completes, if the removal is actually being completed by a concurrent call that's still ongoing.
    • values

      public Collection<T> values()
      Return a collection of all the tracked items. May be large. In the presence of concurrent calls to put(org.elasticsearch.tasks.Task, long, T) and remove(org.elasticsearch.tasks.Task) it behaves similarly to ConcurrentHashMap.values().
    • getByParent

      public Stream<T> getByParent(TaskId parentTaskId)
      Return a collection of all the tracked items with a given parent, which will include at least every item for which put(org.elasticsearch.tasks.Task, long, T) completed, but remove(org.elasticsearch.tasks.Task) hasn't started. May include some additional items for which all the calls to remove(org.elasticsearch.tasks.Task) that started before this method was called have not completed.