have steps point to step-key, not the actual step object
This commit is contained in:
parent
ce4248ec59
commit
e6ee5b49d1
|
@ -23,9 +23,9 @@ public class ClientStep<RequestBuilder extends ActionRequestBuilder, Response ex
|
||||||
private Exception returnedException;
|
private Exception returnedException;
|
||||||
private boolean returnedSuccess;
|
private boolean returnedSuccess;
|
||||||
|
|
||||||
public ClientStep(String name, String action, String phase, String index, Step nextStep, RequestBuilder requestBuilder,
|
public ClientStep(String name, String action, String phase, String index, StepKey nextStepKey, RequestBuilder requestBuilder,
|
||||||
Function<ClusterState, Boolean> checkComplete, Function<Response, Boolean> checkSuccess) {
|
Function<ClusterState, Boolean> checkComplete, Function<Response, Boolean> checkSuccess) {
|
||||||
super(name, action, phase, nextStep);
|
super(name, action, phase, nextStepKey);
|
||||||
this.requestBuilder = requestBuilder;
|
this.requestBuilder = requestBuilder;
|
||||||
this.checkComplete = checkComplete;
|
this.checkComplete = checkComplete;
|
||||||
this.checkSuccess = checkSuccess;
|
this.checkSuccess = checkSuccess;
|
||||||
|
|
|
@ -18,8 +18,8 @@ import java.util.function.LongSupplier;
|
||||||
public class ClusterStateUpdateStep extends Step {
|
public class ClusterStateUpdateStep extends Step {
|
||||||
private final Function<ClusterState, ClusterState> updateTask;
|
private final Function<ClusterState, ClusterState> updateTask;
|
||||||
|
|
||||||
public ClusterStateUpdateStep(String name, String index, String phase, String action, Step nextStep, Function<ClusterState, ClusterState> updateTask) {
|
public ClusterStateUpdateStep(String name, String index, String phase, String action, StepKey nextStepKey, Function<ClusterState, ClusterState> updateTask) {
|
||||||
super(name, action, phase, nextStep);
|
super(name, action, phase, nextStepKey);
|
||||||
this.updateTask = updateTask;
|
this.updateTask = updateTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,8 @@ import java.util.function.LongSupplier;
|
||||||
public class ConditionalWaitStep extends Step {
|
public class ConditionalWaitStep extends Step {
|
||||||
private final Function<ClusterState, Boolean> condition;
|
private final Function<ClusterState, Boolean> condition;
|
||||||
|
|
||||||
public ConditionalWaitStep(String name, String phase, String action, Step nextStep, Function<ClusterState, Boolean> condition) {
|
public ConditionalWaitStep(String name, String phase, String action, StepKey nextStepKey, Function<ClusterState, Boolean> condition) {
|
||||||
super(name, action, phase, nextStep);
|
super(name, action, phase, nextStepKey);
|
||||||
this.condition = condition;
|
this.condition = condition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,8 @@ import org.elasticsearch.common.unit.TimeValue;
|
||||||
public class PhaseAfterStep extends Step {
|
public class PhaseAfterStep extends Step {
|
||||||
private final TimeValue after;
|
private final TimeValue after;
|
||||||
|
|
||||||
public PhaseAfterStep(String phase, String action, String name, TimeValue after, Step nextStep) {
|
public PhaseAfterStep(String phase, String action, String name, TimeValue after, StepKey nextStepKey) {
|
||||||
super(name, action, phase, nextStep);
|
super(name, action, phase, nextStepKey);
|
||||||
this.after = after;
|
this.after = after;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,13 +23,13 @@ public class Step {
|
||||||
private final String name;
|
private final String name;
|
||||||
private final String action;
|
private final String action;
|
||||||
private final String phase;
|
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.name = name;
|
||||||
this.action = action;
|
this.action = action;
|
||||||
this.phase = phase;
|
this.phase = phase;
|
||||||
this.nextStep = nextStep;
|
this.nextStepKey = nextStepKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -44,12 +44,12 @@ public class Step {
|
||||||
return phase;
|
return phase;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Step getNextStep() {
|
public StepKey getNextStepKey() {
|
||||||
return nextStep;
|
return nextStepKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasNextStep() {
|
public boolean hasNextStep() {
|
||||||
return nextStep != null;
|
return nextStepKey != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -97,12 +97,12 @@ public class Step {
|
||||||
long now = nowSupplier.getAsLong();
|
long now = nowSupplier.getAsLong();
|
||||||
// fetch details about next step to run and update the cluster state with this information
|
// fetch details about next step to run and update the cluster state with this information
|
||||||
Settings newLifecyclePhaseSettings = Settings.builder()
|
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_PHASE_TIME, now)
|
||||||
.put(LifecycleSettings.LIFECYCLE_ACTION_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_TIME, now)
|
||||||
.put(LifecycleSettings.LIFECYCLE_STEP, nextStep.getName())
|
.put(LifecycleSettings.LIFECYCLE_STEP, nextStepKey.getName())
|
||||||
.build();
|
.build();
|
||||||
return ClusterState.builder(currentState)
|
return ClusterState.builder(currentState)
|
||||||
.metaData(MetaData.builder(currentState.metaData())
|
.metaData(MetaData.builder(currentState.metaData())
|
||||||
|
|
|
@ -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
|
// returns current step to execute. If settings are null, then the first step to be executed in
|
||||||
// this policy is returned.
|
// this policy is returned.
|
||||||
Step currentStep = policyRegistry.getStep(policyName, new Step.StepKey(phase, action, stepName));
|
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
|
@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
|
* @param startStep The current step that has either not been executed, or not completed before
|
||||||
* @return the new ClusterState
|
* @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);
|
StepResult result = startStep.execute(clusterService, currentState, index, client, nowSupplier);
|
||||||
while (result.isComplete() && result.indexSurvived() && startStep.hasNextStep()) {
|
while (result.isComplete() && result.indexSurvived() && startStep.hasNextStep()) {
|
||||||
currentState = result.getClusterState();
|
currentState = result.getClusterState();
|
||||||
startStep = startStep.getNextStep();
|
startStep = policyRegistry.getStep(policyName, startStep.getNextStepKey());
|
||||||
result = startStep.execute(clusterService, currentState, index, client, nowSupplier);
|
result = startStep.execute(clusterService, currentState, index, client, nowSupplier);
|
||||||
}
|
}
|
||||||
if (result.isComplete()) {
|
if (result.isComplete()) {
|
||||||
|
|
Loading…
Reference in New Issue