Skip to content

Commit

Permalink
add this possible heavy computation in the constructor so it is store…
Browse files Browse the repository at this point in the history
…d and cached then future usage will be really quick...

Signed-off-by: Olivier Lamy <olamy@apache.org>
  • Loading branch information
olamy committed Mar 16, 2023
1 parent 864ac53 commit 3ea8a3c
Showing 1 changed file with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;

/**
Expand All @@ -57,6 +58,8 @@ public class PipelineNodeImpl extends BluePipelineNode {
private final Link self;
private final String runExternalizableId;
private final Reachable parent;

private final Boolean restartable;
public static final int waitJobInqueueTimeout = Integer.getInteger("blueocean.wait.job.inqueue", 1000);

public PipelineNodeImpl(FlowNodeWrapper node, Reachable parent, WorkflowRun run) {
Expand All @@ -67,6 +70,17 @@ public PipelineNodeImpl(FlowNodeWrapper node, Reachable parent, WorkflowRun run)
this.durationInMillis = node.getTiming().getTotalDurationMillis();
this.self = parent.getLink().rel(node.getId());
this.parent = parent;
RestartDeclarativePipelineAction restartDeclarativePipelineAction =
getRun().getAction( RestartDeclarativePipelineAction.class );
if (restartDeclarativePipelineAction != null) {
List<String> restartableStages = restartDeclarativePipelineAction.getRestartableStages();
if (restartableStages != null) {
restartable = Boolean.valueOf(restartableStages.contains(this.getDisplayName())
&& this.getStateObj() == BlueRun.BlueRunState.FINISHED);
return;
}
}
restartable = Boolean.FALSE;
}

@Override
Expand Down Expand Up @@ -183,16 +197,8 @@ private WorkflowRun getRun() {

@Override
public boolean isRestartable() {
RestartDeclarativePipelineAction restartDeclarativePipelineAction =
getRun().getAction( RestartDeclarativePipelineAction.class );
if (restartDeclarativePipelineAction != null) {
List<String> restartableStages = restartDeclarativePipelineAction.getRestartableStages();
if (restartableStages != null) {
return restartableStages.contains(this.getDisplayName())
&& this.getStateObj() == BlueRun.BlueRunState.FINISHED;
}
}
return false;
// can't be null really but just in case
return restartable == null ? false : restartable.booleanValue();
}

@Override
Expand Down

0 comments on commit 3ea8a3c

Please sign in to comment.