Skip to content

Commit 0d7e025

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

14 files changed

+51
-15
lines changed

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

+12-1
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

+2-1
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

+1-1
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

+1-1
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

+2-1
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

+4-1
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

+1
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

+1
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

+2-1
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

+16-3
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

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ public UpdateSettingsStep(StepKey key, StepKey nextStepKey, Client client, Setti
3030

3131
@Override
3232
public void performAction(IndexMetaData indexMetaData, ClusterState currentState, ClusterStateObserver observer, Listener listener) {
33-
UpdateSettingsRequest updateSettingsRequest = new UpdateSettingsRequest(indexMetaData.getIndex().getName()).settings(settings);
33+
UpdateSettingsRequest updateSettingsRequest = new UpdateSettingsRequest(indexMetaData.getIndex().getName())
34+
.masterNodeTimeout(getMasterTimeout(currentState))
35+
.settings(settings);
3436
getClient().admin().indices().updateSettings(updateSettingsRequest,
3537
ActionListener.wrap(response -> listener.onResponse(true), listener::onFailure));
3638
}

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.elasticsearch.client.Client;
1414
import org.elasticsearch.cluster.metadata.IndexMetaData;
1515
import org.elasticsearch.common.Strings;
16+
import org.elasticsearch.common.settings.Settings;
1617
import org.elasticsearch.common.unit.ByteSizeValue;
1718
import org.elasticsearch.common.unit.TimeValue;
1819
import org.elasticsearch.common.xcontent.ToXContentObject;
@@ -48,7 +49,7 @@ public boolean isRetryable() {
4849
}
4950

5051
@Override
51-
public void evaluateCondition(IndexMetaData indexMetaData, Listener listener) {
52+
public void evaluateCondition(Settings settings, IndexMetaData indexMetaData, Listener listener) {
5253
String rolloverAlias = RolloverAction.LIFECYCLE_ROLLOVER_ALIAS_SETTING.get(indexMetaData.getSettings());
5354

5455
if (Strings.isNullOrEmpty(rolloverAlias)) {
@@ -113,7 +114,8 @@ public void evaluateCondition(IndexMetaData indexMetaData, Listener listener) {
113114
"index [%s] is not the write index for alias [%s]", indexMetaData.getIndex().getName(), rolloverAlias)));
114115
}
115116

116-
RolloverRequest rolloverRequest = new RolloverRequest(rolloverAlias, null);
117+
RolloverRequest rolloverRequest = new RolloverRequest(rolloverAlias, null)
118+
.masterNodeTimeout(ILM_STEP_MASTER_TIMEOUT_SETTING.get(settings));
117119
rolloverRequest.dryRun(true);
118120
if (maxAge != null) {
119121
rolloverRequest.addMaxIndexAgeCondition(maxAge);

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*/
2626
public class WaitForSnapshotAction implements LifecycleAction {
2727

28-
public static final String NAME = "snapshot";
28+
public static final String NAME = "waitforsnapshot";
2929
public static final ParseField POLICY_FIELD = new ParseField("policy");
3030

3131
private static final ConstructingObjectParser<WaitForSnapshotAction, Void> PARSER = new ConstructingObjectParser<>(NAME,

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ void runPeriodicStep(String policy, IndexMetaData indexMetaData) {
149149
}
150150
} else if (currentStep instanceof AsyncWaitStep) {
151151
logger.debug("[{}] running periodic policy with current-step [{}]", index, currentStep.getKey());
152-
((AsyncWaitStep) currentStep).evaluateCondition(indexMetaData, new AsyncWaitStep.Listener() {
152+
((AsyncWaitStep) currentStep).evaluateCondition(clusterService.getSettings(), indexMetaData, new AsyncWaitStep.Listener() {
153153

154154
@Override
155155
public void onResponse(boolean conditionMet, ToXContentObject stepInfo) {

0 commit comments

Comments
 (0)