提交 902cc4e1 编写于 作者: S Stephen Connolly

Added an extension point to allow prodding the NodeProvisioner into taking...

Added an extension point to allow prodding the NodeProvisioner into taking action faster than it might usually.
上级 a5f8484b
...@@ -80,6 +80,8 @@ Upcoming changes</a> ...@@ -80,6 +80,8 @@ Upcoming changes</a>
<li class=rfe> <li class=rfe>
Strongly encrypt proxy credentials Strongly encrypt proxy credentials
(<a href="http://issues.jenkins-ci.org/browse/JENKINS-4002">issue 4002</a>) (<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> </ul>
</div><!--=TRUNK-END=--> </div><!--=TRUNK-END=-->
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
*/ */
package hudson.slaves; package hudson.slaves;
import hudson.model.Computer;
import hudson.model.LoadStatistics; import hudson.model.LoadStatistics;
import hudson.model.Node; import hudson.model.Node;
import hudson.model.Hudson; import hudson.model.Hudson;
...@@ -41,6 +42,7 @@ import java.util.List; ...@@ -41,6 +42,7 @@ import java.util.List;
import java.util.Collection; import java.util.Collection;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger; import java.util.logging.Logger;
import java.util.logging.Level; import java.util.logging.Level;
import java.io.IOException; import java.io.IOException;
...@@ -87,6 +89,8 @@ public class NodeProvisioner { ...@@ -87,6 +89,8 @@ public class NodeProvisioner {
private List<PlannedNode> pendingLaunches = new ArrayList<PlannedNode>(); 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 * Exponential moving average of the "planned capacity" over time, which is the number of
* additional executors being brought up. * additional executors being brought up.
...@@ -113,11 +117,29 @@ public class NodeProvisioner { ...@@ -113,11 +117,29 @@ public class NodeProvisioner {
return new ArrayList<PlannedNode>(pendingLaunches); 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. * Periodically invoked to keep track of the load.
* Launches additional nodes if necessary. * Launches additional nodes if necessary.
*/ */
private synchronized void update() { private synchronized void update() {
lastSuggestedReview = System.currentTimeMillis();
Hudson hudson = Hudson.getInstance(); Hudson hudson = Hudson.getInstance();
// clean up the cancelled launch activity, then count the # of executors that we are about to bring up. // clean up the cancelled launch activity, then count the # of executors that we are about to bring up.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册