From 6b8af39b0317bad90851d4f8025fd71fadb9deaa Mon Sep 17 00:00:00 2001 From: Stephen Connolly Date: Wed, 3 Dec 2014 16:41:41 +0000 Subject: [PATCH 1/2] [FIXED JENKINS-21618] Ensure that the LoadStatistics return a self-consistent 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. --- core/src/main/java/hudson/model/Label.java | 11 + .../java/hudson/model/LoadStatistics.java | 426 +++++++++++++++++- .../hudson/model/OverallLoadStatistics.java | 13 +- .../java/hudson/slaves/NodeProvisioner.java | 140 ++++-- core/src/main/java/jenkins/model/Jenkins.java | 3 +- .../model/UnlabeledLoadStatistics.java | 48 ++ .../hudson/model/Messages.properties | 5 + .../java/hudson/model/LoadStatisticsTest.java | 17 +- 8 files changed, 589 insertions(+), 74 deletions(-) diff --git a/core/src/main/java/hudson/model/Label.java b/core/src/main/java/hudson/model/Label.java index cdfcfb5e86..7e8510e06a 100644 --- a/core/src/main/java/hudson/model/Label.java +++ b/core/src/main/java/hudson/model/Label.java @@ -39,6 +39,7 @@ import hudson.model.labels.LabelExpressionLexer; import hudson.model.labels.LabelExpressionParser; import hudson.model.labels.LabelOperatorPrecedence; import hudson.model.labels.LabelVisitor; +import hudson.model.queue.SubTask; import hudson.security.ACL; import hudson.slaves.NodeProvisioner; import hudson.slaves.Cloud; @@ -107,6 +108,16 @@ public abstract class Label extends Actionable implements Comparable