hudson.model.Label.getNodes()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(146)

本文整理了Java中hudson.model.Label.getNodes()方法的一些代码示例,展示了Label.getNodes()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Label.getNodes()方法的具体详情如下:
包路径:hudson.model.Label
类名称:Label
方法名:getNodes

Label.getNodes介绍

[英]Gets all Nodes that belong to this label.
[中]获取属于此标签的所有节点。

代码示例

代码示例来源:origin: jenkinsci/jenkins

@Override
protected Set<Node> getNodes() {
  return Label.this.getNodes();
}

代码示例来源:origin: jenkinsci/jenkins

public boolean contains(Node node) {
  return getNodes().contains(node);
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Returns true if this label is a "self label",
 * which means the label is the name of a {@link Node}.
 */
public boolean isSelfLabel() {
  Set<Node> nodes = getNodes();
  return nodes.size() == 1 && nodes.iterator().next().getSelfLabel() == this;
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * If there's no such label defined in {@link Node} or {@link Cloud}.
 * This is usually used as a signal that this label is invalid.
 */
public boolean isEmpty() {
  return getNodes().isEmpty() && getClouds().isEmpty();
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Number of total {@link Executor}s that belong to this label.
 * <p>
 * This includes executors that belong to offline nodes, so the result
 * can be thought of as a potential capacity, whereas {@link #getTotalExecutors()}
 * is the currently functioning total number of executors.
 * <p>
 * This method doesn't take the dynamically allocatable nodes (via {@link Cloud})
 * into account. If you just want to test if there's some executors, use {@link #isAssignable()}.
 */
public int getTotalConfiguredExecutors() {
  int r=0;
  for (Node n : getNodes())
    r += n.getNumExecutors();
  return r;
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Can jobs be assigned to this label?
 * <p>
 * The answer is yes if there is a reasonable basis to believe that Hudson can have
 * an executor under this label, given the current configuration. This includes
 * situations such as (1) there are offline agents that have this label (2) clouds exist
 * that can provision agents that have this label.
 */
public boolean isAssignable() {
  for (Node n : getNodes())
    if(n.getNumExecutors()>0)
      return true;
  return !getClouds().isEmpty();
}

代码示例来源:origin: jenkinsci/jenkins

@Restricted(DoNotUse.class) // Jelly
public Set<Node> getSortedNodes() {
  Set<Node> r = new TreeSet<>(new NodeSorter());
  r.addAll(getNodes());
  return r;
}

代码示例来源:origin: jenkinsci/jenkins

public ContextMenu doChildrenContextMenu(StaplerRequest request, StaplerResponse response) throws Exception {
  ContextMenu menu = new ContextMenu();
  for (Node node : getNodes()) {
    menu.add(node);
  }
  return menu;
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Returns true if all the nodes of this label is offline.
 */
@Exported
public boolean isOffline() {
  for (Node n : getNodes()) {
    Computer c = n.toComputer();
    if(c != null && !c.isOffline())
      return false;
  }
  return true;
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Returns a human readable text that explains this label.
 */
@Exported
public String getDescription() {
  Set<Node> nodes = getNodes();
  if(nodes.isEmpty()) {
    Set<Cloud> clouds = getClouds();
    if(clouds.isEmpty())
      return Messages.Label_InvalidLabel();
    return Messages.Label_ProvisionedFrom(toString(clouds));
  }
  if(nodes.size()==1)
    return nodes.iterator().next().getNodeDescription();
  return Messages.Label_GroupOf(toString(nodes));
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Number of busy {@link Executor}s that are carrying out some work right now.
 */
@Exported
public int getBusyExecutors() {
  int r=0;
  for (Node n : getNodes()) {
    Computer c = n.toComputer();
    if(c!=null && c.isOnline())
      r += c.countBusy();
  }
  return r;
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Number of total {@link Executor}s that belong to this label that are functioning.
 * <p>
 * This excludes executors that belong to offline nodes.
 */
@Exported
public int getTotalExecutors() {
  int r=0;
  for (Node n : getNodes()) {
    Computer c = n.toComputer();
    if(c!=null && c.isOnline())
      r += c.countExecutors();
  }
  return r;
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Number of idle {@link Executor}s that can start working immediately.
 */
@Exported
public int getIdleExecutors() {
  int r=0;
  for (Node n : getNodes()) {
    Computer c = n.toComputer();
    if(c!=null && (c.isOnline() || c.isConnecting()) && c.isAcceptingTasks())
      r += c.countIdle();
  }
  return r;
}

代码示例来源:origin: jenkinsci/jenkins

public CauseOfBlockage getCauseOfBlockage() {
  Jenkins jenkins = Jenkins.getInstance();
  if(isBlockedByShutdown(task))
    return CauseOfBlockage.fromMessage(Messages._Queue_HudsonIsAboutToShutDown());
  List<CauseOfBlockage> causesOfBlockage = transientCausesOfBlockage;
  Label label = getAssignedLabel();
  List<Node> allNodes = jenkins.getNodes();
  if (allNodes.isEmpty())
    label = null;    // no master/agent. pointless to talk about nodes
  if (label != null) {
    Set<Node> nodes = label.getNodes();
    if (label.isOffline()) {
      if (nodes.size() != 1)      return new BecauseLabelIsOffline(label);
      else                        return new BecauseNodeIsOffline(nodes.iterator().next());
    } else {
      if (causesOfBlockage != null && label.getIdleExecutors() > 0) {
        return new CompositeCauseOfBlockage(causesOfBlockage);
      }
      if (nodes.size() != 1)      return new BecauseLabelIsBusy(label);
      else                        return new BecauseNodeIsBusy(nodes.iterator().next());
    }
  } else if (causesOfBlockage != null && new ComputerSet().getIdleExecutors() > 0) {
    return new CompositeCauseOfBlockage(causesOfBlockage);
  } else {
    return CauseOfBlockage.createNeedsMoreExecutor(Messages._Queue_WaitingForNextAvailableExecutor());
  }
}

代码示例来源:origin: jenkinsci/jenkins

j.getRootUrl(), Util.escape(l.getName()), l.getUrl(), l.getNodes().size(), l.getClouds().size())
);

代码示例来源:origin: jenkinsci/jenkins

if(label.getNodes().isEmpty()) {
  return false;

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

/**
 * Returns true if this label is a "self label",
 * which means the label is the name of a {@link Node}.
 */
public boolean isSelfLabel() {
  Set<Node> nodes = getNodes();
  return nodes.size() == 1 && nodes.iterator().next().getSelfLabel() == this;
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

public ContextMenu doChildrenContextMenu(StaplerRequest request, StaplerResponse response) throws Exception {
  ContextMenu menu = new ContextMenu();
  for (Node node : getNodes()) {
    menu.add(node);
  }
  return menu;
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

/**
 * Returns true if all the nodes of this label is offline.
 */
@Exported
public boolean isOffline() {
  for (Node n : getNodes()) {
    Computer c = n.toComputer();
    if(c != null && !c.isOffline())
      return false;
  }
  return true;
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

/**
 * Returns true if all the nodes of this label is offline.
 */
@Exported
public boolean isOffline() {
  for (Node n : getNodes()) {
    if(n.toComputer() != null && !n.toComputer().isOffline())
      return false;
  }
  return true;
}

相关文章