Skip to content

Commit

Permalink
[FIXED JENKINS-21618] Ensure that the LoadStatistics return a self-co…
Browse files Browse the repository at this point in the history
…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 6b8af39
Show file tree
Hide file tree
Showing 8 changed files with 588 additions and 73 deletions.
11 changes: 11 additions & 0 deletions core/src/main/java/hudson/model/Label.java
Expand Up @@ -39,6 +39,7 @@
import hudson.model.labels.LabelExpressionParser; import hudson.model.labels.LabelExpressionParser;
import hudson.model.labels.LabelOperatorPrecedence; import hudson.model.labels.LabelOperatorPrecedence;
import hudson.model.labels.LabelVisitor; import hudson.model.labels.LabelVisitor;
import hudson.model.queue.SubTask;
import hudson.security.ACL; import hudson.security.ACL;
import hudson.slaves.NodeProvisioner; import hudson.slaves.NodeProvisioner;
import hudson.slaves.Cloud; import hudson.slaves.Cloud;
Expand Down Expand Up @@ -107,6 +108,16 @@ public int computeTotalExecutors() {
public int computeQueueLength() { public int computeQueueLength() {
return Jenkins.getInstance().getQueue().countBuildableItemsFor(Label.this); return Jenkins.getInstance().getQueue().countBuildableItemsFor(Label.this);
} }

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

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

0 comments on commit 6b8af39

Please sign in to comment.