提交 c71690b7 编写于 作者: S stephenconnolly

better logging

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@9445 71c3de6d-444a-0410-be80-ed276b4c234a
上级 7060c5ff
package hudson.slaves;
import hudson.ExtensionPoint;
import hudson.Util;
import hudson.model.*;
import hudson.util.DescriptorList;
import org.kohsuke.stapler.DataBoundConstructor;
......@@ -150,23 +151,26 @@ public abstract class RetentionStrategy<T extends Computer> implements Describab
if (c.isOffline()) {
final Queue queue = Hudson.getInstance().getQueue();
for (Queue.Item item : queue.getBuildableItems(c)) {
if ((System.currentTimeMillis() - item.buildableStartMilliseconds) >
final long demandMilliseconds = System.currentTimeMillis() - item.buildableStartMilliseconds;
if (demandMilliseconds >
TimeUnit.MILLISECONDS.convert(inDemandDelay, TimeUnit.MINUTES)) {
// we've been in demand for long enough
logger.log(Level.INFO, "Trying to launch computer {0} as it has been in demand for too long",
c.getNode().getNodeName());
if (c.isOffline() && c.isLaunchSupported())
c.tryReconnect();
logger.log(Level.INFO, "Launching computer {0} as it has been in demand for {1}",
new Object[]{c.getNode().getNodeName(), Util.getTimeSpanString(demandMilliseconds)});
if (c.isLaunchSupported())
c.launch();
break;
}
}
} else {
if (c.isIdle()) {
if (System.currentTimeMillis() - c.getIdleStartMilliseconds() >
final long idleMilliseconds = System.currentTimeMillis() - c.getIdleStartMilliseconds();
if (idleMilliseconds >
TimeUnit.MILLISECONDS.convert(inDemandDelay, TimeUnit.MINUTES)) {
// we've been idle for long enough
logger.log(Level.INFO, "Disconnecting computer {0} as it has been idle too long", c.getNode().getNodeName());
logger.log(Level.INFO, "Disconnecting computer {0} as it has been idle for {1}",
new Object[]{c.getNode().getNodeName(), Util.getTimeSpanString(idleMilliseconds)});
c.disconnect();
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册