From 5f4d50dbfee3e94cd27cce3592f6b525680e3a04 Mon Sep 17 00:00:00 2001 From: mindless Date: Thu, 19 Nov 2009 23:02:11 +0000 Subject: [PATCH] Allow zero for inDemandDelay in RetentionStrategy.Demand. Don't write "launching" in log if launch is not supported. Don't need to call check() every minute for NOOP strategy. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@23874 71c3de6d-444a-0410-be80-ed276b4c234a --- core/src/main/java/hudson/slaves/RetentionStrategy.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/hudson/slaves/RetentionStrategy.java b/core/src/main/java/hudson/slaves/RetentionStrategy.java index 49f3c7fbcd..b2ce5c7ddf 100644 --- a/core/src/main/java/hudson/slaves/RetentionStrategy.java +++ b/core/src/main/java/hudson/slaves/RetentionStrategy.java @@ -105,7 +105,7 @@ public abstract class RetentionStrategy implements Describab */ public static final RetentionStrategy NOOP = new RetentionStrategy() { public long check(Computer c) { - return 1; + return 60; } @Override @@ -176,7 +176,7 @@ public abstract class RetentionStrategy implements Describab @DataBoundConstructor public Demand(long inDemandDelay, long idleDelay) { - this.inDemandDelay = Math.max(1, inDemandDelay); + this.inDemandDelay = Math.max(0, inDemandDelay); this.idleDelay = Math.max(1, idleDelay); } @@ -201,12 +201,11 @@ public abstract class RetentionStrategy implements Describab public synchronized long check(SlaveComputer c) { if (c.isOffline()) { final long demandMilliseconds = System.currentTimeMillis() - c.getDemandStartMilliseconds(); - if (demandMilliseconds > inDemandDelay * 1000 * 60 /*MINS->MILLIS*/) { + if (demandMilliseconds > inDemandDelay * 1000 * 60 /*MINS->MILLIS*/ && c.isLaunchSupported()) { // we've been in demand for long enough logger.log(Level.INFO, "Launching computer {0} as it has been in demand for {1}", new Object[]{c.getName(), Util.getTimeSpanString(demandMilliseconds)}); - if (c.isLaunchSupported()) - c.connect(false); + c.connect(false); } } else if (c.isIdle()) { final long idleMilliseconds = System.currentTimeMillis() - c.getIdleStartMilliseconds(); -- GitLab