Skip to content

Commit 35f4d4c

Browse files
authored
Improve the javadocs around features infrastructure (elastic#106292)
1 parent e6d1c90 commit 35f4d4c

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

server/src/main/java/org/elasticsearch/features/FeatureService.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
import java.util.Set;
2121

2222
/**
23-
* Manages information on the features supported by nodes in the cluster
23+
* Manages information on the features supported by nodes in the cluster.
24+
* For more information, see {@link FeatureSpecification}.
2425
*/
2526
public class FeatureService {
2627

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

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

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

4853
/**
4954
* The non-historical features supported by this node.
55+
* @return Map of {@code feature-id} to its declaring {@code NodeFeature} object.
5056
*/
5157
public Map<String, NodeFeature> getNodeFeatures() {
5258
return nodeFeatures;

server/src/main/java/org/elasticsearch/features/FeatureSpecification.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@
1515

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

2738
/**
28-
* Returns information on historical features that should be added to all nodes at or above the {@link Version} specified.
39+
* Returns information on historical features that should be deemed to be present on all nodes
40+
* on or above the {@link Version} specified.
2941
*/
3042
default Map<NodeFeature, Version> getHistoricalFeatures() {
3143
return Map.of();

0 commit comments

Comments
 (0)