From e34d9bed4e301a369a7578f2809c36795dcf5c25 Mon Sep 17 00:00:00 2001 From: kohsuke Date: Tue, 8 Apr 2008 00:02:18 +0000 Subject: [PATCH] Tweaking the algorithm to avoid putting load on the master. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@8358 71c3de6d-444a-0410-be80-ed276b4c234a --- core/src/main/java/hudson/model/Queue.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/hudson/model/Queue.java b/core/src/main/java/hudson/model/Queue.java index c00c2e842b..417ac4c7ff 100644 --- a/core/src/main/java/hudson/model/Queue.java +++ b/core/src/main/java/hudson/model/Queue.java @@ -427,21 +427,30 @@ public class Queue extends ResourceController { return null; } + // if we are a large deployment, then we will favor slaves + boolean isLargeHudson = Hudson.getInstance().getSlaves().size()>10; + // otherwise let's see if the last node where this project was built is available // it has up-to-date workspace, so that's usually preferable. // (but we can't use an exclusive node) Node n = p.getLastBuiltOn(); if(n!=null && n.getMode()==Mode.NORMAL) { for (JobOffer offer : parked.values()) { - if(offer.isAvailable() && offer.getNode()==n) + if(offer.isAvailable() && offer.getNode()==n) { + if(isLargeHudson && offer.getNode() instanceof Slave) + // but if we are a large Hudson, then we really do want to keep the master free from builds + continue; return offer; + } } } // duration of a build on a slave tends not to have an impact on // the master/slave communication, so that means we should favor // running long jobs on slaves. - if(p.getEstimatedDuration()>15*60*1000) { + // Similarly if we have many slaves, master should be made available + // for HTTP requests and coordination as much as possible + if(isLargeHudson || p.getEstimatedDuration()>15*60*1000) { // consider a long job to be > 15 mins for (JobOffer offer : parked.values()) { if(offer.isAvailable() && offer.getNode() instanceof Slave && offer.isNotExclusive())