Ejemplo n.º 1
0
  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);
  }
Ejemplo n.º 2
0
    @Override
    public String getWhy() {
      Hudson hudson = Hudson.getInstance();
      if (hudson.isQuietingDown()) return Messages.Queue_HudsonIsAboutToShutDown();

      Label label = task.getAssignedLabel();
      if (hudson.getNodes().isEmpty())
        label = null; // no master/slave. pointless to talk about nodes

      String name = null;
      if (label != null) {
        name = label.getName();
        if (label.isOffline()) {
          if (label.getNodes().size() > 1) return Messages.Queue_AllNodesOffline(name);
          else return Messages.Queue_NodeOffline(name);
        }
      }

      if (name == null) return Messages.Queue_WaitingForNextAvailableExecutor();
      else return Messages.Queue_WaitingForNextAvailableExecutorOn(name);
    }