-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Adding dry_run mode for setting data stream settings #128269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
masseyke
merged 11 commits into
elastic:main
from
masseyke:data-stream-settings-dry-run
May 23, 2025
Merged
Changes from 5 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
f9fdaa3
Adding dry_run mode for setting data stream settings
masseyke 353d1d1
testing
masseyke 83ea386
merging main
masseyke cc19fbd
commenting, improving readability
masseyke f5bdf7b
adding a comment
masseyke 67c4177
Merge branch 'main' into data-stream-settings-dry-run
masseyke 051d7f0
pulling out UpdateSingleIndexSettingsListener into its own class
masseyke 59b8079
reverting accidental change
masseyke 39cf10e
using helper methods for action listeners
masseyke 6fda776
using wrap rather than both delegateFailure and delegateResponse
masseyke e161504
merging main
masseyke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |
|
|
||
| package org.elasticsearch.action.datastreams; | ||
|
|
||
| import org.elasticsearch.TransportVersions; | ||
| import org.elasticsearch.action.ActionResponse; | ||
| import org.elasticsearch.action.ActionType; | ||
| import org.elasticsearch.action.IndicesRequest; | ||
|
|
@@ -47,10 +48,16 @@ public UpdateDataStreamSettingsAction() { | |
| public static class Request extends AcknowledgedRequest<Request> implements IndicesRequest.Replaceable { | ||
| private final Settings settings; | ||
| private String[] dataStreamNames = Strings.EMPTY_ARRAY; | ||
| private final boolean dryRun; | ||
|
|
||
| public Request(Settings settings, TimeValue masterNodeTimeout, TimeValue ackTimeout) { | ||
| this(settings, false, masterNodeTimeout, ackTimeout); | ||
| } | ||
|
|
||
| public Request(Settings settings, boolean dryRun, TimeValue masterNodeTimeout, TimeValue ackTimeout) { | ||
| super(masterNodeTimeout, ackTimeout); | ||
| this.settings = settings; | ||
| this.dryRun = dryRun; | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -63,6 +70,10 @@ public Settings getSettings() { | |
| return settings; | ||
| } | ||
|
|
||
| public boolean isDryRun() { | ||
| return dryRun; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean includeDataStreams() { | ||
| return true; | ||
|
|
@@ -72,13 +83,21 @@ public Request(StreamInput in) throws IOException { | |
| super(in); | ||
| this.dataStreamNames = in.readStringArray(); | ||
| this.settings = Settings.readSettingsFromStream(in); | ||
| if (in.getTransportVersion().onOrAfter(TransportVersions.SETTINGS_IN_DATA_STREAMS)) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this be |
||
| this.dryRun = in.readBoolean(); | ||
| } else { | ||
| this.dryRun = false; | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void writeTo(StreamOutput out) throws IOException { | ||
| super.writeTo(out); | ||
| out.writeStringArray(dataStreamNames); | ||
| settings.writeTo(out); | ||
| if (out.getTransportVersion().onOrAfter(TransportVersions.SETTINGS_IN_DATA_STREAMS_DRY_RUN)) { | ||
| out.writeBoolean(dryRun); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -103,13 +122,14 @@ public boolean equals(Object o) { | |
| Request request = (Request) o; | ||
| return Arrays.equals(dataStreamNames, request.dataStreamNames) | ||
| && settings.equals(request.settings) | ||
| && dryRun == request.dryRun | ||
| && Objects.equals(masterNodeTimeout(), request.masterNodeTimeout()) | ||
| && Objects.equals(ackTimeout(), request.ackTimeout()); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hash(Arrays.hashCode(dataStreamNames), settings, masterNodeTimeout(), ackTimeout()); | ||
| return Objects.hash(Arrays.hashCode(dataStreamNames), settings, dryRun, masterNodeTimeout(), ackTimeout()); | ||
| } | ||
|
|
||
| } | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're getting quite deeply nested at this point. Is it worth pulling out some of these blocks into methods / inner classes for readability?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK I switched everything over to ActionListeners helper methods rather than creating my own ActionListeners. I think it improves readability a bit. Let me know what you think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks :-) Yeah I think that's a little easier on the eyes 👍🏻