Class MasterService

    • Field Detail

      • MASTER_UPDATE_THREAD_NAME

        public static final java.lang.String MASTER_UPDATE_THREAD_NAME
        See Also:
        Constant Field Values
      • threadPool

        protected final ThreadPool threadPool
    • Constructor Detail

      • MasterService

        public MasterService​(java.lang.String nodeName,
                             Settings settings,
                             ThreadPool threadPool)
    • Method Detail

      • setSlowTaskLoggingThreshold

        public void setSlowTaskLoggingThreshold​(TimeValue slowTaskLoggingThreshold)
      • setClusterStateSupplier

        public void setClusterStateSupplier​(java.util.function.Supplier<ClusterState> clusterStateSupplier)
      • assertMasterUpdateThread

        public static boolean assertMasterUpdateThread()
      • assertNotMasterUpdateThread

        public static boolean assertNotMasterUpdateThread​(java.lang.String reason)
      • calculateTaskOutputs

        public org.elasticsearch.cluster.service.MasterService.TaskOutputs calculateTaskOutputs​(MasterService.TaskInputs taskInputs,
                                                                                                ClusterState previousClusterState,
                                                                                                long startTimeNS)
      • submitStateUpdateTask

        public <T> void submitStateUpdateTask​(java.lang.String source,
                                              T task,
                                              ClusterStateTaskConfig config,
                                              ClusterStateTaskExecutor<T> executor,
                                              ClusterStateTaskListener listener)
        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
        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
        listener - callback after the cluster state update task completes
      • pendingTasks

        public java.util.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
      • warnAboutSlowTaskIfNeeded

        protected void warnAboutSlowTaskIfNeeded​(TimeValue executionTime,
                                                 java.lang.String source)
      • submitStateUpdateTasks

        public <T> void submitStateUpdateTasks​(java.lang.String source,
                                               java.util.Map<T,​ClusterStateTaskListener> tasks,
                                               ClusterStateTaskConfig config,
                                               ClusterStateTaskExecutor<T> executor)
        Submits a batch of cluster state update tasks; submitted updates are guaranteed to be processed together, potentially with more tasks of the same executor.
        Type Parameters:
        T - the type of the cluster state update task state
        Parameters:
        source - the source of the cluster state update task
        tasks - a map of update tasks and their corresponding listeners
        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
      • currentTimeInNanos

        protected long currentTimeInNanos()