Skip to content

Commit feec6c7

Browse files
authored
[Failure store - selector syntax] Refactor IndicesOptions builder (#114597) (#114622)
**Introduction** > In order to make adoption of failure stores simpler for all users, we are introducing a new syntactical feature to index expression resolution: The selector. > > Selectors, denoted with a :: followed by a recognized suffix will allow users to specify which component of an index abstraction they would like to operate on within an API call. In this case, an index abstraction is a concrete index, data stream, or alias; Any abstraction that can be resolved to a set of indices/shards. We define a component of an index abstraction to be some searchable unit of the index abstraction. > > To start, we will support two components: data and failures. Concrete indices are their own data components, while the data component for index aliases are all of the indices contained therein. For data streams, the data component corresponds to their backing indices. Data stream aliases mirror this, treating all backing indices of the data streams they correspond to as their data component. > > The failure component is only supported by data streams and data stream aliases. The failure component of these abstractions refer to the data streams' failure stores. Indices and index aliases do not have a failure component. For more details and examples see #113144. All this work has been cherry picked from there. **Purpose of this PR** This PR is replacing the the indices options boolean constructor with the builders. The goal is to give me and the reviewer a very narrow scope change when we can ensure we did not make any mistakes during the conversion. Also it will reduce a bit the change list in https://github.com/elastic/elasticsearch/pull/113144/files.
1 parent 1ad4ae1 commit feec6c7

File tree

8 files changed

+164
-17
lines changed

8 files changed

+164
-17
lines changed

modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/action/DeleteDataStreamLifecycleAction.java

+20-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,26 @@ private DeleteDataStreamLifecycleAction() {/* no instances */}
3434
public static final class Request extends AcknowledgedRequest<Request> implements IndicesRequest.Replaceable {
3535

3636
private String[] names;
37-
private IndicesOptions indicesOptions = IndicesOptions.fromOptions(false, true, true, true, false, false, true, false);
37+
private IndicesOptions indicesOptions = IndicesOptions.builder()
38+
.concreteTargetOptions(IndicesOptions.ConcreteTargetOptions.ERROR_WHEN_UNAVAILABLE_TARGETS)
39+
.wildcardOptions(
40+
IndicesOptions.WildcardOptions.builder()
41+
.matchOpen(true)
42+
.matchClosed(true)
43+
.includeHidden(false)
44+
.resolveAliases(false)
45+
.allowEmptyExpressions(true)
46+
.build()
47+
)
48+
.gatekeeperOptions(
49+
IndicesOptions.GatekeeperOptions.builder()
50+
.allowAliasToMultipleIndices(false)
51+
.allowClosedIndices(true)
52+
.ignoreThrottled(false)
53+
.allowFailureIndices(false)
54+
.build()
55+
)
56+
.build();
3857

3958
public Request(StreamInput in) throws IOException {
4059
super(in);

server/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesRequest.java

+20-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,26 @@ public class IndicesAliasesRequest extends AcknowledgedRequest<IndicesAliasesReq
5858
// indices options that require every specified index to exist, expand wildcards only to open
5959
// indices, don't allow that no indices are resolved from wildcard expressions and resolve the
6060
// expressions only against indices
61-
private static final IndicesOptions INDICES_OPTIONS = IndicesOptions.fromOptions(false, false, true, false, true, false, true, false);
61+
private static final IndicesOptions INDICES_OPTIONS = IndicesOptions.builder()
62+
.concreteTargetOptions(IndicesOptions.ConcreteTargetOptions.ERROR_WHEN_UNAVAILABLE_TARGETS)
63+
.wildcardOptions(
64+
IndicesOptions.WildcardOptions.builder()
65+
.matchOpen(true)
66+
.matchClosed(false)
67+
.includeHidden(false)
68+
.resolveAliases(false)
69+
.allowEmptyExpressions(false)
70+
.build()
71+
)
72+
.gatekeeperOptions(
73+
IndicesOptions.GatekeeperOptions.builder()
74+
.allowAliasToMultipleIndices(true)
75+
.allowClosedIndices(true)
76+
.ignoreThrottled(false)
77+
.allowFailureIndices(true)
78+
.build()
79+
)
80+
.build();
6281

6382
public IndicesAliasesRequest(StreamInput in) throws IOException {
6483
super(in);

server/src/main/java/org/elasticsearch/action/admin/indices/delete/DeleteIndexRequest.java

+19-10
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,25 @@
2828
*/
2929
public class DeleteIndexRequest extends AcknowledgedRequest<DeleteIndexRequest> implements IndicesRequest.Replaceable {
3030

31-
public static final IndicesOptions DEFAULT_INDICES_OPTIONS = IndicesOptions.fromOptions(
32-
false,
33-
true,
34-
true,
35-
true,
36-
false,
37-
false,
38-
true,
39-
false
40-
);
31+
public static final IndicesOptions DEFAULT_INDICES_OPTIONS = IndicesOptions.builder()
32+
.concreteTargetOptions(IndicesOptions.ConcreteTargetOptions.ERROR_WHEN_UNAVAILABLE_TARGETS)
33+
.wildcardOptions(
34+
IndicesOptions.WildcardOptions.builder()
35+
.matchOpen(true)
36+
.matchClosed(true)
37+
.allowEmptyExpressions(true)
38+
.resolveAliases(false)
39+
.build()
40+
)
41+
.gatekeeperOptions(
42+
IndicesOptions.GatekeeperOptions.builder()
43+
.allowAliasToMultipleIndices(false)
44+
.allowClosedIndices(true)
45+
.ignoreThrottled(false)
46+
.allowFailureIndices(true)
47+
.build()
48+
)
49+
.build();
4150

4251
private String[] indices;
4352
// Delete index should work by default on both open and closed indices.

server/src/main/java/org/elasticsearch/action/datastreams/DataStreamsStatsAction.java

+26-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,32 @@ public static class Request extends BroadcastRequest<Request> {
4040
public Request() {
4141
// this doesn't really matter since data stream name resolution isn't affected by IndicesOptions and
4242
// a data stream's backing indices are retrieved from its metadata
43-
super(null, IndicesOptions.fromOptions(false, true, true, true, true, false, true, false));
43+
super(
44+
null,
45+
IndicesOptions.builder()
46+
.concreteTargetOptions(IndicesOptions.ConcreteTargetOptions.ERROR_WHEN_UNAVAILABLE_TARGETS)
47+
.wildcardOptions(
48+
IndicesOptions.WildcardOptions.builder()
49+
.matchOpen(true)
50+
.matchClosed(true)
51+
.includeHidden(false)
52+
.resolveAliases(false)
53+
.allowEmptyExpressions(true)
54+
.build()
55+
)
56+
.gatekeeperOptions(
57+
IndicesOptions.GatekeeperOptions.builder()
58+
.allowAliasToMultipleIndices(true)
59+
.allowClosedIndices(true)
60+
.ignoreThrottled(false)
61+
.allowFailureIndices(true)
62+
.build()
63+
)
64+
.failureStoreOptions(
65+
IndicesOptions.FailureStoreOptions.builder().includeRegularIndices(true).includeFailureIndices(true).build()
66+
)
67+
.build()
68+
);
4469
}
4570

4671
public Request(StreamInput in) throws IOException {

server/src/main/java/org/elasticsearch/action/datastreams/DeleteDataStreamAction.java

+19-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,25 @@ public static class Request extends MasterNodeRequest<Request> implements Indice
4646
// empty response can be returned in case wildcards were used or
4747
// 404 status code returned in case no wildcard were used.
4848
private final boolean wildcardExpressionsOriginallySpecified;
49-
private IndicesOptions indicesOptions = IndicesOptions.fromOptions(false, true, true, true, false, false, true, false);
49+
private IndicesOptions indicesOptions = IndicesOptions.builder()
50+
.concreteTargetOptions(IndicesOptions.ConcreteTargetOptions.ERROR_WHEN_UNAVAILABLE_TARGETS)
51+
.wildcardOptions(
52+
IndicesOptions.WildcardOptions.builder()
53+
.matchOpen(true)
54+
.matchClosed(true)
55+
.resolveAliases(false)
56+
.allowEmptyExpressions(true)
57+
.build()
58+
)
59+
.gatekeeperOptions(
60+
IndicesOptions.GatekeeperOptions.builder()
61+
.allowAliasToMultipleIndices(false)
62+
.allowClosedIndices(true)
63+
.ignoreThrottled(false)
64+
.allowFailureIndices(true)
65+
.build()
66+
)
67+
.build();
5068

5169
public Request(TimeValue masterNodeTimeout, String... names) {
5270
super(masterNodeTimeout);

server/src/main/java/org/elasticsearch/action/datastreams/GetDataStreamAction.java

+20-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,26 @@ private GetDataStreamAction() {
5656
public static class Request extends MasterNodeReadRequest<Request> implements IndicesRequest.Replaceable {
5757

5858
private String[] names;
59-
private IndicesOptions indicesOptions = IndicesOptions.fromOptions(false, true, true, true, false, false, true, false);
59+
private IndicesOptions indicesOptions = IndicesOptions.builder()
60+
.concreteTargetOptions(IndicesOptions.ConcreteTargetOptions.ERROR_WHEN_UNAVAILABLE_TARGETS)
61+
.wildcardOptions(
62+
IndicesOptions.WildcardOptions.builder()
63+
.matchOpen(true)
64+
.matchClosed(true)
65+
.includeHidden(false)
66+
.resolveAliases(false)
67+
.allowEmptyExpressions(true)
68+
.build()
69+
)
70+
.gatekeeperOptions(
71+
IndicesOptions.GatekeeperOptions.builder()
72+
.allowAliasToMultipleIndices(false)
73+
.allowClosedIndices(true)
74+
.ignoreThrottled(false)
75+
.allowFailureIndices(true)
76+
.build()
77+
)
78+
.build();
6079
private boolean includeDefaults = false;
6180
private boolean verbose = false;
6281

server/src/main/java/org/elasticsearch/action/datastreams/lifecycle/GetDataStreamLifecycleAction.java

+20-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,26 @@ private GetDataStreamLifecycleAction() {/* no instances */}
4747
public static class Request extends MasterNodeReadRequest<Request> implements IndicesRequest.Replaceable {
4848

4949
private String[] names;
50-
private IndicesOptions indicesOptions = IndicesOptions.fromOptions(false, true, true, true, false, false, true, false);
50+
private IndicesOptions indicesOptions = IndicesOptions.builder()
51+
.concreteTargetOptions(IndicesOptions.ConcreteTargetOptions.ERROR_WHEN_UNAVAILABLE_TARGETS)
52+
.wildcardOptions(
53+
IndicesOptions.WildcardOptions.builder()
54+
.matchOpen(true)
55+
.matchClosed(true)
56+
.includeHidden(false)
57+
.resolveAliases(false)
58+
.allowEmptyExpressions(true)
59+
.build()
60+
)
61+
.gatekeeperOptions(
62+
IndicesOptions.GatekeeperOptions.builder()
63+
.allowAliasToMultipleIndices(false)
64+
.allowClosedIndices(true)
65+
.ignoreThrottled(false)
66+
.allowFailureIndices(true)
67+
.build()
68+
)
69+
.build();
5170
private boolean includeDefaults = false;
5271

5372
public Request(TimeValue masterNodeTimeout, String[] names) {

server/src/main/java/org/elasticsearch/action/datastreams/lifecycle/PutDataStreamLifecycleAction.java

+20-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,26 @@ public static Request parseRequest(XContentParser parser, Factory factory) {
7878
}
7979

8080
private String[] names;
81-
private IndicesOptions indicesOptions = IndicesOptions.fromOptions(false, true, true, true, false, false, true, false);
81+
private IndicesOptions indicesOptions = IndicesOptions.builder()
82+
.concreteTargetOptions(IndicesOptions.ConcreteTargetOptions.ERROR_WHEN_UNAVAILABLE_TARGETS)
83+
.wildcardOptions(
84+
IndicesOptions.WildcardOptions.builder()
85+
.matchOpen(true)
86+
.matchClosed(true)
87+
.includeHidden(false)
88+
.resolveAliases(false)
89+
.allowEmptyExpressions(true)
90+
.build()
91+
)
92+
.gatekeeperOptions(
93+
IndicesOptions.GatekeeperOptions.builder()
94+
.allowAliasToMultipleIndices(false)
95+
.allowClosedIndices(true)
96+
.ignoreThrottled(false)
97+
.allowFailureIndices(false)
98+
.build()
99+
)
100+
.build();
82101
private final DataStreamLifecycle lifecycle;
83102

84103
public Request(StreamInput in) throws IOException {

0 commit comments

Comments
 (0)