Class ClusterApplierService
- All Implemented Interfaces:
Closeable,AutoCloseable,ClusterApplier,LifecycleComponent,Releasable
-
Field Summary
FieldsFields inherited from class org.elasticsearch.common.component.AbstractLifecycleComponent
lifecycle -
Constructor Summary
ConstructorsConstructorDescriptionClusterApplierService(String nodeName, Settings settings, ClusterSettings clusterSettings, ThreadPool threadPool) -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a high priority applier of updated cluster states.voidaddListener(ClusterStateListener listener) Add a listener for updated cluster states.voidAdd a listener for on/off local node master eventsvoidaddLowPriorityApplier(ClusterStateApplier applier) Adds an applier which will be called after all high priority and normal appliers have been called.voidaddStateApplier(ClusterStateApplier applier) Adds a applier of updated cluster states.voidaddTimeoutListener(TimeValue timeout, TimeoutClusterStateListener listener) Adds a cluster state listener that is expected to be removed during a short period of time.protected booleanstatic booleanstatic booleanasserts that the current thread is NOT the cluster state update threadstatic voidprotected voidconnectToNodesAndWait(ClusterState newClusterState) protected final voidconnectToNodesAsync(ClusterState newClusterState, Runnable onCompletion) protected PrioritizedEsThreadPoolExecutorprotected voiddoClose()Close this component.protected voiddoStart()Start this component.protected voiddoStop()Stop this component.getStats()intvoidonNewClusterState(String source, Supplier<ClusterState> clusterStateSupplier, ActionListener<Void> listener) Method to invoke when a new cluster state is available to be appliedvoidremoveApplier(ClusterStateApplier applier) Removes an applier of updated cluster states.voidremoveListener(ClusterStateListener listener) Removes a listener for updated cluster states.voidRemoves a timeout listener for updated cluster states.voidrunOnApplierThread(String source, Priority priority, Consumer<ClusterState> clusterStateConsumer, ActionListener<Void> listener) Run the givenclusterStateConsumeron the applier thread.voidsetInitialState(ClusterState initialState) Sets the initial state for this applier.static voidvoidsetNodeConnectionsService(NodeConnectionsService nodeConnectionsService) state()The current cluster state.Methods inherited from class org.elasticsearch.common.component.AbstractLifecycleComponent
addLifecycleListener, close, lifecycleState, start, stop
-
Field Details
-
CLUSTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING
-
CLUSTER_SERVICE_SLOW_TASK_THREAD_DUMP_TIMEOUT_SETTING
-
CLUSTER_UPDATE_THREAD_NAME
- See Also:
-
-
Constructor Details
-
ClusterApplierService
public ClusterApplierService(String nodeName, Settings settings, ClusterSettings clusterSettings, ThreadPool threadPool)
-
-
Method Details
-
setNodeConnectionsService
-
setInitialState
Description copied from interface:ClusterApplierSets the initial state for this applier. Should only be called once.- Specified by:
setInitialStatein interfaceClusterApplier- Parameters:
initialState- the initial state to set
-
doStart
protected void doStart()Description copied from class:AbstractLifecycleComponentStart this component. Typically that means doing things like launching background processes and registering listeners on other components. Other components have been initialized by this point, but may not yet be started.If this method throws an exception then the startup process will fail, but this component will not be stopped before it is closed.
This method is called while synchronized on
AbstractLifecycleComponent.lifecycle. It is only called once in the lifetime of a component, although it may not be called at all if the startup process encountered some kind of fatal error, such as the failure of some other component to initialize or start.- Specified by:
doStartin classAbstractLifecycleComponent
-
createThreadPoolExecutor
-
doStop
protected void doStop()Description copied from class:AbstractLifecycleComponentStop this component. Typically that means doing the reverse of whateverAbstractLifecycleComponent.doStart()does.This method is called while synchronized on
AbstractLifecycleComponent.lifecycle. It is only called once in the lifetime of a component, after callingAbstractLifecycleComponent.doStart(), although it will not be called at all if this component did not successfully start.- Specified by:
doStopin classAbstractLifecycleComponent
-
doClose
protected void doClose()Description copied from class:AbstractLifecycleComponentClose this component. Typically that means doing the reverse of whatever happened during initialization, such as releasing resources acquired there.This method is called while synchronized on
AbstractLifecycleComponent.lifecycle. It is called once in the lifetime of a component. If the component was started then it will be stopped before it is closed, and once it is closed it will not be started or stopped.- Specified by:
doClosein classAbstractLifecycleComponent
-
state
The current cluster state. Should be renamed to 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. Listeners are executed in the system thread context. -
removeListener
Removes a listener for updated cluster states. -
removeTimeoutListener
Removes a timeout listener for updated cluster states. -
addLocalNodeMasterListener
Add a listener for on/off local node master events -
addTimeoutListener
Adds a cluster state listener that is expected to be removed during a short period of time. If provided, the listener will be notified once a specific time has elapsed. NOTE: the listener is not removed on timeout. This is the responsibility of the caller. -
runOnApplierThread
public void runOnApplierThread(String source, Priority priority, Consumer<ClusterState> clusterStateConsumer, ActionListener<Void> listener) Run the givenclusterStateConsumeron the applier thread. Should only be used in tests, byIndicesClusterStateServicewhen trying to acquire shard locks and create shards, and byIndicesStorewhen it's deleting the data behind a shard that moved away from a node. -
threadPool
-
onNewClusterState
public void onNewClusterState(String source, Supplier<ClusterState> clusterStateSupplier, ActionListener<Void> listener) Description copied from interface:ClusterApplierMethod to invoke when a new cluster state is available to be applied- Specified by:
onNewClusterStatein interfaceClusterApplier- Parameters:
source- information where the cluster state came fromclusterStateSupplier- the cluster state supplier which provides the latest cluster state to applylistener- notified after cluster state is applied. The implementation must not throw exceptions: an exception thrown by this listener is logged by the cluster applier service atERRORlevel and otherwise ignored, except in tests where it raises anAssertionError. If log-and-ignore is the right behaviour then implementations must do so themselves, typically using a more specific logger and at a less dramatic log level.
-
assertNotClusterStateUpdateThread
asserts that the current thread is NOT the cluster state update thread -
connectToNodesAndWait
-
connectToNodesAsync
-
applicationMayFail
protected boolean applicationMayFail() -
getStats
- Specified by:
getStatsin interfaceClusterApplier
-
getTimeoutClusterStateListenersSize
public int getTimeoutClusterStateListenersSize() -
assertNotApplyingClusterState
public static boolean assertNotApplyingClusterState() -
setIsApplyingClusterState
public static void setIsApplyingClusterState() -
clearIsApplyingClusterState
public static void clearIsApplyingClusterState()
-