diff options
author | Håkon Hallingstad <hakon@verizonmedia.com> | 2019-12-19 14:09:00 +0100 |
---|---|---|
committer | Håkon Hallingstad <hakon@verizonmedia.com> | 2019-12-19 14:09:00 +0100 |
commit | 375e5fb2f2f02eeeb71d5754062d0404376422ff (patch) | |
tree | 18cfd7e630cb8380a33d9c0ffca199b6ff45f027 /controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/Run.java | |
parent | de165f5aa5262d974e1ecc9b92f11a02a945bcec (diff) |
Keep steps and add new stepDetails
Diffstat (limited to 'controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/Run.java')
-rw-r--r-- | controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/Run.java | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/Run.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/Run.java index 71e5934c97e..00021c4765a 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/Run.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/Run.java @@ -62,8 +62,8 @@ public class Run { /** Returns a new Run with the status of the given completed step set accordingly. */ public Run with(RunStatus status, LockedStep step) { requireActive(); - StepInfo stepInfo = steps.get(step.get()); - if (stepInfo == null || stepInfo.status() != unfinished) + StepInfo stepInfo = getRequiredStepInfo(step.get()); + if (stepInfo.status() != unfinished) throw new IllegalStateException("Step '" + step.get() + "' can't be set to '" + status + "'" + " -- it already completed with status '" + stepInfo.status() + "'!"); @@ -76,8 +76,8 @@ public class Run { /** Returns a new Run with a new start time*/ public Run with(Instant startTime, LockedStep step) { requireActive(); - StepInfo stepInfo = steps.get(step.get()); - if (stepInfo == null || stepInfo.status() != unfinished) + StepInfo stepInfo = getRequiredStepInfo(step.get()); + if (stepInfo.status() != unfinished) throw new IllegalStateException("Unable to set start timestamp of step " + step.get() + ": it has already completed with status " + stepInfo.status() + "!"); @@ -132,6 +132,10 @@ public class Run { return Optional.ofNullable(steps.get(step)); } + private StepInfo getRequiredStepInfo(Step step) { + return stepInfo(step).orElseThrow(() -> new IllegalArgumentException("There is no such step " + step + " for run " + id)); + } + /** Returns status of step. */ public Optional<Step.Status> stepStatus(Step step) { return stepInfo(step).map(StepInfo::status); |