java.lang.Object
org.elasticsearch.common.component.AbstractLifecycleComponent
org.elasticsearch.cluster.service.ClusterService
- All Implemented Interfaces:
Closeable
,AutoCloseable
,LifecycleComponent
,Releasable
-
Field Summary
FieldsFields inherited from class org.elasticsearch.common.component.AbstractLifecycleComponent
lifecycle
-
Constructor Summary
ConstructorsConstructorDescriptionClusterService
(Settings settings, ClusterSettings clusterSettings, MasterService masterService, ClusterApplierService clusterApplierService) ClusterService
(Settings settings, ClusterSettings clusterSettings, ThreadPool threadPool, TaskManager taskManager) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a high priority applier of updated cluster states.void
addListener
(ClusterStateListener listener) Add a listener for updated cluster statesvoid
Add a listener for on/off local node master eventsvoid
addLowPriorityApplier
(ClusterStateApplier applier) Adds an applier which will be called after all high priority and normal appliers have been called.void
addStateApplier
(ClusterStateApplier applier) Adds a applier of updated cluster states.static boolean
<T extends ClusterStateTaskListener>
MasterServiceTaskQueue<T>createTaskQueue
(String name, Priority priority, ClusterStateTaskExecutor<T> executor) Create a new task queue which can be used to submit tasks for execution by the master service.protected void
doClose()
protected void
doStart()
protected void
doStop()
final String
The name of this node.The node's settings.The local node.void
removeApplier
(ClusterStateApplier applier) Removes an applier of updated cluster states.void
removeListener
(ClusterStateListener listener) Removes a listener for updated cluster states.void
setNodeConnectionsService
(NodeConnectionsService nodeConnectionsService) void
setRerouteService
(RerouteService rerouteService) state()
The currently applied cluster state.void
submitUnbatchedStateUpdateTask
(String source, ClusterStateUpdateTask updateTask) Deprecated.Methods inherited from class org.elasticsearch.common.component.AbstractLifecycleComponent
addLifecycleListener, close, lifecycleState, start, stop
-
Field Details
-
USER_DEFINED_METADATA
-
-
Constructor Details
-
ClusterService
public ClusterService(Settings settings, ClusterSettings clusterSettings, ThreadPool threadPool, TaskManager taskManager) -
ClusterService
public ClusterService(Settings settings, ClusterSettings clusterSettings, MasterService masterService, ClusterApplierService clusterApplierService)
-
-
Method Details
-
threadPool
-
setNodeConnectionsService
-
setRerouteService
-
getRerouteService
-
doStart
protected void doStart()- Specified by:
doStart
in classAbstractLifecycleComponent
-
doStop
protected void doStop()- Specified by:
doStop
in classAbstractLifecycleComponent
-
doClose
protected void doClose()- Specified by:
doClose
in classAbstractLifecycleComponent
-
localNode
The local node. -
operationRouting
-
state
The currently applied cluster state. TODO: Should be renamed to appliedState / appliedClusterState -
addHighPriorityApplier
Adds a high priority applier of updated cluster states. -
addLowPriorityApplier
Adds an applier which will be called after all high priority and normal appliers have been called. -
addStateApplier
Adds a applier of updated cluster states. -
removeApplier
Removes an applier of updated cluster states. -
addListener
Add a listener for updated cluster states -
removeListener
Removes a listener for updated cluster states. -
addLocalNodeMasterListener
Add a listener for on/off local node master events -
getMasterService
-
getClusterApplierService
-
assertClusterOrMasterStateThread
public static boolean assertClusterOrMasterStateThread() -
getClusterName
-
getClusterSettings
-
getSettings
The node's settings. -
getNodeName
The name of this node. -
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
-
createTaskQueue
public <T extends ClusterStateTaskListener> MasterServiceTaskQueue<T> createTaskQueue(String name, Priority priority, ClusterStateTaskExecutor<T> executor) Create a new task queue which can be used to submit tasks for execution by the master service. Tasks submitted to the same queue (while the master service is otherwise busy) will be batched together into a single cluster state update. You should therefore re-use each queue as much as possible.- Type Parameters:
T
- The type of the tasks- Parameters:
name
- The name of the queue, which is mostly useful for debugging.priority
- The priority at which tasks submitted to the queue are executed. Avoid priorites other thanPriority.NORMAL
where possible. A stream of higher-priority tasks can starve lower-priority ones from running. Higher-priority tasks should definitely re-use the sameMasterServiceTaskQueue
so that they are executed in batches.executor
- The executor which processes each batch of tasks.- Returns:
- A new batching task queue.
-