diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/ClientStep.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/ClientStep.java index 7474af79635..179a1edefef 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/ClientStep.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/ClientStep.java @@ -23,9 +23,9 @@ public class ClientStep checkComplete, Function checkSuccess) { - super(name, action, phase, nextStep); + super(name, action, phase, nextStepKey); this.requestBuilder = requestBuilder; this.checkComplete = checkComplete; this.checkSuccess = checkSuccess; diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/ClusterStateUpdateStep.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/ClusterStateUpdateStep.java index 4fc63424fc1..eab7ac564e9 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/ClusterStateUpdateStep.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/ClusterStateUpdateStep.java @@ -18,8 +18,8 @@ import java.util.function.LongSupplier; public class ClusterStateUpdateStep extends Step { private final Function updateTask; - public ClusterStateUpdateStep(String name, String index, String phase, String action, Step nextStep, Function updateTask) { - super(name, action, phase, nextStep); + public ClusterStateUpdateStep(String name, String index, String phase, String action, StepKey nextStepKey, Function updateTask) { + super(name, action, phase, nextStepKey); this.updateTask = updateTask; } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/ConditionalWaitStep.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/ConditionalWaitStep.java index 25d2e666c2f..fe675ccc8b9 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/ConditionalWaitStep.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/ConditionalWaitStep.java @@ -18,8 +18,8 @@ import java.util.function.LongSupplier; public class ConditionalWaitStep extends Step { private final Function condition; - public ConditionalWaitStep(String name, String phase, String action, Step nextStep, Function condition) { - super(name, action, phase, nextStep); + public ConditionalWaitStep(String name, String phase, String action, StepKey nextStepKey, Function condition) { + super(name, action, phase, nextStepKey); this.condition = condition; } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/PhaseAfterStep.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/PhaseAfterStep.java index 1f7bb25067c..6eeef3ddcaf 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/PhaseAfterStep.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/PhaseAfterStep.java @@ -10,8 +10,8 @@ import org.elasticsearch.common.unit.TimeValue; public class PhaseAfterStep extends Step { private final TimeValue after; - public PhaseAfterStep(String phase, String action, String name, TimeValue after, Step nextStep) { - super(name, action, phase, nextStep); + public PhaseAfterStep(String phase, String action, String name, TimeValue after, StepKey nextStepKey) { + super(name, action, phase, nextStepKey); this.after = after; } } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/Step.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/Step.java index dbe847663b0..57de63d3778 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/Step.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/Step.java @@ -23,13 +23,13 @@ public class Step { private final String name; private final String action; private final String phase; - private final Step nextStep; + private final StepKey nextStepKey; - public Step(String name, String action, String phase, Step nextStep) { + public Step(String name, String action, String phase, StepKey nextStepKey) { this.name = name; this.action = action; this.phase = phase; - this.nextStep = nextStep; + this.nextStepKey = nextStepKey; } public String getName() { @@ -44,12 +44,12 @@ public class Step { return phase; } - public Step getNextStep() { - return nextStep; + public StepKey getNextStepKey() { + return nextStepKey; } public boolean hasNextStep() { - return nextStep != null; + return nextStepKey != null; } /** @@ -97,12 +97,12 @@ public class Step { long now = nowSupplier.getAsLong(); // fetch details about next step to run and update the cluster state with this information Settings newLifecyclePhaseSettings = Settings.builder() - .put(LifecycleSettings.LIFECYCLE_PHASE, nextStep.getPhase()) + .put(LifecycleSettings.LIFECYCLE_PHASE, nextStepKey.getPhase()) .put(LifecycleSettings.LIFECYCLE_PHASE_TIME, now) .put(LifecycleSettings.LIFECYCLE_ACTION_TIME, now) - .put(LifecycleSettings.LIFECYCLE_ACTION, nextStep.getAction()) + .put(LifecycleSettings.LIFECYCLE_ACTION, nextStepKey.getAction()) .put(LifecycleSettings.LIFECYCLE_STEP_TIME, now) - .put(LifecycleSettings.LIFECYCLE_STEP, nextStep.getName()) + .put(LifecycleSettings.LIFECYCLE_STEP, nextStepKey.getName()) .build(); return ClusterState.builder(currentState) .metaData(MetaData.builder(currentState.metaData()) diff --git a/x-pack/plugin/index-lifecycle/src/main/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycleService.java b/x-pack/plugin/index-lifecycle/src/main/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycleService.java index 61c4e1e0072..144d69e06b3 100644 --- a/x-pack/plugin/index-lifecycle/src/main/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycleService.java +++ b/x-pack/plugin/index-lifecycle/src/main/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycleService.java @@ -138,7 +138,7 @@ public class IndexLifecycleService extends AbstractComponent // returns current step to execute. If settings are null, then the first step to be executed in // this policy is returned. Step currentStep = policyRegistry.getStep(policyName, new Step.StepKey(phase, action, stepName)); - return executeStepUntilAsync(currentStep, clusterState, client, nowSupplier, idxMeta.getIndex()); + return executeStepUntilAsync(policyName, currentStep, clusterState, client, nowSupplier, idxMeta.getIndex()); } @Override @@ -159,11 +159,11 @@ public class IndexLifecycleService extends AbstractComponent * @param startStep The current step that has either not been executed, or not completed before * @return the new ClusterState */ - private ClusterState executeStepUntilAsync(Step startStep, ClusterState currentState, Client client, LongSupplier nowSupplier, Index index) { + private ClusterState executeStepUntilAsync(String policyName, Step startStep, ClusterState currentState, Client client, LongSupplier nowSupplier, Index index) { StepResult result = startStep.execute(clusterService, currentState, index, client, nowSupplier); while (result.isComplete() && result.indexSurvived() && startStep.hasNextStep()) { currentState = result.getClusterState(); - startStep = startStep.getNextStep(); + startStep = policyRegistry.getStep(policyName, startStep.getNextStepKey()); result = startStep.execute(clusterService, currentState, index, client, nowSupplier); } if (result.isComplete()) {