Skip to content

Commit

Permalink
[Failure store - selector syntax] Refactor IndicesOptions builder (#1…
Browse files Browse the repository at this point in the history
…14597) (#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.
  • Loading branch information
gmarouli authored Oct 11, 2024
1 parent 1ad4ae1 commit feec6c7
Show file tree
Hide file tree
Showing 8 changed files with 164 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,26 @@ private DeleteDataStreamLifecycleAction() {/* no instances */}
public static final class Request extends AcknowledgedRequest<Request> implements IndicesRequest.Replaceable {

private String[] names;
private IndicesOptions indicesOptions = IndicesOptions.fromOptions(false, true, true, true, false, false, true, false);
private IndicesOptions indicesOptions = IndicesOptions.builder()
.concreteTargetOptions(IndicesOptions.ConcreteTargetOptions.ERROR_WHEN_UNAVAILABLE_TARGETS)
.wildcardOptions(
IndicesOptions.WildcardOptions.builder()
.matchOpen(true)
.matchClosed(true)
.includeHidden(false)
.resolveAliases(false)
.allowEmptyExpressions(true)
.build()
)
.gatekeeperOptions(
IndicesOptions.GatekeeperOptions.builder()
.allowAliasToMultipleIndices(false)
.allowClosedIndices(true)
.ignoreThrottled(false)
.allowFailureIndices(false)
.build()
)
.build();

public Request(StreamInput in) throws IOException {
super(in);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,26 @@ public class IndicesAliasesRequest extends AcknowledgedRequest<IndicesAliasesReq
// indices options that require every specified index to exist, expand wildcards only to open
// indices, don't allow that no indices are resolved from wildcard expressions and resolve the
// expressions only against indices
private static final IndicesOptions INDICES_OPTIONS = IndicesOptions.fromOptions(false, false, true, false, true, false, true, false);
private static final IndicesOptions INDICES_OPTIONS = IndicesOptions.builder()
.concreteTargetOptions(IndicesOptions.ConcreteTargetOptions.ERROR_WHEN_UNAVAILABLE_TARGETS)
.wildcardOptions(
IndicesOptions.WildcardOptions.builder()
.matchOpen(true)
.matchClosed(false)
.includeHidden(false)
.resolveAliases(false)
.allowEmptyExpressions(false)
.build()
)
.gatekeeperOptions(
IndicesOptions.GatekeeperOptions.builder()
.allowAliasToMultipleIndices(true)
.allowClosedIndices(true)
.ignoreThrottled(false)
.allowFailureIndices(true)
.build()
)
.build();

public IndicesAliasesRequest(StreamInput in) throws IOException {
super(in);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,25 @@
*/
public class DeleteIndexRequest extends AcknowledgedRequest<DeleteIndexRequest> implements IndicesRequest.Replaceable {

public static final IndicesOptions DEFAULT_INDICES_OPTIONS = IndicesOptions.fromOptions(
false,
true,
true,
true,
false,
false,
true,
false
);
public static final IndicesOptions DEFAULT_INDICES_OPTIONS = IndicesOptions.builder()
.concreteTargetOptions(IndicesOptions.ConcreteTargetOptions.ERROR_WHEN_UNAVAILABLE_TARGETS)
.wildcardOptions(
IndicesOptions.WildcardOptions.builder()
.matchOpen(true)
.matchClosed(true)
.allowEmptyExpressions(true)
.resolveAliases(false)
.build()
)
.gatekeeperOptions(
IndicesOptions.GatekeeperOptions.builder()
.allowAliasToMultipleIndices(false)
.allowClosedIndices(true)
.ignoreThrottled(false)
.allowFailureIndices(true)
.build()
)
.build();

private String[] indices;
// Delete index should work by default on both open and closed indices.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,32 @@ public static class Request extends BroadcastRequest<Request> {
public Request() {
// this doesn't really matter since data stream name resolution isn't affected by IndicesOptions and
// a data stream's backing indices are retrieved from its metadata
super(null, IndicesOptions.fromOptions(false, true, true, true, true, false, true, false));
super(
null,
IndicesOptions.builder()
.concreteTargetOptions(IndicesOptions.ConcreteTargetOptions.ERROR_WHEN_UNAVAILABLE_TARGETS)
.wildcardOptions(
IndicesOptions.WildcardOptions.builder()
.matchOpen(true)
.matchClosed(true)
.includeHidden(false)
.resolveAliases(false)
.allowEmptyExpressions(true)
.build()
)
.gatekeeperOptions(
IndicesOptions.GatekeeperOptions.builder()
.allowAliasToMultipleIndices(true)
.allowClosedIndices(true)
.ignoreThrottled(false)
.allowFailureIndices(true)
.build()
)
.failureStoreOptions(
IndicesOptions.FailureStoreOptions.builder().includeRegularIndices(true).includeFailureIndices(true).build()
)
.build()
);
}

public Request(StreamInput in) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,25 @@ public static class Request extends MasterNodeRequest<Request> implements Indice
// empty response can be returned in case wildcards were used or
// 404 status code returned in case no wildcard were used.
private final boolean wildcardExpressionsOriginallySpecified;
private IndicesOptions indicesOptions = IndicesOptions.fromOptions(false, true, true, true, false, false, true, false);
private IndicesOptions indicesOptions = IndicesOptions.builder()
.concreteTargetOptions(IndicesOptions.ConcreteTargetOptions.ERROR_WHEN_UNAVAILABLE_TARGETS)
.wildcardOptions(
IndicesOptions.WildcardOptions.builder()
.matchOpen(true)
.matchClosed(true)
.resolveAliases(false)
.allowEmptyExpressions(true)
.build()
)
.gatekeeperOptions(
IndicesOptions.GatekeeperOptions.builder()
.allowAliasToMultipleIndices(false)
.allowClosedIndices(true)
.ignoreThrottled(false)
.allowFailureIndices(true)
.build()
)
.build();

public Request(TimeValue masterNodeTimeout, String... names) {
super(masterNodeTimeout);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,26 @@ private GetDataStreamAction() {
public static class Request extends MasterNodeReadRequest<Request> implements IndicesRequest.Replaceable {

private String[] names;
private IndicesOptions indicesOptions = IndicesOptions.fromOptions(false, true, true, true, false, false, true, false);
private IndicesOptions indicesOptions = IndicesOptions.builder()
.concreteTargetOptions(IndicesOptions.ConcreteTargetOptions.ERROR_WHEN_UNAVAILABLE_TARGETS)
.wildcardOptions(
IndicesOptions.WildcardOptions.builder()
.matchOpen(true)
.matchClosed(true)
.includeHidden(false)
.resolveAliases(false)
.allowEmptyExpressions(true)
.build()
)
.gatekeeperOptions(
IndicesOptions.GatekeeperOptions.builder()
.allowAliasToMultipleIndices(false)
.allowClosedIndices(true)
.ignoreThrottled(false)
.allowFailureIndices(true)
.build()
)
.build();
private boolean includeDefaults = false;
private boolean verbose = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,26 @@ private GetDataStreamLifecycleAction() {/* no instances */}
public static class Request extends MasterNodeReadRequest<Request> implements IndicesRequest.Replaceable {

private String[] names;
private IndicesOptions indicesOptions = IndicesOptions.fromOptions(false, true, true, true, false, false, true, false);
private IndicesOptions indicesOptions = IndicesOptions.builder()
.concreteTargetOptions(IndicesOptions.ConcreteTargetOptions.ERROR_WHEN_UNAVAILABLE_TARGETS)
.wildcardOptions(
IndicesOptions.WildcardOptions.builder()
.matchOpen(true)
.matchClosed(true)
.includeHidden(false)
.resolveAliases(false)
.allowEmptyExpressions(true)
.build()
)
.gatekeeperOptions(
IndicesOptions.GatekeeperOptions.builder()
.allowAliasToMultipleIndices(false)
.allowClosedIndices(true)
.ignoreThrottled(false)
.allowFailureIndices(true)
.build()
)
.build();
private boolean includeDefaults = false;

public Request(TimeValue masterNodeTimeout, String[] names) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,26 @@ public static Request parseRequest(XContentParser parser, Factory factory) {
}

private String[] names;
private IndicesOptions indicesOptions = IndicesOptions.fromOptions(false, true, true, true, false, false, true, false);
private IndicesOptions indicesOptions = IndicesOptions.builder()
.concreteTargetOptions(IndicesOptions.ConcreteTargetOptions.ERROR_WHEN_UNAVAILABLE_TARGETS)
.wildcardOptions(
IndicesOptions.WildcardOptions.builder()
.matchOpen(true)
.matchClosed(true)
.includeHidden(false)
.resolveAliases(false)
.allowEmptyExpressions(true)
.build()
)
.gatekeeperOptions(
IndicesOptions.GatekeeperOptions.builder()
.allowAliasToMultipleIndices(false)
.allowClosedIndices(true)
.ignoreThrottled(false)
.allowFailureIndices(false)
.build()
)
.build();
private final DataStreamLifecycle lifecycle;

public Request(StreamInput in) throws IOException {
Expand Down

0 comments on commit feec6c7

Please sign in to comment.