Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import io.flamingock.internal.util.ThreadSleeper;
import io.flamingock.internal.util.TimeService;
import io.flamingock.internal.common.core.error.FlamingockException;
import io.flamingock.internal.common.core.response.data.PlannerVerdict;
import io.flamingock.cloud.api.request.ExecutionPlanRequest;
import io.flamingock.cloud.api.response.ExecutionPlanResponse;
import io.flamingock.internal.common.core.targets.TargetSystemAuditMarkType;
Expand All @@ -35,6 +36,7 @@
import io.flamingock.internal.core.external.store.lock.LockException;
import io.flamingock.internal.core.pipeline.loaded.stage.AbstractLoadedStage;
import io.flamingock.internal.core.pipeline.run.PipelineRun;
import io.flamingock.internal.core.pipeline.run.StageRun;
import io.flamingock.internal.util.log.FlamingockLoggerFactory;
import org.slf4j.Logger;

Expand Down Expand Up @@ -102,6 +104,12 @@ public ExecutionPlan getNextExecution(PipelineRun pipelineRun) throws LockExcept
}

if (response.isContinue()) {
//TODO temporally. Remove this
// Server's CONTINUE is authoritative: nothing left to apply for any stage in
// the pipeline. Stamp the planner's UP_TO_DATE verdict on every stage the
// planner hasn't already evaluated this run. No per-change records — the
// server's CONTINUE doesn't carry per-change data and we don't synthesize.
markRemainingStagesUpToDate(pipelineRun);
return ExecutionPlan.CONTINUE();

} else if (response.isExecute()) {
Expand Down Expand Up @@ -200,6 +208,22 @@ private ExecutionPlan buildNextExecutionPlan(List<AbstractLoadedStage> loadedSta
);
}

/**
* Stamps {@link PlannerVerdict#UP_TO_DATE} on every still-{@code NOT_EVALUATED} stage in the
* pipeline. Called when the cloud server returns {@code CONTINUE} — its verdict is authoritative
* for the whole pipeline. No per-change records are added; the server's CONTINUE payload doesn't
* carry per-change data and we don't synthesize.
*/
private static void markRemainingStagesUpToDate(PipelineRun pipelineRun) {
for (StageRun stageRun : pipelineRun.getStageRuns()) {
if (stageRun.getResult().getPlannerVerdict() == PlannerVerdict.NOT_EVALUATED
&& !stageRun.getState().isFailed()
&& !stageRun.getState().isCompleted()) {
pipelineRun.markStageVerdict(stageRun.getName(), PlannerVerdict.UP_TO_DATE);
}
}
}

static class AuditMarkSnapshot {
private final Collection<TargetSystemAuditMark> marks;
private final Map<String, TargetSystemAuditMarker> markerByChangeId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ public boolean isFailed() {
return status == ChangeStatus.FAILED;
}

public boolean isRolledBack() {
return status == ChangeStatus.ROLLED_BACK;
}

public boolean isApplied() {
return status == ChangeStatus.APPLIED;
}
Expand All @@ -109,6 +113,10 @@ public boolean isAlreadyApplied() {
return status == ChangeStatus.ALREADY_APPLIED;
}

public boolean isNotReached() {
return status == ChangeStatus.NOT_REACHED;
}

public static Builder builder() {
return new Builder();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,33 @@
*/
public enum ChangeStatus {
/**
* Change was successfully applied.
* Change was successfully applied during this run by the operation.
*/
APPLIED,

/**
* Change was already applied in a previous execution.
* Change was found already applied — either by the executor (SKIP action during this run)
* or by the planner (audit-confirmed without invoking the executor).
*/
ALREADY_APPLIED,

/**
* Change failed during execution.
* Change failed during execution this run.
*/
FAILED,

/**
* Change failed but was successfully rolled back.
* Change failed during execution this run and was successfully rolled back (transactional
* auto-rollback).
*/
ROLLED_BACK,

/**
* Change was not reached due to a prior failure.
* No positive information about this change in this run. Either the operation didn't process
* it (executor stopped on a prior failure, the stage was unreached, etc.) or the planner
* found no audit entry confirming it was applied. Default initial status assigned to every
* loaded change at {@code PipelineRun} construction; writers transition records forward as
* they learn facts.
*/
NOT_REACHED
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,15 @@ public class ExecuteResponseData {

// Aggregate counts
private int totalStages;
private int upToDateStages;
private int notReachedStages;
private int completedStages;
private int failedStages;
private int totalChanges;
private int appliedChanges;
private int skippedChanges;
private int failedChanges;
private int notReachedChanges;

// Per-stage breakdown
private List<StageResult> stages;
Expand All @@ -54,12 +57,15 @@ private ExecuteResponseData(Builder builder) {
this.endTime = builder.endTime;
this.totalDurationMs = builder.totalDurationMs;
this.totalStages = builder.totalStages;
this.upToDateStages = builder.upToDateStages;
this.notReachedStages = builder.notReachedStages;
this.completedStages = builder.completedStages;
this.failedStages = builder.failedStages;
this.totalChanges = builder.totalChanges;
this.appliedChanges = builder.appliedChanges;
this.skippedChanges = builder.skippedChanges;
this.failedChanges = builder.failedChanges;
this.notReachedChanges = builder.notReachedChanges;
this.stages = builder.stages != null ? builder.stages : new ArrayList<>();
}

Expand Down Expand Up @@ -103,6 +109,22 @@ public void setTotalStages(int totalStages) {
this.totalStages = totalStages;
}

public int getUpToDateStages() {
return upToDateStages;
}

public void setUpToDateStages(int upToDateStages) {
this.upToDateStages = upToDateStages;
}

public int getNotReachedStages() {
return notReachedStages;
}

public void setNotReachedStages(int notReachedStages) {
this.notReachedStages = notReachedStages;
}

public int getCompletedStages() {
return completedStages;
}
Expand Down Expand Up @@ -151,6 +173,14 @@ public void setFailedChanges(int failedChanges) {
this.failedChanges = failedChanges;
}

public int getNotReachedChanges() {
return notReachedChanges;
}

public void setNotReachedChanges(int notReachedChanges) {
this.notReachedChanges = notReachedChanges;
}

public List<StageResult> getStages() {
return stages;
}
Expand All @@ -177,12 +207,15 @@ public static class Builder {
private Instant endTime;
private long totalDurationMs;
private int totalStages;
private int upToDateStages;
private int notReachedStages;
private int completedStages;
private int failedStages;
private int totalChanges;
private int appliedChanges;
private int skippedChanges;
private int failedChanges;
private int notReachedChanges;
private List<StageResult> stages = new ArrayList<>();

public Builder status(ExecutionStatus status) {
Expand Down Expand Up @@ -210,6 +243,16 @@ public Builder totalStages(int totalStages) {
return this;
}

public Builder upToDateStages(int upToDateStages) {
this.upToDateStages = upToDateStages;
return this;
}

public Builder notReachedStages(int notReachedStages) {
this.notReachedStages = notReachedStages;
return this;
}

public Builder completedStages(int completedStages) {
this.completedStages = completedStages;
return this;
Expand Down Expand Up @@ -240,6 +283,11 @@ public Builder failedChanges(int failedChanges) {
return this;
}

public Builder notReachedChanges(int notReachedChanges) {
this.notReachedChanges = notReachedChanges;
return this;
}

public Builder stages(List<StageResult> stages) {
this.stages = stages;
return this;
Expand Down
Loading
Loading