mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-18 06:22:29 +00:00
better logging
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@9445 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
7060c5ffdd
commit
c71690b7ca
1 file changed
+11
-7
@@ -1,6 +1,7 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user