Skip to content

Commit

Permalink
Update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
thecoop committed Dec 9, 2024
1 parent 86e0171 commit a2c71a7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,27 +89,15 @@ private Set<String> allNodeFeatures() {

/**
* Returns {@code true} if {@code node} can have assumed features.
* <p>
* This is true if it is of the next major version, or it is running on serverless.<br/>
* The next major version can be assumed because the next major version can only ever
* talk to the highest minor of the previous major, so any features added before that
* will always exist on the cluster.<br/>
* It can be assumed for serverless because we never go backwards on serverless,
* so once a feature is in the serverless environment it will always be there.
* @see {@link org.elasticsearch.env.BuildVersion#canRemoveAssumedFeatures}
*/
public static boolean featuresCanBeAssumedForNode(DiscoveryNode node) {
return node.getBuildVersion().canRemoveAssumedFeatures();
}

/**
* Returns {@code true} if one or more nodes in {@code nodes} can have assumed features.
* <p>
* This is true if it is of the next major version, or it is running on serverless.<br/>
* The next major version can be assumed because the next major version can only ever
* talk to the highest minor of the previous major, so any features added before that point
* will always exist on the cluster.<br/>
* It can be assumed for serverless because we never go backwards on serverless,
* so once a feature is in the serverless environment it will always be there.
* @see {@link org.elasticsearch.env.BuildVersion#canRemoveAssumedFeatures}
*/
public static boolean featuresCanBeAssumedForNodes(DiscoveryNodes nodes) {
return nodes.getAllNodes().stream().anyMatch(n -> n.getBuildVersion().canRemoveAssumedFeatures());
Expand Down
3 changes: 2 additions & 1 deletion server/src/main/java/org/elasticsearch/env/BuildVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
public abstract class BuildVersion implements ToXContentFragment, Writeable {

/**
* Checks if this version can have features removed that are assumed in the currently running Elasticsearch.
* Checks if this version can operate properly in a cluster without features
* that are assumed in the currently running Elasticsearch.
*/
public abstract boolean canRemoveAssumedFeatures();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ final class DefaultBuildVersion extends BuildVersion {

@Override
public boolean canRemoveAssumedFeatures() {
/*
* We can remove assumed features if the node version is the next major version.
* This is because the next major version can only form a cluster with the
* latest minor version of the previous major, so any features introduced before that point
* (that are marked as assumed in the running code version) are automatically met by that version.
*/
return version.major == Version.CURRENT.major + 1;
}

Expand Down

0 comments on commit a2c71a7

Please sign in to comment.