mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-16 21:42:27 +00:00
Added an extension point to allow prodding the NodeProvisioner into taking action faster than it might usually.
This commit is contained in:
1 parent
a5f8484b9a
commit
902cc4e1dd
2 files changed
+24
No files matched your search
@@ -80,6 +80,8 @@ Upcoming changes</a>
|
||||
<li class=rfe>
|
||||
Strongly encrypt proxy credentials
|
||||
(<a href="http://issues.jenkins-ci.org/browse/JENKINS-4002">issue 4002</a>)
|
||||
<li class=rfe>
|
||||
Added an extension point to allow prodding the NodeProvisioner into taking action faster than it might usually.
|
||||
</ul>
|
||||
</div><!--=TRUNK-END=-->
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
*/
|
||||
package hudson.slaves;
|
||||
|
||||
import hudson.model.Computer;
|
||||
import hudson.model.LoadStatistics;
|
||||
import hudson.model.Node;
|
||||
import hudson.model.Hudson;
|
||||
@@ -41,6 +42,7 @@ import java.util.List;
|
||||
import java.util.Collection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.logging.Level;
|
||||
import java.io.IOException;
|
||||
@@ -87,6 +89,8 @@ public class NodeProvisioner {
|
||||
|
||||
private List<PlannedNode> pendingLaunches = new ArrayList<PlannedNode>();
|
||||
|
||||
private transient volatile long lastSuggestedReview;
|
||||
|
||||
/**
|
||||
* Exponential moving average of the "planned capacity" over time, which is the number of
|
||||
* additional executors being brought up.
|
||||
@@ -113,11 +117,29 @@ public class NodeProvisioner {
|
||||
return new ArrayList<PlannedNode>(pendingLaunches);
|
||||
}
|
||||
|
||||
/**
|
||||
* Give the {@link NodeProvisioner} a hint that now would be a good time to think about provisioning some nodes.
|
||||
* The hint will be ignored if subjected to excessive pestering by callers.
|
||||
*
|
||||
* @since 1.415
|
||||
*/
|
||||
public void suggestReviewNow() {
|
||||
if (System.currentTimeMillis() > lastSuggestedReview + TimeUnit.SECONDS.toMillis(1)) {
|
||||
lastSuggestedReview = System.currentTimeMillis();
|
||||
Computer.threadPoolForRemoting.submit(new Runnable() {
|
||||
public void run() {
|
||||
update();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Periodically invoked to keep track of the load.
|
||||
* Launches additional nodes if necessary.
|
||||
*/
|
||||
private synchronized void update() {
|
||||
lastSuggestedReview = System.currentTimeMillis();
|
||||
Hudson hudson = Hudson.getInstance();
|
||||
|
||||
// clean up the cancelled launch activity, then count the # of executors that we are about to bring up.
|
||||
|
||||
Reference in new issue
Block a user