提交 bd0e8ef3 编写于 作者: K Kohsuke Kawaguchi

added another callback

上级 e837438c
......@@ -140,6 +140,7 @@ public abstract class AbstractCIBase extends Node implements ItemGroup<TopLevelI
for (Map.Entry<Node, Computer> e : computers.entrySet()) {
if (e.getValue() == computer) {
computers.remove(e.getKey());
computer.onRemoved();
return;
}
}
......
......@@ -663,11 +663,26 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
/**
* Called by {@link Jenkins#updateComputerList()} to notify {@link Computer} that it will be discarded.
*
* @see #onRemoved()
*/
protected void kill() {
setNumExecutors(0);
}
/**
* Called by {@link Jenkins} when this computer is removed.
*
* This happens when list of nodes are updated (for example by {@link Jenkins#setNodes(List)} and
* the computer becomes redundant. Such {@link Computer}s get {@linkplain #kill() killed}, then
* after all its executors are finished, this method is called.
*
* @see #kill()
* @since 1.510
*/
protected void onRemoved(){
}
private synchronized void setNumExecutors(int n) {
if(numExecutors==n) return; // no-op
......@@ -1076,8 +1091,8 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
offlineMessage = Util.fixEmptyAndTrim(offlineMessage);
setTemporarilyOffline(true,
OfflineCause.create(hudson.slaves.Messages._SlaveComputer_DisconnectedBy(
Jenkins.getAuthentication().getName(),
offlineMessage!=null ? " : " + offlineMessage : "")));
Jenkins.getAuthentication().getName(),
offlineMessage != null ? " : " + offlineMessage : "")));
return HttpResponses.redirectToDot();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册