Skip to content
Permalink
Browse files

Merge pull request #34 from svanoort/fix-bad-big-o-for-copylogs-with-…

…parallels

[JENKINS-40934] Avoid redundant scans of parallels
  • Loading branch information
svanoort committed Mar 21, 2017
2 parents 494446b + e364b6b commit 4b48f17fc8525a9d2cfb63c763d7ec5070192712
Showing with 12 additions and 7 deletions.
  1. +12 −7 src/main/java/org/jenkinsci/plugins/workflow/support/actions/LogActionImpl.java
@@ -39,6 +39,7 @@
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -51,7 +52,10 @@
import org.jenkinsci.plugins.workflow.flow.GraphListener;
import org.jenkinsci.plugins.workflow.graph.BlockStartNode;
import org.jenkinsci.plugins.workflow.graph.FlowNode;
import org.jenkinsci.plugins.workflow.graphanalysis.AbstractFlowScanner;
import org.jenkinsci.plugins.workflow.graphanalysis.DepthFirstScanner;
import org.jenkinsci.plugins.workflow.graphanalysis.LinearBlockHoppingScanner;
import org.jenkinsci.plugins.workflow.graphanalysis.LinearScanner;
import org.jenkinsci.plugins.workflow.steps.StepContext;
import org.jenkinsci.plugins.workflow.steps.StepContextParameter;
import org.kohsuke.accmod.Restricted;
@@ -148,15 +152,16 @@ public FlowNode getParent() {
* (for example by calling {@link StepContext#get} on demand rather than by using {@link StepContextParameter}).
*/
private static boolean isRunning(FlowNode node) {
if (node.isRunning()) {
return true;
}
if (node instanceof BlockStartNode) {
for (FlowNode head : node.getExecution().getCurrentHeads()) {
if (new LinearBlockHoppingScanner().findFirstMatch(head, Predicates.equalTo(node)) != null) {
return true;
}
}
return false;
// Block start is considered running if currently executing nodes are part of the block
List<FlowNode> headNodes = node.getExecution().getCurrentHeads();
AbstractFlowScanner scanner = (headNodes.size() > 1) ? new DepthFirstScanner() : new LinearBlockHoppingScanner();
return scanner.findFirstMatch(headNodes, Predicates.equalTo(node)) != null;
} else {
return node.isRunning();
return false;
}
}

0 comments on commit 4b48f17

Please sign in to comment.
You can’t perform that action at this time.