77
88package org .elasticsearch .xpack .core .slm .action ;
99
10- import org .elasticsearch .action .ActionRequestValidationException ;
1110import org .elasticsearch .action .ActionResponse ;
1211import org .elasticsearch .action .ActionType ;
12+ import org .elasticsearch .action .support .local .LocalClusterStateRequest ;
1313import org .elasticsearch .action .support .master .AcknowledgedRequest ;
14- import org .elasticsearch .action .support .master .MasterNodeReadRequest ;
1514import org .elasticsearch .common .Strings ;
1615import org .elasticsearch .common .io .stream .StreamInput ;
1716import org .elasticsearch .common .io .stream .StreamOutput ;
1817import org .elasticsearch .core .TimeValue ;
18+ import org .elasticsearch .core .UpdateForV10 ;
1919import org .elasticsearch .logging .LogManager ;
2020import org .elasticsearch .logging .Logger ;
2121import org .elasticsearch .xcontent .ToXContentObject ;
@@ -40,55 +40,50 @@ protected GetSnapshotLifecycleStatsAction() {
4040 super (NAME );
4141 }
4242
43- public static class Request extends MasterNodeReadRequest <Request > {
43+ public static class Request extends LocalClusterStateRequest {
44+ // TODO: remove
4445 private static final Logger logger = LogManager .getLogger (GetSnapshotLifecycleStatsAction .Request .class );
4546
46- // for backwards compatibility, store the ack timeout to maintain compatibility with AcknowledgedRequest used in previous versions
47- private final TimeValue ackTimeout ;
47+ // // for backwards compatibility, store the ack timeout to maintain compatibility with AcknowledgedRequest used in previous
48+ // versions
49+ // private final TimeValue ackTimeout;
4850
49- // private to avoid non-backwards compatible instantiation
50- private Request (StreamInput input ) throws IOException {
51- super (input );
52- this .ackTimeout = null ;
53- }
54-
55- // private, should not be used directly
56- private Request (TimeValue masterNodeTimeout , TimeValue ackTimeout ) {
51+ public Request (TimeValue masterNodeTimeout ) throws IOException {
5752 super (masterNodeTimeout );
58- this .ackTimeout = ackTimeout ;
53+ // this.ackTimeout = null ;
5954 }
6055
61- public Request (TimeValue masterNodeTimeout ) throws IOException {
62- super (masterNodeTimeout );
63- this .ackTimeout = null ;
56+ // private, to avoid non-backwards compatible use
57+ private Request (StreamInput input ) throws IOException {
58+ super (input );
59+ // this.ackTimeout = null;
6460 }
6561
62+ // private, should not be used directly
63+ // private Request(TimeValue masterNodeTimeout, TimeValue ackTimeout) {
64+ // super(masterNodeTimeout);
65+ // this.ackTimeout = ackTimeout;
66+ // }
67+
68+ /**
69+ * Previously this request was an AcknowledgedRequest, which had an ack timeout, and the action was an MasterNodeAction.
70+ * This method only exists for backward compatibility to deserialize request from previous versions.
71+ */
72+ @ UpdateForV10 (owner = UpdateForV10 .Owner .DATA_MANAGEMENT )
6673 public static Request read (StreamInput input ) throws IOException {
74+ // TODO: remove logs
6775 logger .info ("Reading GetSnapshotLifecycleStatsAction.Request from stream input" );
6876 if (input .getTransportVersion ().onOrAfter (SLM_GET_STATS_CHANGE_REQUEST_TYPE )) {
69- logger .info ("Reading old GetSnapshotLifecycleStatsAction.Request format" );
77+ logger .info ("Reading new GetSnapshotLifecycleStatsAction.Request format" );
7078 return new Request (input );
7179 } else {
72- logger .info ("Reading new GetSnapshotLifecycleStatsAction.Request format" );
80+ logger .info ("Reading old GetSnapshotLifecycleStatsAction.Request format" );
7381 var requestBwc = new AcknowledgedRequest .Plain (input );
74- return new GetSnapshotLifecycleStatsAction .Request (requestBwc .masterNodeTimeout (), requestBwc .ackTimeout ());
82+ // return new Request(requestBwc.masterNodeTimeout(), requestBwc.ackTimeout());
83+ return new Request (requestBwc .masterNodeTimeout ());
7584 }
7685 }
7786
78- @ Override
79- public void writeTo (StreamOutput out ) throws IOException {
80- if (out .getTransportVersion ().onOrAfter (SLM_GET_STATS_CHANGE_REQUEST_TYPE )) {
81- super .writeTo (out );
82- } else {
83- // For backwards compatibility, write the request as an AcknowledgedRequest
84- new AcknowledgedRequest .Plain (this .masterNodeTimeout (), this .ackTimeout ).writeTo (out );
85- }
86- }
87-
88- @ Override
89- public ActionRequestValidationException validate () {
90- return null ;
91- }
9287 }
9388
9489 public static class Response extends ActionResponse implements ToXContentObject {
0 commit comments