public class ClusterApplierService extends AbstractLifecycleComponent implements ClusterApplier
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CLUSTER_UPDATE_THREAD_NAME |
protected ThreadPool |
threadPool |
lifecycle
deprecationLogger, logger, settings
Constructor and Description |
---|
ClusterApplierService(Settings settings,
ClusterSettings clusterSettings,
ThreadPool threadPool) |
Modifier and Type | Method and Description |
---|---|
void |
addHighPriorityApplier(ClusterStateApplier applier)
Adds a high priority applier of updated cluster states.
|
void |
addListener(ClusterStateListener listener)
Add a listener for updated cluster states
|
void |
addLocalNodeMasterListener(LocalNodeMasterListener listener)
Add a listener for on/off local node master events
|
void |
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.
|
void |
addTimeoutListener(TimeValue timeout,
TimeoutClusterStateListener listener)
Adds a cluster state listener that is expected to be removed during a short period of time.
|
static boolean |
assertClusterStateUpdateThread()
asserts that the current thread is the cluster state update thread
|
static boolean |
assertNotClusterStateUpdateThread(java.lang.String reason)
asserts that the current thread is NOT the cluster state update thread
|
protected long |
currentTimeInNanos() |
protected void |
doClose() |
protected void |
doStart() |
protected void |
doStop() |
void |
onNewClusterState(java.lang.String source,
java.util.function.Supplier<ClusterState> clusterStateSupplier,
ClusterStateTaskListener listener)
Method to invoke when a new cluster state is available to be applied
|
void |
removeApplier(ClusterStateApplier applier)
Removes an applier of updated cluster states.
|
void |
removeListener(ClusterStateListener listener)
Removes a listener for updated cluster states.
|
void |
removeLocalNodeMasterListener(LocalNodeMasterListener listener)
Remove the given listener for on/off local master events
|
void |
removeTimeoutListener(TimeoutClusterStateListener listener)
Removes a timeout listener for updated cluster states.
|
void |
runOnApplierThread(java.lang.String source,
java.util.function.Consumer<ClusterState> clusterStateConsumer,
ClusterStateTaskListener listener) |
void |
runOnApplierThread(java.lang.String source,
java.util.function.Consumer<ClusterState> clusterStateConsumer,
ClusterStateTaskListener listener,
Priority priority) |
protected void |
runTask(org.elasticsearch.cluster.service.ClusterApplierService.UpdateTask task) |
void |
setInitialState(ClusterState initialState)
Sets the initial state for this applier.
|
void |
setNodeConnectionsService(NodeConnectionsService nodeConnectionsService) |
void |
setSlowTaskLoggingThreshold(TimeValue slowTaskLoggingThreshold) |
ClusterState |
state()
The current cluster state.
|
protected void |
warnAboutSlowTaskIfNeeded(TimeValue executionTime,
java.lang.String source) |
addLifecycleListener, close, lifecycleState, removeLifecycleListener, start, stop
logDeprecatedSetting, logRemovedSetting, nodeName
public static final java.lang.String CLUSTER_UPDATE_THREAD_NAME
protected final ThreadPool threadPool
public ClusterApplierService(Settings settings, ClusterSettings clusterSettings, ThreadPool threadPool)
public void setSlowTaskLoggingThreshold(TimeValue slowTaskLoggingThreshold)
public void setNodeConnectionsService(NodeConnectionsService nodeConnectionsService)
public void setInitialState(ClusterState initialState)
ClusterApplier
setInitialState
in interface ClusterApplier
initialState
- the initial state to setprotected void doStart()
doStart
in class AbstractLifecycleComponent
protected void doStop()
doStop
in class AbstractLifecycleComponent
protected void doClose()
doClose
in class AbstractLifecycleComponent
public ClusterState state()
public void addHighPriorityApplier(ClusterStateApplier applier)
public void addLowPriorityApplier(ClusterStateApplier applier)
public void addStateApplier(ClusterStateApplier applier)
public void removeApplier(ClusterStateApplier applier)
public void addListener(ClusterStateListener listener)
public void removeListener(ClusterStateListener listener)
public void removeTimeoutListener(TimeoutClusterStateListener listener)
public void addLocalNodeMasterListener(LocalNodeMasterListener listener)
public void removeLocalNodeMasterListener(LocalNodeMasterListener listener)
public void addTimeoutListener(@Nullable TimeValue timeout, TimeoutClusterStateListener listener)
public void runOnApplierThread(java.lang.String source, java.util.function.Consumer<ClusterState> clusterStateConsumer, ClusterStateTaskListener listener, Priority priority)
public void runOnApplierThread(java.lang.String source, java.util.function.Consumer<ClusterState> clusterStateConsumer, ClusterStateTaskListener listener)
public void onNewClusterState(java.lang.String source, java.util.function.Supplier<ClusterState> clusterStateSupplier, ClusterStateTaskListener listener)
ClusterApplier
onNewClusterState
in interface ClusterApplier
source
- information where the cluster state came fromclusterStateSupplier
- the cluster state supplier which provides the latest cluster state to applylistener
- callback that is invoked after cluster state is appliedpublic static boolean assertClusterStateUpdateThread()
public static boolean assertNotClusterStateUpdateThread(java.lang.String reason)
protected void runTask(org.elasticsearch.cluster.service.ClusterApplierService.UpdateTask task)
protected void warnAboutSlowTaskIfNeeded(TimeValue executionTime, java.lang.String source)
protected long currentTimeInNanos()