public class ClusterService extends AbstractLifecycleComponent
Modifier and Type | Field and Description |
---|---|
static Setting<TimeValue> |
CLUSTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING |
static java.lang.String |
UPDATE_THREAD_NAME |
lifecycle
deprecationLogger, logger, settings
Constructor and Description |
---|
ClusterService(Settings settings,
ClusterSettings clusterSettings,
ThreadPool threadPool) |
Modifier and Type | Method and Description |
---|---|
void |
add(ClusterStateListener listener)
Adds a listener for updated cluster states.
|
void |
add(LocalNodeMasterListener listener)
Add a listener for on/off local node master events
|
void |
add(TimeValue timeout,
TimeoutClusterStateListener listener)
Adds a cluster state listener that will timeout after the provided timeout,
and is executed after the clusterstate has been successfully applied ie.
|
void |
addFirst(ClusterStateListener listener)
Adds a priority listener for updated cluster states.
|
void |
addInitialStateBlock(ClusterBlock block)
Adds an initial block to be set on the first cluster state created.
|
void |
addLast(ClusterStateListener listener)
Adds last listener.
|
static boolean |
assertClusterStateThread()
asserts that the current thread is the cluster state update thread
|
protected long |
currentTimeInNanos() |
protected void |
doClose() |
protected void |
doStart() |
protected void |
doStop() |
ClusterName |
getClusterName() |
ClusterSettings |
getClusterSettings() |
TimeValue |
getMaxTaskWaitTime()
Returns the maximum wait time for tasks in the queue
|
Settings |
getSettings() |
DiscoveryNode |
localNode()
The local node.
|
int |
numberOfPendingTasks()
Returns the number of currently pending tasks.
|
OperationRouting |
operationRouting() |
java.util.List<PendingClusterTask> |
pendingTasks()
Returns the tasks that are pending.
|
void |
remove(ClusterStateListener listener)
Removes a listener for updated cluster states.
|
void |
remove(LocalNodeMasterListener listener)
Remove the given listener for on/off local master events
|
void |
removeInitialStateBlock(ClusterBlock block)
Remove an initial block to be set on the first cluster state created.
|
void |
removeInitialStateBlock(int blockId)
Remove an initial block to be set on the first cluster state created.
|
void |
setClusterStatePublisher(java.util.function.BiConsumer<ClusterChangedEvent,Discovery.AckListener> publisher) |
void |
setLocalNode(DiscoveryNode localNode) |
void |
setNodeConnectionsService(NodeConnectionsService nodeConnectionsService) |
ClusterState |
state()
The current state.
|
void |
submitStateUpdateTask(java.lang.String source,
ClusterStateUpdateTask updateTask)
Submits a cluster state update task; unlike
submitStateUpdateTask(String, Object, ClusterStateTaskConfig,
ClusterStateTaskExecutor, ClusterStateTaskListener) , submitted updates will not be batched. |
<T> void |
submitStateUpdateTask(java.lang.String source,
T task,
ClusterStateTaskConfig config,
ClusterStateTaskExecutor<T> executor,
ClusterStateTaskListener listener)
Submits a cluster state update task; submitted updates will be
batched across the same instance of executor.
|
<T> void |
submitStateUpdateTasks(java.lang.String source,
java.util.Map<T,ClusterStateTaskListener> tasks,
ClusterStateTaskConfig config,
ClusterStateTaskExecutor<T> executor)
Submits a batch of cluster state update tasks; submitted updates are guaranteed to be processed together,
potentially with more tasks of the same executor.
|
addLifecycleListener, close, lifecycleState, removeLifecycleListener, start, stop
logDeprecatedSetting, logRemovedSetting, nodeName
public static final Setting<TimeValue> CLUSTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING
public static final java.lang.String UPDATE_THREAD_NAME
public ClusterService(Settings settings, ClusterSettings clusterSettings, ThreadPool threadPool)
public void setClusterStatePublisher(java.util.function.BiConsumer<ClusterChangedEvent,Discovery.AckListener> publisher)
public void setLocalNode(DiscoveryNode localNode)
public void setNodeConnectionsService(NodeConnectionsService nodeConnectionsService)
public void addInitialStateBlock(ClusterBlock block) throws java.lang.IllegalStateException
java.lang.IllegalStateException
public void removeInitialStateBlock(ClusterBlock block) throws java.lang.IllegalStateException
java.lang.IllegalStateException
public void removeInitialStateBlock(int blockId) throws java.lang.IllegalStateException
java.lang.IllegalStateException
protected void doStart()
doStart
in class AbstractLifecycleComponent
protected void doStop()
doStop
in class AbstractLifecycleComponent
protected void doClose()
doClose
in class AbstractLifecycleComponent
public DiscoveryNode localNode()
public OperationRouting operationRouting()
public ClusterState state()
public void addFirst(ClusterStateListener listener)
public void addLast(ClusterStateListener listener)
public void add(ClusterStateListener listener)
public void remove(ClusterStateListener listener)
public void add(LocalNodeMasterListener listener)
public void remove(LocalNodeMasterListener listener)
public void add(@Nullable TimeValue timeout, TimeoutClusterStateListener listener)
ClusterState.ClusterStateStatus.APPLIED
NOTE: a null
timeout means that the listener will never be removed
automaticallypublic void submitStateUpdateTask(java.lang.String source, ClusterStateUpdateTask updateTask)
submitStateUpdateTask(String, Object, ClusterStateTaskConfig,
ClusterStateTaskExecutor, ClusterStateTaskListener)
, submitted updates will not be batched.source
- the source of the cluster state update taskupdateTask
- the full context for the cluster state update
taskpublic <T> void submitStateUpdateTask(java.lang.String source, T task, ClusterStateTaskConfig config, ClusterStateTaskExecutor<T> executor, ClusterStateTaskListener listener)
T
- the type of the cluster state update task statesource
- the source of the cluster state update tasktask
- the state needed for the cluster state update taskconfig
- the cluster state update task configurationexecutor
- the cluster state update task executor; tasks
that share the same executor will be executed
batches on this executorlistener
- callback after the cluster state update task
completespublic <T> void submitStateUpdateTasks(java.lang.String source, java.util.Map<T,ClusterStateTaskListener> tasks, ClusterStateTaskConfig config, ClusterStateTaskExecutor<T> executor)
T
- the type of the cluster state update task statesource
- the source of the cluster state update tasktasks
- a map of update tasks and their corresponding listenersconfig
- the cluster state update task configurationexecutor
- the cluster state update task executor; tasks
that share the same executor will be executed
batches on this executorpublic java.util.List<PendingClusterTask> pendingTasks()
public int numberOfPendingTasks()
public TimeValue getMaxTaskWaitTime()
public static boolean assertClusterStateThread()
public ClusterName getClusterName()
protected long currentTimeInNanos()
public ClusterSettings getClusterSettings()
public Settings getSettings()