Class MasterService

All Implemented Interfaces:
Closeable, AutoCloseable, LifecycleComponent, Releasable

public class MasterService extends AbstractLifecycleComponent
  • Field Details

    • MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING

      public static final Setting<TimeValue> MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING
    • MASTER_SERVICE_STARVATION_LOGGING_THRESHOLD_SETTING

      public static final Setting<TimeValue> MASTER_SERVICE_STARVATION_LOGGING_THRESHOLD_SETTING
    • STATE_UPDATE_ACTION_NAME

      public static final String STATE_UPDATE_ACTION_NAME
      See Also:
    • threadPool

      protected final ThreadPool threadPool
  • Constructor Details

  • Method Details

    • setClusterStatePublisher

      public void setClusterStatePublisher(ClusterStatePublisher publisher)
    • setClusterStateSupplier

      public void setClusterStateSupplier(Supplier<ClusterState> clusterStateSupplier)
    • doStart

      protected void doStart()
      Specified by:
      doStart in class AbstractLifecycleComponent
    • createThreadPoolExecutor

      protected PrioritizedEsThreadPoolExecutor createThreadPoolExecutor()
    • getClusterStateUpdateStats

      public ClusterStateUpdateStats getClusterStateUpdateStats()
    • doStop

      protected void doStop()
      Specified by:
      doStop in class AbstractLifecycleComponent
    • doClose

      protected void doClose()
      Specified by:
      doClose in class AbstractLifecycleComponent
    • isMasterUpdateThread

      public static boolean isMasterUpdateThread()
    • assertMasterUpdateOrTestThread

      public static boolean assertMasterUpdateOrTestThread()
    • assertNotMasterUpdateThread

      public static boolean assertNotMasterUpdateThread(String reason)
    • publicationMayFail

      protected boolean publicationMayFail()
    • publish

      protected void publish(ClusterStatePublicationEvent clusterStatePublicationEvent, ClusterStatePublisher.AckListener ackListener, ActionListener<Void> publicationListener)
    • incrementVersion

      public ClusterState.Builder incrementVersion(ClusterState clusterState)
    • submitUnbatchedStateUpdateTask

      @Deprecated public void submitUnbatchedStateUpdateTask(String source, ClusterStateUpdateTask updateTask)
      Deprecated.
      Submits an unbatched cluster state update task. This method exists for legacy reasons but is deprecated and forbidden in new production code because unbatched tasks are a source of performance and stability bugs. You should instead implement your update logic in a dedicated ClusterStateTaskExecutor which is reused across multiple task instances. The task itself is typically just a collection of parameters consumed by the executor, together with any listeners to be notified when execution completes.
      Parameters:
      source - the source of the cluster state update task
      updateTask - the full context for the cluster state update
    • submitStateUpdateTask

      public <T extends ClusterStateTaskListener> void submitStateUpdateTask(String source, T task, ClusterStateTaskConfig config, ClusterStateTaskExecutor<T> executor)
      Submits a cluster state update task; submitted updates will be batched across the same instance of executor. The exact batching semantics depend on the underlying implementation but a rough guideline is that if the update task is submitted while there are pending update tasks for the same executor, these update tasks will all be executed on the executor in a single batch
      Type Parameters:
      T - the type of the cluster state update task state
      Parameters:
      source - the source of the cluster state update task
      task - the state needed for the cluster state update task, which implements ClusterStateTaskListener so that it is notified when it is executed.
      config - the cluster state update task configuration
      executor - the cluster state update task executor; tasks that share the same executor will be executed batches on this executor
    • pendingTasks

      public List<PendingClusterTask> pendingTasks()
      Returns the tasks that are pending.
    • numberOfPendingTasks

      public int numberOfPendingTasks()
      Returns the number of currently pending tasks.
    • getMaxTaskWaitTime

      public TimeValue getMaxTaskWaitTime()
      Returns the maximum wait time for tasks in the queue
      Returns:
      A zero time value if the queue is empty, otherwise the time value oldest task waiting in the queue
    • isPublishFailureException

      public static boolean isPublishFailureException(Exception e)