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 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) {
|
||||
super(name, action, phase, nextStep);
|
||||
super(name, action, phase, nextStepKey);
|
||||
this.requestBuilder = requestBuilder;
|
||||
this.checkComplete = checkComplete;
|
||||
this.checkSuccess = checkSuccess;
|
||||
|
|
|
@ -18,8 +18,8 @@ import java.util.function.LongSupplier;
|
|||
public class ClusterStateUpdateStep extends Step {
|
||||
private final Function<ClusterState, ClusterState> updateTask;
|
||||
|
||||
public ClusterStateUpdateStep(String name, String index, String phase, String action, Step nextStep, Function<ClusterState, ClusterState> updateTask) {
|
||||
super(name, action, phase, nextStep);
|
||||
public ClusterStateUpdateStep(String name, String index, String phase, String action, StepKey nextStepKey, Function<ClusterState, ClusterState> updateTask) {
|
||||
super(name, action, phase, nextStepKey);
|
||||
this.updateTask = updateTask;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@ import java.util.function.LongSupplier;
|
|||
public class ConditionalWaitStep extends Step {
|
||||
private final Function<ClusterState, Boolean> condition;
|
||||
|
||||
public ConditionalWaitStep(String name, String phase, String action, Step nextStep, Function<ClusterState, Boolean> condition) {
|
||||
super(name, action, phase, nextStep);
|
||||
public ConditionalWaitStep(String name, String phase, String action, StepKey nextStepKey, Function<ClusterState, Boolean> condition) {
|
||||
super(name, action, phase, nextStepKey);
|
||||
this.condition = condition;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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()) {
|
||||
|
|
Loading…
Reference in New Issue