- All Implemented Interfaces:
Iterable<DesiredNodeWithStatus>,Writeable,ToXContent,ToXContentObject
Desired nodes represents the cluster topology that the operator of the cluster is aiming for.
Therefore, it is possible that the desired nodes contain nodes that are not part of the
cluster in contrast to DiscoveryNodes that contains only nodes that are part of the cluster.
This concept is useful as it provides more context about future topology changes to the system as well as the desired set of nodes in the cluster, allowing it to make better decisions about allocation, autoscaling, auto-expand replicas, etc.
Additionally, settings validation is done during desired nodes updates avoiding boot-looping when an invalid setting is provided before the node is started.
To modify the desired nodes it is necessary to provide the entire collection of nodes that will be part of the proposed cluster topology.
Desired nodes are expected to be part of a lineage defined by the provided historyId.
The historyId is provided by the orchestrator taking care of managing the cluster.
In order to identify the different proposed desired nodes within the same history, it is
also expected that the orchestrator provides a monotonically increasing version
when it communicates about future topology changes.
The cluster rejects desired nodes updated with a version less than or equal
than the current version for the same historyId.
The historyId is expected to remain stable during the cluster lifecycle, but it is
possible that the orchestrator loses its own state and needs to be restored to a
previous point in time with an older desired nodes version. In those cases it is
expected to use new historyId that would allow starting from a different version.
Each DesiredNode part of DesiredNodes has a DesiredNodeWithStatus.Status
depending on whether or not the node has been part of the cluster at some point.
DesiredNodeWithStatus.Status are:
PENDING: TheDesiredNodeis not part of the cluster yetACTUALIZED: TheDesiredNodeis or has been part of the cluster. Notice that it is possible that a node hasACTUALIZEDstatus but it is not part ofDiscoveryNodes, this is a conscious decision as it is expected that nodes can leave the cluster momentarily due to network issues, gc pressure, restarts, hardware failures etc, but are expected to still be part of the cluster.
See NodeJoinExecutor and TransportUpdateDesiredNodesAction for more details about desired nodes status tracking.
Finally, each DesiredNode is expected to provide a way of identifying the node when it joins,
Node.NODE_EXTERNAL_ID_SETTING allows providing that identity through settings.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.ParamsNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final ConstructingObjectParser<DesiredNodes, Void> Fields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY, EMPTY_PARAMS -
Method Summary
Modifier and TypeMethodDescriptionstatic DesiredNodescreate(String historyID, long version, List<DesiredNodeWithStatus> nodes) static DesiredNodescreateIncludingStatusFromPreviousVersion(String historyId, long version, List<DesiredNode> nodes, DesiredNodes previousDesiredNodes) booleanbooleanbooleaninthashCode()booleanhasSameHistoryId(DesiredNodes other) booleanhasSameVersion(DesiredNodes other) booleanisSupersededBy(DesiredNodes otherDesiredNodes) iterator()static DesiredNodeslatestFromClusterState(ClusterState clusterState) nodes()pending()static DesiredNodesreadFrom(StreamInput in) toString()toXContent(XContentBuilder builder, ToXContent.Params params) static ClusterStateupdateDesiredNodesStatusIfNeeded(ClusterState clusterState) static DesiredNodesupdateDesiredNodesStatusIfNeeded(DiscoveryNodes discoveryNodes, DesiredNodes desiredNodes) longversion()voidwriteTo(StreamOutput out) Write this into the StreamOutput.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface org.elasticsearch.xcontent.ToXContentObject
isFragment
-
Field Details
-
CONTEXT_MODE_PARAM
- See Also:
-
CONTEXT_MODE_API
-
CONTEXT_MODE_CLUSTER_STATE
-
PARSER
-
-
Method Details
-
readFrom
- Throws:
IOException
-
writeTo
Description copied from interface:WriteableWrite this into the StreamOutput.- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Specified by:
toXContentin interfaceToXContent- Throws:
IOException
-
createIncludingStatusFromPreviousVersion
public static DesiredNodes createIncludingStatusFromPreviousVersion(String historyId, long version, List<DesiredNode> nodes, @Nullable DesiredNodes previousDesiredNodes) -
create
public static DesiredNodes create(String historyID, long version, List<DesiredNodeWithStatus> nodes) -
latestFromClusterState
-
isSupersededBy
-
hasSameVersion
-
hasSameHistoryId
-
equalsWithProcessorsCloseTo
-
equalsNodesWithProcessorsCloseTo
-
equals
-
hashCode
public int hashCode() -
toString
-
historyID
-
version
public long version() -
nodes
-
actualized
-
pending
-
iterator
- Specified by:
iteratorin interfaceIterable<DesiredNodeWithStatus>
-
find
-
updateDesiredNodesStatusIfNeeded
-
updateDesiredNodesStatusIfNeeded
public static DesiredNodes updateDesiredNodesStatusIfNeeded(DiscoveryNodes discoveryNodes, DesiredNodes desiredNodes)
-