Class TaskCancellationMonitoringService

java.lang.Object
org.opensearch.common.lifecycle.AbstractLifecycleComponent
org.opensearch.tasks.TaskCancellationMonitoringService
All Implemented Interfaces:
Closeable, AutoCloseable, org.opensearch.common.lease.Releasable, org.opensearch.common.lifecycle.LifecycleComponent, TaskManager.TaskEventListeners

public class TaskCancellationMonitoringService extends org.opensearch.common.lifecycle.AbstractLifecycleComponent implements TaskManager.TaskEventListeners
This monitoring service is responsible to track long-running(defined by a threshold) cancelled tasks as part of node stats.
  • Constructor Details

  • Method Details

    • doStart

      protected void doStart()
      Specified by:
      doStart in class org.opensearch.common.lifecycle.AbstractLifecycleComponent
    • doStop

      protected void doStop()
      Specified by:
      doStop in class org.opensearch.common.lifecycle.AbstractLifecycleComponent
    • doClose

      protected void doClose() throws IOException
      Specified by:
      doClose in class org.opensearch.common.lifecycle.AbstractLifecycleComponent
      Throws:
      IOException
    • getCancelledTaskTracker

      protected Map<Long,Boolean> getCancelledTaskTracker()
    • onTaskCompleted

      public void onTaskCompleted(Task task)
      Invoked when a task is completed. This helps us to disable monitoring service when there are no cancelled tasks running to avoid wasteful work.
      Specified by:
      onTaskCompleted in interface TaskManager.TaskEventListeners
      Parameters:
      task - task which got completed.
    • onTaskCancelled

      public void onTaskCancelled(CancellableTask task)
      Invoked when a task is cancelled. This is to keep track of tasks being cancelled. More importantly also helps us to enable this monitoring service only when needed.
      Specified by:
      onTaskCancelled in interface TaskManager.TaskEventListeners
      Parameters:
      task - task which got cancelled.
    • stats

      public TaskCancellationStats stats()