-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Make TransportGetSnapshotLifecycleStatsAction project aware #132289
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
base: main
Are you sure you want to change the base?
Changes from all commits
7ee8bc9
29f11eb
eb11fd0
c928763
edb43e5
4dfe026
e8ec4d1
e52c7a4
2593c39
72fb540
22a9039
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -9,16 +9,22 @@ | |||||||||||
|
|
||||||||||||
| import org.elasticsearch.action.ActionResponse; | ||||||||||||
| import org.elasticsearch.action.ActionType; | ||||||||||||
| import org.elasticsearch.action.support.local.LocalClusterStateRequest; | ||||||||||||
| import org.elasticsearch.action.support.master.AcknowledgedRequest; | ||||||||||||
| import org.elasticsearch.common.Strings; | ||||||||||||
| import org.elasticsearch.common.io.stream.StreamInput; | ||||||||||||
| import org.elasticsearch.common.io.stream.StreamOutput; | ||||||||||||
| import org.elasticsearch.core.TimeValue; | ||||||||||||
| import org.elasticsearch.core.UpdateForV10; | ||||||||||||
| import org.elasticsearch.xcontent.ToXContentObject; | ||||||||||||
| import org.elasticsearch.xcontent.XContentBuilder; | ||||||||||||
| import org.elasticsearch.xpack.core.slm.SnapshotLifecycleStats; | ||||||||||||
|
|
||||||||||||
| import java.io.IOException; | ||||||||||||
| import java.util.Objects; | ||||||||||||
|
|
||||||||||||
| import static org.elasticsearch.TransportVersions.SLM_GET_STATS_CHANGE_REQUEST_TYPE; | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * This class represents the action of retriving the stats for snapshot lifecycle management. | ||||||||||||
| * These are retrieved from the master's cluster state and contain numbers related to the count of | ||||||||||||
|
|
@@ -32,6 +38,33 @@ protected GetSnapshotLifecycleStatsAction() { | |||||||||||
| super(NAME); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| public static class Request extends LocalClusterStateRequest { | ||||||||||||
|
|
||||||||||||
| public Request(TimeValue masterNodeTimeout) { | ||||||||||||
| super(masterNodeTimeout); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| // private, to avoid non-backwards compatible use | ||||||||||||
| private Request(StreamInput input) throws IOException { | ||||||||||||
| super(input); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * Previously this request was an AcknowledgedRequest, which had an ack timeout, and the action was an MasterNodeAction. | ||||||||||||
| * This method only exists for backward compatibility to deserialize request from previous versions. | ||||||||||||
| */ | ||||||||||||
| @UpdateForV10(owner = UpdateForV10.Owner.DATA_MANAGEMENT) | ||||||||||||
| public static Request read(StreamInput input) throws IOException { | ||||||||||||
| if (input.getTransportVersion().onOrAfter(SLM_GET_STATS_CHANGE_REQUEST_TYPE)) { | ||||||||||||
| return new Request(input); | ||||||||||||
|
Comment on lines
+58
to
+59
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. We don't actually need this transport version check (or the new transport version), as this branch will never fire. Any node that is on this transport version will execute the request locally, instead of forwarding it to the master node. Therefore, if we receive this request over the transport wire, we already know it's from an old node. Also, we don't need this separate deserialization method, we can do this in the constructor like we do here: Lines 48 to 52 in d8257b4
|
||||||||||||
| } else { | ||||||||||||
| var requestBwc = new AcknowledgedRequest.Plain(input); | ||||||||||||
| return new Request(requestBwc.masterNodeTimeout()); | ||||||||||||
| } | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| public static class Response extends ActionResponse implements ToXContentObject { | ||||||||||||
|
|
||||||||||||
| private SnapshotLifecycleStats slmStats; | ||||||||||||
|
|
||||||||||||
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 can also remove the
Response(StreamInput in)constructor below, as we'll know for sure that we'll never have to deserialize a response anymore (because any node on this version will run the request locally).And can you add a
@UpdateForV10(owner = UpdateForV10.Owner.DATA_MANAGEMENT)line to theResponse#writeTomethod? When we get to V10, we won't need that method either anymore.