private void makeBuildable(BuildableItem p) { if (Hudson.FLYWEIGHT_SUPPORT && p.task instanceof FlyweightTask) { ConsistentHash<Node> hash = new ConsistentHash<Node>( new Hash<Node>() { public String hash(Node node) { return node.getNodeName(); } }); Hudson h = Hudson.getInstance(); hash.add(h, h.getNumExecutors() * 100); for (Node n : h.getNodes()) hash.add(n, n.getNumExecutors() * 100); for (Node n : hash.list(p.task.getFullDisplayName())) { Computer c = n.toComputer(); if (c == null) continue; c.startFlyWeightTask(p); return; } // if the execution get here, it means we couldn't schedule it anywhere. // so do the scheduling like other normal jobs. } buildables.put(p.task, p); }