java.lang.Object
org.elasticsearch.common.component.AbstractLifecycleComponent
org.elasticsearch.cluster.service.MasterService
- All Implemented Interfaces:
Closeable
,AutoCloseable
,LifecycleComponent
,Releasable
-
Field Summary
Fields inherited from class org.elasticsearch.common.component.AbstractLifecycleComponent
lifecycle
-
Constructor Summary
ConstructorDescriptionMasterService
(Settings settings, ClusterSettings clusterSettings, ThreadPool threadPool, TaskManager taskManager) -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
static boolean
assertNotMasterUpdateThread
(String reason) protected PrioritizedEsThreadPoolExecutor
protected void
doClose()
protected void
doStart()
protected void
doStop()
Returns the maximum wait time for tasks in the queueincrementVersion
(ClusterState clusterState) static boolean
static boolean
int
Returns the number of currently pending tasks.Returns the tasks that are pending.protected boolean
protected void
publish
(ClusterStatePublicationEvent clusterStatePublicationEvent, ClusterStatePublisher.AckListener ackListener, ActionListener<Void> publicationListener) void
setClusterStatePublisher
(ClusterStatePublisher publisher) void
setClusterStateSupplier
(Supplier<ClusterState> clusterStateSupplier) <T extends ClusterStateTaskListener>
voidsubmitStateUpdateTask
(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.void
submitUnbatchedStateUpdateTask
(String source, ClusterStateUpdateTask updateTask) Deprecated.Methods inherited from class org.elasticsearch.common.component.AbstractLifecycleComponent
addLifecycleListener, close, lifecycleState, start, stop
-
Field Details
-
MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING
-
MASTER_SERVICE_STARVATION_LOGGING_THRESHOLD_SETTING
-
STATE_UPDATE_ACTION_NAME
- See Also:
-
threadPool
-
-
Constructor Details
-
MasterService
public MasterService(Settings settings, ClusterSettings clusterSettings, ThreadPool threadPool, TaskManager taskManager)
-
-
Method Details
-
setClusterStatePublisher
-
setClusterStateSupplier
-
doStart
protected void doStart()- Specified by:
doStart
in classAbstractLifecycleComponent
-
createThreadPoolExecutor
-
getClusterStateUpdateStats
-
doStop
protected void doStop()- Specified by:
doStop
in classAbstractLifecycleComponent
-
doClose
protected void doClose()- Specified by:
doClose
in classAbstractLifecycleComponent
-
isMasterUpdateThread
public static boolean isMasterUpdateThread() -
assertMasterUpdateOrTestThread
public static boolean assertMasterUpdateOrTestThread() -
assertNotMasterUpdateThread
-
publicationMayFail
protected boolean publicationMayFail() -
publish
protected void publish(ClusterStatePublicationEvent clusterStatePublicationEvent, ClusterStatePublisher.AckListener ackListener, ActionListener<Void> publicationListener) -
incrementVersion
-
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 dedicatedClusterStateTaskExecutor
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 taskupdateTask
- 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 tasktask
- the state needed for the cluster state update task, which implementsClusterStateTaskListener
so that it is notified when it is executed.config
- the cluster state update task configurationexecutor
- the cluster state update task executor; tasks that share the same executor will be executed batches on this executor
-
pendingTasks
Returns the tasks that are pending. -
numberOfPendingTasks
public int numberOfPendingTasks()Returns the number of currently pending tasks. -
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
-