Skip to content
Open
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 @@ -30,6 +30,8 @@
import hudson.model.Queue;
import hudson.model.queue.CauseOfBlockage;
import hudson.model.queue.QueueTaskDispatcher;

import java.util.logging.Level;
import java.util.logging.Logger;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
Expand Down Expand Up @@ -58,24 +60,34 @@
}

@Override public CauseOfBlockage canTake(Node node, Queue.BuildableItem item) {
// as this method can be a hostspot, do not use a Supplier in logging statements
// rather guard the logging statement inside an if
final boolean isFiner = LOGGER.isLoggable(Level.FINER);
Comment thread
sghill marked this conversation as resolved.
if (isContinued(item.task)) {
LOGGER.finer(() -> item.task + " is a continued task, so we are not blocking it");
if (isFiner) {

Check warning on line 67 in src/main/java/org/jenkinsci/plugins/durabletask/executors/ContinuedTask.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 67 is only partially covered, one branch is missing
LOGGER.finer(item.task + " is a continued task, so we are not blocking it");
}
return null;
}
final boolean isFine = LOGGER.isLoggable(Level.FINE);
for (Queue.BuildableItem other : Queue.getInstance().getBuildableItems()) {
if (isContinued(other.task)) {
Label label = other.task.getAssignedLabel();
if (label == null || label.matches(node)) { // conservative; might actually go to a different node
LOGGER.fine(() -> "blocking " + item.task + " in favor of " + other.task);
if (isFine) {

Check warning on line 77 in src/main/java/org/jenkinsci/plugins/durabletask/executors/ContinuedTask.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 77 is only partially covered, one branch is missing
LOGGER.fine("blocking " + item.task + " in favor of " + other.task);
}
return new HoldOnPlease(other.task);
} else {
LOGGER.finer(() -> other.task + "’s label " + label + " does not match " + node);
} else if (isFiner) {
LOGGER.finer(other.task + "’s label " + label + " does not match " + node);

Check warning on line 82 in src/main/java/org/jenkinsci/plugins/durabletask/executors/ContinuedTask.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 81-82 are not covered by tests
}
} else {
LOGGER.finer(() -> other.task + " is not continued, so it would not block " + item.task);
} else if (isFiner) {
LOGGER.finer(other.task + " is not continued, so it would not block " + item.task);
}
}
LOGGER.finer(() -> "no reason to block " + item.task);
if (isFiner) {
LOGGER.finer("no reason to block " + item.task);
}
return null;
}

Expand Down