Skip to content

Commit 0d7e025

Browse files
committed
action name changed
1 parent 1033a92 commit 0d7e025

File tree

14 files changed

+51
-15
lines changed

14 files changed

+51
-15
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/AsyncWaitStep.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import org.elasticsearch.client.Client;
99
import org.elasticsearch.cluster.metadata.IndexMetaData;
10+
import org.elasticsearch.common.settings.Settings;
1011
import org.elasticsearch.common.xcontent.ToXContentObject;
1112

1213
/**
@@ -28,7 +29,17 @@ protected Client getClient() {
2829
return client;
2930
}
3031

31-
public abstract void evaluateCondition(IndexMetaData indexMetaData, Listener listener);
32+
public void evaluateCondition(Settings settings, IndexMetaData indexMetaData, Listener listener){
33+
evaluateCondition(indexMetaData, listener);
34+
}
35+
36+
public void evaluateCondition(IndexMetaData indexMetaData, Listener listener){
37+
try {
38+
throw new UnsupportedOperationException();
39+
} catch (UnsupportedOperationException e) {
40+
listener.onFailure(e);
41+
}
42+
}
3243

3344
public interface Listener {
3445

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/CloseFollowerIndexStep.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ void performDuringNoSnapshot(IndexMetaData indexMetaData, ClusterState currentCl
3333
}
3434

3535
if (indexMetaData.getState() == IndexMetaData.State.OPEN) {
36-
CloseIndexRequest closeIndexRequest = new CloseIndexRequest(followerIndex);
36+
CloseIndexRequest closeIndexRequest = new CloseIndexRequest(followerIndex)
37+
.masterNodeTimeout(getMasterTimeout(currentClusterState));
3738
getClient().admin().indices().close(closeIndexRequest, ActionListener.wrap(
3839
r -> {
3940
assert r.isAcknowledged() : "close index response is not acknowledged";

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/DeleteStep.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public DeleteStep(StepKey key, StepKey nextStepKey, Client client) {
2424
@Override
2525
public void performDuringNoSnapshot(IndexMetaData indexMetaData, ClusterState currentState, Listener listener) {
2626
getClient().admin().indices()
27-
.delete(new DeleteIndexRequest(indexMetaData.getIndex().getName()),
27+
.delete(new DeleteIndexRequest(indexMetaData.getIndex().getName()).masterNodeTimeout(getMasterTimeout(currentState)),
2828
ActionListener.wrap(response -> listener.onResponse(true), listener::onFailure));
2929
}
3030

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/FreezeStep.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public FreezeStep(StepKey key, StepKey nextStepKey, Client client) {
2525
@Override
2626
public void performDuringNoSnapshot(IndexMetaData indexMetaData, ClusterState currentState, Listener listener) {
2727
getClient().admin().indices().execute(FreezeIndexAction.INSTANCE,
28-
new FreezeRequest(indexMetaData.getIndex().getName()),
28+
new FreezeRequest(indexMetaData.getIndex().getName()).masterNodeTimeout(getMasterTimeout(currentState)),
2929
ActionListener.wrap(response -> listener.onResponse(true), listener::onFailure));
3030
}
3131
}

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/OpenFollowerIndexStep.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ final class OpenFollowerIndexStep extends AsyncActionStep {
2424
public void performAction(IndexMetaData indexMetaData, ClusterState currentClusterState,
2525
ClusterStateObserver observer, Listener listener) {
2626
if (indexMetaData.getState() == IndexMetaData.State.CLOSE) {
27-
OpenIndexRequest request = new OpenIndexRequest(indexMetaData.getIndex().getName());
27+
OpenIndexRequest request = new OpenIndexRequest(indexMetaData.getIndex().getName())
28+
.masterNodeTimeout(getMasterTimeout(currentClusterState));
2829
getClient().admin().indices().open(request, ActionListener.wrap(
2930
r -> {
3031
assert r.isAcknowledged() : "open index response is not acknowledged";

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/RolloverStep.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import org.elasticsearch.cluster.ClusterStateObserver;
1515
import org.elasticsearch.cluster.metadata.IndexMetaData;
1616
import org.elasticsearch.common.Strings;
17+
import org.elasticsearch.common.settings.ClusterSettings;
18+
import org.elasticsearch.common.unit.TimeValue;
1719

1820
import java.util.Locale;
1921
import java.util.Objects;
@@ -64,7 +66,8 @@ public void performAction(IndexMetaData indexMetaData, ClusterState currentClust
6466
}
6567

6668
// Calling rollover with no conditions will always roll over the index
67-
RolloverRequest rolloverRequest = new RolloverRequest(rolloverAlias, null);
69+
RolloverRequest rolloverRequest = new RolloverRequest(rolloverAlias, null)
70+
.masterNodeTimeout(getMasterTimeout(currentClusterState));
6871
getClient().admin().indices().rolloverIndex(rolloverRequest,
6972
ActionListener.wrap(response -> {
7073
assert response.isRolledOver() : "the only way this rollover call should fail is with an exception";

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/SetSingleNodeAllocateStep.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public void performAction(IndexMetaData indexMetaData, ClusterState clusterState
8383
Settings settings = Settings.builder()
8484
.put(IndexMetaData.INDEX_ROUTING_REQUIRE_GROUP_SETTING.getKey() + "_id", nodeId.get()).build();
8585
UpdateSettingsRequest updateSettingsRequest = new UpdateSettingsRequest(indexMetaData.getIndex().getName())
86+
.masterNodeTimeout(getMasterTimeout(clusterState))
8687
.settings(settings);
8788
getClient().admin().indices().updateSettings(updateSettingsRequest,
8889
ActionListener.wrap(response -> listener.onResponse(true), listener::onFailure));

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/ShrinkSetAliasStep.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public void performDuringNoSnapshot(IndexMetaData indexMetaData, ClusterState cu
3838
// get target shrink index
3939
String targetIndexName = shrunkIndexPrefix + index;
4040
IndicesAliasesRequest aliasesRequest = new IndicesAliasesRequest()
41+
.masterNodeTimeout(getMasterTimeout(currentState))
4142
.addAliasAction(IndicesAliasesRequest.AliasActions.removeIndex().index(index))
4243
.addAliasAction(IndicesAliasesRequest.AliasActions.add().index(targetIndexName).alias(index));
4344
// copy over other aliases from original index

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/ShrinkStep.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ public void performAction(IndexMetaData indexMetaData, ClusterState currentState
5757
.build();
5858

5959
String shrunkenIndexName = shrunkIndexPrefix + indexMetaData.getIndex().getName();
60-
ResizeRequest resizeRequest = new ResizeRequest(shrunkenIndexName, indexMetaData.getIndex().getName());
60+
ResizeRequest resizeRequest = new ResizeRequest(shrunkenIndexName, indexMetaData.getIndex().getName())
61+
.masterNodeTimeout(getMasterTimeout(currentState));
6162
resizeRequest.getTargetIndexRequest().settings(relevantTargetSettings);
6263

6364
getClient().admin().indices().resizeIndex(resizeRequest, ActionListener.wrap(response -> {

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/Step.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55
*/
66
package org.elasticsearch.xpack.core.ilm;
77

8+
import org.elasticsearch.cluster.ClusterState;
89
import org.elasticsearch.common.ParseField;
910
import org.elasticsearch.common.Strings;
1011
import org.elasticsearch.common.io.stream.StreamInput;
1112
import org.elasticsearch.common.io.stream.StreamOutput;
1213
import org.elasticsearch.common.io.stream.Writeable;
14+
import org.elasticsearch.common.settings.Setting;
15+
import org.elasticsearch.common.unit.TimeValue;
1316
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
1417
import org.elasticsearch.common.xcontent.ToXContentObject;
1518
import org.elasticsearch.common.xcontent.XContentBuilder;
@@ -22,6 +25,11 @@
2225
* Represents one part of the execution of a {@link LifecycleAction}.
2326
*/
2427
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+
2533
private final StepKey key;
2634
private final StepKey nextStepKey;
2735

@@ -60,14 +68,18 @@ public boolean equals(Object obj) {
6068
}
6169
Step other = (Step) obj;
6270
return Objects.equals(key, other.key) &&
63-
Objects.equals(nextStepKey, other.nextStepKey);
71+
Objects.equals(nextStepKey, other.nextStepKey);
6472
}
6573

6674
@Override
6775
public String toString() {
6876
return key + " => " + nextStepKey;
6977
}
7078

79+
protected TimeValue getMasterTimeout(ClusterState clusterState){
80+
return ILM_STEP_MASTER_TIMEOUT_SETTING.get(clusterState.metaData().settings());
81+
}
82+
7183
public static final class StepKey implements Writeable, ToXContentObject {
7284
private final String phase;
7385
private final String action;
@@ -78,6 +90,7 @@ public static final class StepKey implements Writeable, ToXContentObject {
7890
public static final ParseField NAME_FIELD = new ParseField("name");
7991
private static final ConstructingObjectParser<StepKey, Void> PARSER =
8092
new ConstructingObjectParser<>("stepkey", a -> new StepKey((String) a[0], (String) a[1], (String) a[2]));
93+
8194
static {
8295
PARSER.declareString(ConstructingObjectParser.constructorArg(), PHASE_FIELD);
8396
PARSER.declareString(ConstructingObjectParser.constructorArg(), ACTION_FIELD);
@@ -134,8 +147,8 @@ public boolean equals(Object obj) {
134147
}
135148
StepKey other = (StepKey) obj;
136149
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);
139152
}
140153

141154
@Override

0 commit comments

Comments
 (0)