77
88package org .elasticsearch .xpack .core .transform .action ;
99
10+ import org .elasticsearch .TransportVersion ;
1011import org .elasticsearch .TransportVersions ;
1112import org .elasticsearch .action .ActionRequestValidationException ;
1213import org .elasticsearch .action .ActionType ;
1617import org .elasticsearch .common .io .stream .Writeable ;
1718import org .elasticsearch .common .logging .DeprecationCategory ;
1819import org .elasticsearch .common .logging .DeprecationLogger ;
20+ import org .elasticsearch .core .TimeValue ;
1921import org .elasticsearch .xcontent .ParseField ;
2022import org .elasticsearch .xcontent .ToXContentObject ;
2123import org .elasticsearch .xcontent .XContentBuilder ;
@@ -39,6 +41,8 @@ public class GetTransformAction extends ActionType<GetTransformAction.Response>
3941 public static final GetTransformAction INSTANCE = new GetTransformAction ();
4042 public static final String NAME = "cluster:monitor/transform/get" ;
4143
44+ static final TransportVersion DANGLING_TASKS = TransportVersion .fromName ("transform_check_for_dangling_tasks" );
45+
4246 private static final DeprecationLogger deprecationLogger = DeprecationLogger .getLogger (GetTransformAction .class );
4347
4448 private GetTransformAction () {
@@ -47,24 +51,49 @@ private GetTransformAction() {
4751
4852 public static class Request extends AbstractGetResourcesRequest {
4953
54+ // for legacy purposes, this transport action previously had no timeout
55+ private static final TimeValue LEGACY_TIMEOUT_VALUE = TimeValue .MAX_VALUE ;
5056 private static final int MAX_SIZE_RETURN = 1000 ;
57+ private final boolean checkForDanglingTasks ;
58+ private final TimeValue timeout ;
5159
5260 public Request (String id ) {
53- super (id , PageParams . defaultParams (), true );
61+ this (id , false , LEGACY_TIMEOUT_VALUE );
5462 }
5563
56- public Request () {
57- super (null , PageParams .defaultParams (), true );
64+ public Request (String id , boolean checkForDanglingTasks , TimeValue timeout ) {
65+ super (id , PageParams .defaultParams (), true );
66+ this .checkForDanglingTasks = checkForDanglingTasks ;
67+ this .timeout = timeout ;
5868 }
5969
6070 public Request (StreamInput in ) throws IOException {
6171 super (in );
72+ this .checkForDanglingTasks = in .getTransportVersion ().onOrAfter (DANGLING_TASKS ) ? in .readBoolean () : true ;
73+ this .timeout = in .getTransportVersion ().onOrAfter (DANGLING_TASKS ) ? in .readTimeValue () : LEGACY_TIMEOUT_VALUE ;
74+ }
75+
76+ @ Override
77+ public void writeTo (StreamOutput out ) throws IOException {
78+ super .writeTo (out );
79+ if (out .getTransportVersion ().onOrAfter (DANGLING_TASKS )) {
80+ out .writeBoolean (checkForDanglingTasks );
81+ out .writeTimeValue (timeout );
82+ }
6283 }
6384
6485 public String getId () {
6586 return getResourceId ();
6687 }
6788
89+ public boolean checkForDanglingTasks () {
90+ return checkForDanglingTasks ;
91+ }
92+
93+ public TimeValue timeout () {
94+ return timeout ;
95+ }
96+
6897 @ Override
6998 public ActionRequestValidationException validate () {
7099 ActionRequestValidationException exception = null ;
@@ -86,6 +115,20 @@ public String getCancelableTaskDescription() {
86115 public String getResourceIdField () {
87116 return TransformField .ID .getPreferredName ();
88117 }
118+
119+ @ Override
120+ public boolean equals (Object obj ) {
121+ return this == obj
122+ || (obj instanceof Request other
123+ && super .equals (obj )
124+ && (checkForDanglingTasks == other .checkForDanglingTasks )
125+ && Objects .equals (timeout , other .timeout ));
126+ }
127+
128+ @ Override
129+ public int hashCode () {
130+ return Objects .hash (super .hashCode (), checkForDanglingTasks , timeout );
131+ }
89132 }
90133
91134 public static class Response extends AbstractGetResourcesResponse <TransformConfig > implements ToXContentObject {
0 commit comments