hudson.model.Node.toComputer()方法的使用及代码示例

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

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

Node.toComputer介绍

[英]Gets the corresponding Computer object.
[中]获取相应的计算机对象。

代码示例

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

  1. /**
  2. * Gets the current channel, if the node is connected and online, or null.
  3. *
  4. * This is just a convenience method for {@link Computer#getChannel()} with null check.
  5. */
  6. @CheckForNull
  7. public final VirtualChannel getChannel() {
  8. Computer c = toComputer();
  9. return c==null ? null : c.getChannel();
  10. }

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

  1. @Override
  2. protected int run() throws Exception {
  3. node.toComputer().waitUntilOnline();
  4. return 0;
  5. }
  6. }

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

  1. @Override
  2. protected int run() throws Exception {
  3. node.toComputer().waitUntilOffline();
  4. return 0;
  5. }
  6. }

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

  1. @Override
  2. protected int run() throws IOException, ServletException {
  3. node.toComputer().updateByXml(stdin);
  4. return 0;
  5. }
  6. }

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

  1. public Builder with(@CheckForNull Node node) {
  2. if (node != null) {
  3. return with(node.toComputer());
  4. }
  5. return this;
  6. }

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

  1. public String getShortDescription() {
  2. String name = (node.toComputer() != null) ? node.toComputer().getDisplayName() : node.getDisplayName();
  3. return Messages.Queue_NodeOffline(name);
  4. }

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

  1. public String getShortDescription() {
  2. String name = (node.toComputer() != null) ? node.toComputer().getDisplayName() : node.getDisplayName();
  3. return Messages.Queue_WaitingForNextAvailableExecutorOn(name);
  4. }

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

  1. node.toComputer().doDoDelete();
  2. } catch (Exception e) {
  3. if(hs.size() == 1) {

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

  1. @Override
  2. public String getShortDescription() {
  3. Computer computer = node.toComputer();
  4. String name = computer != null ? computer.getDisplayName() : node.getDisplayName();
  5. return Messages.Node_BecauseNodeIsNotAcceptingTasks(name);
  6. }

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

  1. public String getSearchUrl() {
  2. Computer c = toComputer();
  3. if (c != null) {
  4. return c.getUrl();
  5. }
  6. return "computer/" + Util.rawEncode(getNodeName());
  7. }

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

  1. /**
  2. * Returns true if all the nodes of this label is offline.
  3. */
  4. @Exported
  5. public boolean isOffline() {
  6. for (Node n : getNodes()) {
  7. Computer c = n.toComputer();
  8. if(c != null && !c.isOffline())
  9. return false;
  10. }
  11. return true;
  12. }

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

  1. /**
  2. * Number of busy {@link Executor}s that are carrying out some work right now.
  3. */
  4. @Exported
  5. public int getBusyExecutors() {
  6. int r=0;
  7. for (Node n : getNodes()) {
  8. Computer c = n.toComputer();
  9. if(c!=null && c.isOnline())
  10. r += c.countBusy();
  11. }
  12. return r;
  13. }

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

  1. /**
  2. * Number of total {@link Executor}s that belong to this label that are functioning.
  3. * <p>
  4. * This excludes executors that belong to offline nodes.
  5. */
  6. @Exported
  7. public int getTotalExecutors() {
  8. int r=0;
  9. for (Node n : getNodes()) {
  10. Computer c = n.toComputer();
  11. if(c!=null && c.isOnline())
  12. r += c.countExecutors();
  13. }
  14. return r;
  15. }

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

  1. @Override
  2. public void run() {
  3. Computer c = node.toComputer();
  4. if (c != null) {
  5. c.recordTermination();
  6. c.disconnect(OfflineCause.create(hudson.model.Messages._Hudson_NodeBeingRemoved()));
  7. }
  8. if (node == nodes.remove(node.getNodeName())) {
  9. jenkins.updateComputerList();
  10. jenkins.trimLabels();
  11. }
  12. }
  13. });

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

  1. /**
  2. * Number of idle {@link Executor}s that can start working immediately.
  3. */
  4. @Exported
  5. public int getIdleExecutors() {
  6. int r=0;
  7. for (Node n : getNodes()) {
  8. Computer c = n.toComputer();
  9. if(c!=null && (c.isOnline() || c.isConnecting()) && c.isAcceptingTasks())
  10. r += c.countIdle();
  11. }
  12. return r;
  13. }

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

  1. private WorkspaceOfflineReason workspaceOffline(R build) throws IOException, InterruptedException {
  2. FilePath ws = build.getWorkspace();
  3. Label label = getAssignedLabel();
  4. if (isAllSuitableNodesOffline(build)) {
  5. Collection<Cloud> applicableClouds = label == null ? Jenkins.getInstance().clouds : label.getClouds();
  6. return applicableClouds.isEmpty() ? WorkspaceOfflineReason.all_suitable_nodes_are_offline : WorkspaceOfflineReason.use_ondemand_slave;
  7. }
  8. if (ws==null || !ws.exists()) {
  9. return WorkspaceOfflineReason.nonexisting_workspace;
  10. }
  11. Node builtOn = build.getBuiltOn();
  12. if (builtOn == null) { // node built-on doesn't exist anymore
  13. return WorkspaceOfflineReason.builton_node_gone;
  14. }
  15. if (builtOn.toComputer() == null) { // node still exists, but has 0 executors - o.s.l.t.
  16. return WorkspaceOfflineReason.builton_node_no_executors;
  17. }
  18. return null;
  19. }

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

  1. public static String encodeTo(Node node) {
  2. Computer c = node.toComputer();
  3. if (c != null) {
  4. return encodeTo("/" + c.getUrl(), node.getDisplayName());
  5. }
  6. String nodePath = node == Jenkins.getInstance() ? "(master)" : node.getNodeName();
  7. return encodeTo("/computer/" + nodePath, node.getDisplayName());
  8. }

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

  1. final Computer computer = node.toComputer();
  2. if (computer != null) {

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

  1. /**
  2. * Adds a node
  3. *
  4. * @since 1.513
  5. */
  6. public ContextMenu add(Node n) {
  7. Computer c = n.toComputer();
  8. return add(new MenuItem()
  9. .withDisplayName(n.getDisplayName())
  10. .withStockIcon((c==null) ? "computer.png" : c.getIcon())
  11. .withContextRelativeUrl(n.getSearchUrl()));
  12. }

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

  1. if(canRoam) {
  2. for (Node n : Jenkins.getInstance().getNodes()) {
  3. Computer c = n.toComputer();
  4. if (c != null && c.isOnline() && c.isAcceptingTasks() && n.getMode() == Mode.NORMAL) {

相关文章