Class NodeJoinExecutor
- All Implemented Interfaces:
ClusterStateTaskExecutor<JoinTask>
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.cluster.ClusterStateTaskExecutor
ClusterStateTaskExecutor.BatchExecutionContext<T extends ClusterStateTaskListener>, ClusterStateTaskExecutor.TaskContext<T extends ClusterStateTaskListener>
-
Constructor Summary
ConstructorDescriptionNodeJoinExecutor
(AllocationService allocationService, RerouteService rerouteService, FeatureService featureService) NodeJoinExecutor
(AllocationService allocationService, RerouteService rerouteService, FeatureService featureService, Function<ClusterState, ClusterState> maybeReconfigureAfterMasterElection) -
Method Summary
Modifier and TypeMethodDescriptionstatic Collection<BiConsumer<DiscoveryNode,
ClusterState>> addBuiltInJoinValidators
(Collection<BiConsumer<DiscoveryNode, ClusterState>> onJoinValidators) protected ClusterState.Builder
becomeMasterAndTrimConflictingNodes
(ClusterState currentState, List<? extends ClusterStateTaskExecutor.TaskContext<JoinTask>> taskContexts, long term) static void
ensureIndexCompatibility
(IndexVersion minSupportedVersion, IndexVersion maxSupportedVersion, Metadata metadata) Ensures that all indices are compatible with the given index version.static void
ensureNodesCompatibility
(Version joiningNodeVersion, DiscoveryNodes currentNodes) ensures that the joining node has a version that's compatible with all current nodesstatic void
ensureNodesCompatibility
(Version joiningNodeVersion, Version minClusterNodeVersion, Version maxClusterNodeVersion) ensures that the joining node has a version that's compatible with a given version rangestatic void
ensureVersionBarrier
(Version joiningNodeVersion, Version minClusterNodeVersion) ensures that the joining node's version is equal or higher to the minClusterNodeVersion.execute
(ClusterStateTaskExecutor.BatchExecutionContext<JoinTask> batchExecutionContext) Update the cluster state based on the current state and the given tasks.boolean
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.elasticsearch.cluster.ClusterStateTaskExecutor
clusterStatePublished, describeTasks
-
Constructor Details
-
NodeJoinExecutor
public NodeJoinExecutor(AllocationService allocationService, RerouteService rerouteService, FeatureService featureService) -
NodeJoinExecutor
public NodeJoinExecutor(AllocationService allocationService, RerouteService rerouteService, FeatureService featureService, Function<ClusterState, ClusterState> maybeReconfigureAfterMasterElection)
-
-
Method Details
-
execute
public ClusterState execute(ClusterStateTaskExecutor.BatchExecutionContext<JoinTask> batchExecutionContext) throws Exception Description copied from interface:ClusterStateTaskExecutor
Update the cluster state based on the current state and the given tasks. ReturnbatchExecutionContext.initialState()
to avoid publishing any update.If this method throws an exception then the cluster state is unchanged and every task's
ClusterStateTaskListener.onFailure(java.lang.Exception)
method is called.A common implementation pattern is to iterate through the tasks, constructing a new and updated
ClusterState
for each one. This works ok but beware that constructing a whole newClusterState
can be somewhat expensive, and there may sometimes be surprisingly many tasks to process in the batch. If it's possible to accumulate the effects of the tasks at a lower level then you should do that instead.Returning
batchExecutionContext.initialState()
is an important and useful optimisation in most cases, but note that this fast-path exposes APIs to the risk of stale reads in the vicinity of a master failover: a nodeN
that handles such a no-op task batch does not verify with its peers that it's still the master, and if it's not the master then another nodeM
may already have become master and updated the state in a way that would be inconsistent with the response thatN
sends back to clients.- Specified by:
execute
in interfaceClusterStateTaskExecutor<JoinTask>
- Returns:
- The resulting cluster state after executing all the tasks. If
batchExecutionContext.initialState()
is returned then no update is published. - Throws:
Exception
-
becomeMasterAndTrimConflictingNodes
protected ClusterState.Builder becomeMasterAndTrimConflictingNodes(ClusterState currentState, List<? extends ClusterStateTaskExecutor.TaskContext<JoinTask>> taskContexts, long term) -
runOnlyOnMaster
public boolean runOnlyOnMaster()- Specified by:
runOnlyOnMaster
in interfaceClusterStateTaskExecutor<JoinTask>
- Returns:
true
iff this executor should only run on the elected master.
-
ensureIndexCompatibility
public static void ensureIndexCompatibility(IndexVersion minSupportedVersion, IndexVersion maxSupportedVersion, Metadata metadata) Ensures that all indices are compatible with the given index version. This will ensure that all indices in the given metadata will not be created with a newer version of elasticsearch as well as that all indices are newer or equal to the minimum index compatibility version.- Throws:
IllegalStateException
- if any index is incompatible with the given version- See Also:
-
ensureNodesCompatibility
public static void ensureNodesCompatibility(Version joiningNodeVersion, DiscoveryNodes currentNodes) ensures that the joining node has a version that's compatible with all current nodes -
ensureNodesCompatibility
public static void ensureNodesCompatibility(Version joiningNodeVersion, Version minClusterNodeVersion, Version maxClusterNodeVersion) ensures that the joining node has a version that's compatible with a given version range -
ensureVersionBarrier
ensures that the joining node's version is equal or higher to the minClusterNodeVersion. This is needed to ensure that if the master is already fully operating under the new version, it doesn't go back to mixed version mode -
addBuiltInJoinValidators
public static Collection<BiConsumer<DiscoveryNode,ClusterState>> addBuiltInJoinValidators(Collection<BiConsumer<DiscoveryNode, ClusterState>> onJoinValidators)
-