Class ClusterApplierService

All Implemented Interfaces:
Closeable, AutoCloseable, ClusterApplier, LifecycleComponent, Releasable

public class ClusterApplierService extends AbstractLifecycleComponent implements ClusterApplier
  • Field Details


      public static final Setting<TimeValue> CLUSTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING

      public static final String CLUSTER_UPDATE_THREAD_NAME
      See Also:
  • Constructor Details

  • Method Details

    • setNodeConnectionsService

      public void setNodeConnectionsService(NodeConnectionsService nodeConnectionsService)
    • setInitialState

      public void setInitialState(ClusterState initialState)
      Description copied from interface: ClusterApplier
      Sets the initial state for this applier. Should only be called once.
      Specified by:
      setInitialState in interface ClusterApplier
      initialState - the initial state to set
    • doStart

      protected void doStart()
      Specified by:
      doStart in class AbstractLifecycleComponent
    • createThreadPoolExecutor

      protected PrioritizedEsThreadPoolExecutor createThreadPoolExecutor()
    • doStop

      protected void doStop()
      Specified by:
      doStop in class AbstractLifecycleComponent
    • doClose

      protected void doClose()
      Specified by:
      doClose in class AbstractLifecycleComponent
    • state

      public ClusterState state()
      The current cluster state. Should be renamed to appliedClusterState
    • addHighPriorityApplier

      public void addHighPriorityApplier(ClusterStateApplier applier)
      Adds a high priority applier of updated cluster states.
    • addLowPriorityApplier

      public void addLowPriorityApplier(ClusterStateApplier applier)
      Adds an applier which will be called after all high priority and normal appliers have been called.
    • addStateApplier

      public void addStateApplier(ClusterStateApplier applier)
      Adds a applier of updated cluster states.
    • removeApplier

      public void removeApplier(ClusterStateApplier applier)
      Removes an applier of updated cluster states.
    • addListener

      public void addListener(ClusterStateListener listener)
      Add a listener for updated cluster states. Listeners are executed in the system thread context.
    • removeListener

      public void removeListener(ClusterStateListener listener)
      Removes a listener for updated cluster states.
    • removeTimeoutListener

      public void removeTimeoutListener(TimeoutClusterStateListener listener)
      Removes a timeout listener for updated cluster states.
    • addLocalNodeMasterListener

      public void addLocalNodeMasterListener(LocalNodeMasterListener listener)
      Add a listener for on/off local node master events
    • addTimeoutListener

      public void addTimeoutListener(@Nullable TimeValue timeout, TimeoutClusterStateListener listener)
      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 given clusterStateConsumer on the applier thread. Should only be used in tests and by IndicesStore when it's deleting the data behind a shard that moved away from a node.
      priority - Priority.HIGH unless in tests.
    • threadPool

      public ThreadPool threadPool()
    • onNewClusterState

      public void onNewClusterState(String source, Supplier<ClusterState> clusterStateSupplier, ActionListener<Void> listener)
      Description copied from interface: ClusterApplier
      Method to invoke when a new cluster state is available to be applied
      Specified by:
      onNewClusterState in interface ClusterApplier
      source - information where the cluster state came from
      clusterStateSupplier - the cluster state supplier which provides the latest cluster state to apply
      listener - 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 at ERROR level and otherwise ignored, except in tests where it raises an AssertionError. 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

      public static boolean assertNotClusterStateUpdateThread(String reason)
      asserts that the current thread is NOT the cluster state update thread
    • connectToNodesAndWait

      protected void connectToNodesAndWait(ClusterState newClusterState)
    • connectToNodesAsync

      protected final void connectToNodesAsync(ClusterState newClusterState, Runnable onCompletion)
    • applicationMayFail

      protected boolean applicationMayFail()
    • getStats

      Specified by:
      getStats in interface ClusterApplier
    • getTimeoutClusterStateListenersSize

      public int getTimeoutClusterStateListenersSize()