5
5
*/
6
6
package org .elasticsearch .xpack .core .ilm ;
7
7
8
+ import org .elasticsearch .cluster .ClusterState ;
8
9
import org .elasticsearch .common .ParseField ;
9
10
import org .elasticsearch .common .Strings ;
10
11
import org .elasticsearch .common .io .stream .StreamInput ;
11
12
import org .elasticsearch .common .io .stream .StreamOutput ;
12
13
import org .elasticsearch .common .io .stream .Writeable ;
14
+ import org .elasticsearch .common .settings .Setting ;
15
+ import org .elasticsearch .common .unit .TimeValue ;
13
16
import org .elasticsearch .common .xcontent .ConstructingObjectParser ;
14
17
import org .elasticsearch .common .xcontent .ToXContentObject ;
15
18
import org .elasticsearch .common .xcontent .XContentBuilder ;
22
25
* Represents one part of the execution of a {@link LifecycleAction}.
23
26
*/
24
27
public abstract class Step {
28
+
29
+ private static final String ILM_STEP_MASTER_TIMEOUT = "ilm.step.master.timeout" ;
30
+ protected static final Setting <TimeValue > ILM_STEP_MASTER_TIMEOUT_SETTING = Setting .positiveTimeSetting (ILM_STEP_MASTER_TIMEOUT ,
31
+ TimeValue .timeValueSeconds (30 ), Setting .Property .Dynamic , Setting .Property .NodeScope );
32
+
25
33
private final StepKey key ;
26
34
private final StepKey nextStepKey ;
27
35
@@ -60,14 +68,18 @@ public boolean equals(Object obj) {
60
68
}
61
69
Step other = (Step ) obj ;
62
70
return Objects .equals (key , other .key ) &&
63
- Objects .equals (nextStepKey , other .nextStepKey );
71
+ Objects .equals (nextStepKey , other .nextStepKey );
64
72
}
65
73
66
74
@ Override
67
75
public String toString () {
68
76
return key + " => " + nextStepKey ;
69
77
}
70
78
79
+ protected TimeValue getMasterTimeout (ClusterState clusterState ){
80
+ return ILM_STEP_MASTER_TIMEOUT_SETTING .get (clusterState .metaData ().settings ());
81
+ }
82
+
71
83
public static final class StepKey implements Writeable , ToXContentObject {
72
84
private final String phase ;
73
85
private final String action ;
@@ -78,6 +90,7 @@ public static final class StepKey implements Writeable, ToXContentObject {
78
90
public static final ParseField NAME_FIELD = new ParseField ("name" );
79
91
private static final ConstructingObjectParser <StepKey , Void > PARSER =
80
92
new ConstructingObjectParser <>("stepkey" , a -> new StepKey ((String ) a [0 ], (String ) a [1 ], (String ) a [2 ]));
93
+
81
94
static {
82
95
PARSER .declareString (ConstructingObjectParser .constructorArg (), PHASE_FIELD );
83
96
PARSER .declareString (ConstructingObjectParser .constructorArg (), ACTION_FIELD );
@@ -134,8 +147,8 @@ public boolean equals(Object obj) {
134
147
}
135
148
StepKey other = (StepKey ) obj ;
136
149
return Objects .equals (phase , other .phase ) &&
137
- Objects .equals (action , other .action ) &&
138
- Objects .equals (name , other .name );
150
+ Objects .equals (action , other .action ) &&
151
+ Objects .equals (name , other .name );
139
152
}
140
153
141
154
@ Override
0 commit comments