Skip to content
Browse files
[FIXED JENKINS-21618] Ensure that the LoadStatistics return a self-co…
…nsistent result.

The original method of computing load statistics would compute the total and idle counts independently
which could lead to counting errors while jobs started in between the different state counting operations.
This change switches to returning a `LoadStatisticsSnapshot` so that callers will get a single consistent
view of the counts which was valid for at least one point in time during the collection of the snapshot.
  • Loading branch information
stephenc committed Mar 25, 2015
1 parent e9bf4b7 commit 6b8af39b0317bad90851d4f8025fd71fadb9deaa
@@ -39,6 +39,7 @@
import hudson.model.labels.LabelExpressionParser;
import hudson.model.labels.LabelOperatorPrecedence;
import hudson.model.labels.LabelVisitor;
import hudson.model.queue.SubTask;
import hudson.slaves.NodeProvisioner;
import hudson.slaves.Cloud;
@@ -107,6 +108,16 @@ public int computeTotalExecutors() {
public int computeQueueLength() {
return Jenkins.getInstance().getQueue().countBuildableItemsFor(Label.this);

protected Set<Node> getNodes() {
return Label.this.getNodes();

protected boolean matches(SubTask item) {
return item.getAssignedLabel() == Label.this;
this.nodeProvisioner = new NodeProvisioner(this, loadStatistics);

0 comments on commit 6b8af39

Please sign in to comment.