Skip to content

Commit

Permalink
Improve the javadocs around features infrastructure (elastic#106292)
Browse files Browse the repository at this point in the history
  • Loading branch information
thecoop authored Mar 13, 2024
1 parent e6d1c90 commit 35f4d4c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
import java.util.Set;

/**
* Manages information on the features supported by nodes in the cluster
* Manages information on the features supported by nodes in the cluster.
* For more information, see {@link FeatureSpecification}.
*/
public class FeatureService {

Expand All @@ -36,6 +37,10 @@ public class FeatureService {
private final NavigableMap<Version, Set<String>> historicalFeatures;
private final Map<String, NodeFeature> nodeFeatures;

/**
* Creates a new {@code FeatureService}, reporting all the features declared in {@code specs}
* as the local node's supported feature set
*/
public FeatureService(List<? extends FeatureSpecification> specs) {

var featureData = FeatureData.createFromSpecifications(specs);
Expand All @@ -47,6 +52,7 @@ public FeatureService(List<? extends FeatureSpecification> specs) {

/**
* The non-historical features supported by this node.
* @return Map of {@code feature-id} to its declaring {@code NodeFeature} object.
*/
public Map<String, NodeFeature> getNodeFeatures() {
return nodeFeatures;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@

/**
* Specifies one or more features that are supported by this node.
* <p>
* Features are published as part of node information in cluster state.
* Code can check if all nodes in a cluster support a feature using {@link FeatureService#clusterHasFeature}.
* Once all nodes in a cluster support a feature, other nodes are blocked from joining that cluster
* unless they also support that feature (this is known as the 'feature ratchet').
* So once a feature is supported by a cluster, it will always be supported by that cluster in the future.
* <p>
* The feature information in cluster state should not normally be directly accessed.
* All feature checks should be done through {@code FeatureService} to ensure that Elasticsearch's
* guarantees on the introduction of new functionality are followed;
* that is, new functionality is not enabled until all nodes in the cluster support it.
*/
public interface FeatureSpecification {
/**
Expand All @@ -25,7 +36,8 @@ default Set<NodeFeature> getFeatures() {
}

/**
* Returns information on historical features that should be added to all nodes at or above the {@link Version} specified.
* Returns information on historical features that should be deemed to be present on all nodes
* on or above the {@link Version} specified.
*/
default Map<NodeFeature, Version> getHistoricalFeatures() {
return Map.of();
Expand Down

0 comments on commit 35f4d4c

Please sign in to comment.