7
7
8
8
package org .elasticsearch .xpack .core .transform .action ;
9
9
10
+ import org .elasticsearch .TransportVersion ;
10
11
import org .elasticsearch .TransportVersions ;
11
12
import org .elasticsearch .action .ActionRequestValidationException ;
12
13
import org .elasticsearch .action .ActionType ;
16
17
import org .elasticsearch .common .io .stream .Writeable ;
17
18
import org .elasticsearch .common .logging .DeprecationCategory ;
18
19
import org .elasticsearch .common .logging .DeprecationLogger ;
20
+ import org .elasticsearch .core .TimeValue ;
19
21
import org .elasticsearch .xcontent .ParseField ;
20
22
import org .elasticsearch .xcontent .ToXContentObject ;
21
23
import org .elasticsearch .xcontent .XContentBuilder ;
@@ -39,6 +41,8 @@ public class GetTransformAction extends ActionType<GetTransformAction.Response>
39
41
public static final GetTransformAction INSTANCE = new GetTransformAction ();
40
42
public static final String NAME = "cluster:monitor/transform/get" ;
41
43
44
+ static final TransportVersion DANGLING_TASKS = TransportVersion .fromName ("transform_check_for_dangling_tasks" );
45
+
42
46
private static final DeprecationLogger deprecationLogger = DeprecationLogger .getLogger (GetTransformAction .class );
43
47
44
48
private GetTransformAction () {
@@ -47,24 +51,49 @@ private GetTransformAction() {
47
51
48
52
public static class Request extends AbstractGetResourcesRequest {
49
53
54
+ // for legacy purposes, this transport action previously had no timeout
55
+ private static final TimeValue LEGACY_TIMEOUT_VALUE = TimeValue .MAX_VALUE ;
50
56
private static final int MAX_SIZE_RETURN = 1000 ;
57
+ private final boolean checkForDanglingTasks ;
58
+ private final TimeValue timeout ;
51
59
52
60
public Request (String id ) {
53
- super (id , PageParams . defaultParams (), true );
61
+ this (id , false , LEGACY_TIMEOUT_VALUE );
54
62
}
55
63
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 ;
58
68
}
59
69
60
70
public Request (StreamInput in ) throws IOException {
61
71
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
+ }
62
83
}
63
84
64
85
public String getId () {
65
86
return getResourceId ();
66
87
}
67
88
89
+ public boolean checkForDanglingTasks () {
90
+ return checkForDanglingTasks ;
91
+ }
92
+
93
+ public TimeValue timeout () {
94
+ return timeout ;
95
+ }
96
+
68
97
@ Override
69
98
public ActionRequestValidationException validate () {
70
99
ActionRequestValidationException exception = null ;
@@ -86,6 +115,20 @@ public String getCancelableTaskDescription() {
86
115
public String getResourceIdField () {
87
116
return TransformField .ID .getPreferredName ();
88
117
}
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
+ }
89
132
}
90
133
91
134
public static class Response extends AbstractGetResourcesResponse <TransformConfig > implements ToXContentObject {
0 commit comments