hudson.model.Hudson.removeNode()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(90)

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

Hudson.removeNode介绍

[英]Removes a Node from Hudson.
[中]从Hudson中删除节点。

代码示例

代码示例来源:origin: hudson/hudson-2.x

/**
 * Releases and removes this slave.
 */
public void terminate() throws InterruptedException, IOException {
  try {
    // TODO: send the output to somewhere real
    _terminate(new StreamTaskListener(System.out, Charset.defaultCharset()));
  } finally {
    try {
      Hudson.getInstance().removeNode(this);
    } catch (IOException e) {
      LOGGER.log(Level.WARNING, "Failed to remove "+name,e);
    }
  }
}

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

/**
 * Releases and removes this slave.
 */
public void terminate() throws InterruptedException, IOException {
  try {
    // TODO: send the output to somewhere real
    _terminate(new StreamTaskListener(System.out, Charset.defaultCharset()));
  } finally {
    try {
      Hudson.getInstance().removeNode(this);
    } catch (IOException e) {
      LOGGER.log(Level.WARNING, "Failed to remove "+name,e);
    }
  }
}

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

/**
 * Releases and removes this slave.
 */
public void terminate() throws InterruptedException, IOException {
  try {
    // TODO: send the output to somewhere real
    _terminate(new StreamTaskListener(System.out, Charset.defaultCharset()));
  } finally {
    try {
      Hudson.getInstance().removeNode(this);
    } catch (IOException e) {
      LOGGER.log(Level.WARNING, "Failed to remove "+name,e);
    }
  }
}

代码示例来源:origin: jenkinsci/mesos-plugin

public void terminate() {
 LOGGER.info("Terminating slave " + getNodeName());
 try {
  // Remove the node from hudson.
  Hudson.getInstance().removeNode(this);
  ComputerLauncher launcher = getLauncher();
  // If this is a mesos computer launcher, terminate the launcher.
  if (launcher instanceof MesosComputerLauncher) {
   ((MesosComputerLauncher) launcher).terminate();
  }
 } catch (IOException e) {
  LOGGER.log(Level.WARNING, "Failed to terminate Mesos instance: "
    + getInstanceId(), e);
 }
}

代码示例来源:origin: Netflix-Skunkworks/dynaslave-plugin

public long check(final SlaveComputer c) {
  if (c.isOffline() && !disabled.get()) {
    final long idleMilliseconds = System.currentTimeMillis() - c.getIdleStartMilliseconds();
    final long defaultIdleMinutes = (this.idleMinutes != null ? this.idleMinutes.get() : 30);
    if (idleMilliseconds > MINUTES.toMillis(defaultIdleMinutes)) {
      LOGGER.info("Disconnecting dynaslave " + c.getName());
      try {
        Hudson.getInstance().removeNode(c.getNode());
      } catch (IOException e) {
        LOGGER.log(WARNING, "Failed to terminate " + c.getName(), e);
      }
    }
  }
  return 1;
}

代码示例来源:origin: org.jenkins-ci.plugins/ec2

@Override
public Node reconfigure(final StaplerRequest req, JSONObject form) throws FormException {
  if (form == null) {
    return null;
  }
  if (!isAlive(true)) {
    LOGGER.info("EC2 instance terminated externally: " + getInstanceId());
    try {
      Hudson.getInstance().removeNode(this);
    } catch (IOException ioe) {
      LOGGER.log(Level.WARNING, "Attempt to reconfigure EC2 instance which has been externally terminated: " + getInstanceId(), ioe);
    }

    return null;
  }
  return super.reconfigure(req, form);
}

代码示例来源:origin: org.jenkins-ci.plugins/ec2

Hudson.getInstance().removeNode(this);
} catch (IOException e){
  LOGGER.log(Level.WARNING,"Failed to remove slave: "+name, e);

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

/**
 * Really deletes the slave.
 */
@CLIMethod(name="delete-node")
public HttpResponse doDoDelete() throws IOException {
  checkPermission(DELETE);
  Hudson.getInstance().removeNode(getNode());
  return new HttpRedirect("..");
}

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

/**
 * Releases and removes this slave.
 */
public void terminate() throws InterruptedException, IOException {
  try {
    // TODO: send the output to somewhere real
    _terminate(new StreamTaskListener(System.out, Charset.defaultCharset()));
  } finally {
    try {
      Hudson hudson = Hudson.getInstance();
      hudson.removeNode(this);
      if (hudson.isTeamManagementEnabled()) {
        hudson.getTeamManager().removeNode(getNodeName());
      }
    } catch (IOException e) {
      LOGGER.log(Level.WARNING, "Failed to remove " + name, e);
    }
  }
}

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

/**
 * Really deletes the slave.
 */
@CLIMethod(name="delete-node")
public HttpResponse doDoDelete() throws IOException {
  checkPermission(DELETE);
  Hudson.getInstance().removeNode(getNode());
  return new HttpRedirect("..");
}

代码示例来源:origin: hudson/hudson-2.x

/**
 * Really deletes the slave.
 */
@CLIMethod(name="delete-node")
public HttpResponse doDoDelete() throws IOException {
  checkPermission(DELETE);
  Hudson.getInstance().removeNode(getNode());
  return new HttpRedirect("..");
}

代码示例来源:origin: org.jenkins-ci.plugins/ec2

/**
 * Terminates the instance in EC2.
 */
public void terminate() {
  try {
    if (!isAlive(true)) {
      /* The node has been killed externally, so we've nothing to do here */
      LOGGER.info("EC2 instance already terminated: "+getInstanceId());
    } else {
      AmazonEC2 ec2 = getCloud().connect();
      TerminateInstancesRequest request = new TerminateInstancesRequest(Collections.singletonList(getInstanceId()));
      ec2.terminateInstances(request);
      LOGGER.info("Terminated EC2 instance (terminated): "+getInstanceId());
    }
    Hudson.getInstance().removeNode(this);
    LOGGER.info("Removed EC2 instance from jenkins master: "+getInstanceId());
  } catch (AmazonClientException e) {
    LOGGER.log(Level.WARNING,"Failed to terminate EC2 instance: "+getInstanceId(),e);
  } catch (IOException e) {
    LOGGER.log(Level.WARNING,"Failed to terminate EC2 instance: "+getInstanceId(),e);
  }
}

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

/**
 * Really deletes the slave.
 */
@CLIMethod(name = "delete-node")
public HttpResponse doDoDelete() throws IOException {
  checkPermission(DELETE);
  Hudson.getInstance().removeNode(getNode());
  removeFromTeam(getName());
  return new HttpRedirect("..");
}

代码示例来源:origin: hudson/hudson-2.x

/**
 * Delete the slave.
 * If request have parameter 'deleteMode' than deleting performs in according with this parameter.
 * @param req StaplerRequest
 * @return HttpResponse
 * @throws IOException if any.
 * @throws ServletException if any.
 */
public HttpResponse doDeleteWithParam(StaplerRequest req) throws IOException, ServletException {
  checkPermission(DELETE);
  String deleteMode = req.getParameter(DELETE_MODE_KEY);
  if (deleteMode != null) {
    if (DELETE_MODE_STOP_KEY.equals(deleteMode)) {
      if (getRunningJobs() != null) {
        for (AbstractProject job : getRunningJobs()) {
          Hudson.getInstance().getQueue().cancel(job);
        }
      }
      for (Executor executor : executors) {
        executor.interrupt();
      }
    }
  }
  Hudson.getInstance().removeNode(getNode());
  return new HttpRedirect("..");
}

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

/**
 * Delete the slave.
 * If request have parameter 'deleteMode' than deleting performs in according with this parameter.
 * @param req StaplerRequest
 * @return HttpResponse
 * @throws IOException if any.
 * @throws ServletException if any.
 */
public HttpResponse doDeleteWithParam(StaplerRequest req) throws IOException, ServletException {
  checkPermission(DELETE);
  String deleteMode = req.getParameter(DELETE_MODE_KEY);
  if (deleteMode != null) {
    if (DELETE_MODE_STOP_KEY.equals(deleteMode)) {
      if (getRunningJobs() != null) {
        for (AbstractProject job : getRunningJobs()) {
          Hudson.getInstance().getQueue().cancel(job);
        }
      }
      for (Executor executor : executors) {
        executor.interrupt();
      }
    }
  }
  Hudson.getInstance().removeNode(getNode());
  return new HttpRedirect("..");
}

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

/**
 * Delete the slave.
 * If request have parameter 'deleteMode' than deleting performs in according with this parameter.
 * @param req StaplerRequest
 * @return HttpResponse
 * @throws IOException if any.
 * @throws ServletException if any.
 */
public HttpResponse doDeleteWithParam(StaplerRequest req) throws IOException, ServletException {
  checkPermission(DELETE);
  String deleteMode = req.getParameter(DELETE_MODE_KEY);
  if (deleteMode != null) {
    if (DELETE_MODE_STOP_KEY.equals(deleteMode)) {
      if (getRunningJobs() != null) {
        for (AbstractProject job : getRunningJobs()) {
          Hudson.getInstance().getQueue().cancel(job);
        }
      }
      for (Executor executor : executors) {
        executor.interrupt();
      }
    }
  }
  Hudson.getInstance().removeNode(getNode());
  return new HttpRedirect("..");
}

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

/**
 * Delete the slave. If request have parameter 'deleteMode' than deleting
 * performs in according with this parameter.
 *
 * @param req StaplerRequest
 * @return HttpResponse
 * @throws IOException if any.
 * @throws ServletException if any.
 */
public HttpResponse doDeleteWithParam(StaplerRequest req) throws IOException, ServletException {
  checkPermission(DELETE);
  String deleteMode = req.getParameter(DELETE_MODE_KEY);
  if (deleteMode != null) {
    if (DELETE_MODE_STOP_KEY.equals(deleteMode)) {
      if (getRunningJobs() != null) {
        for (AbstractProject job : getRunningJobs()) {
          Hudson.getInstance().getQueue().cancel(job);
        }
      }
      for (Executor executor : executors) {
        executor.interrupt();
      }
    }
  }
  Hudson.getInstance().removeNode(getNode());
  removeFromTeam(getName());
  return new HttpRedirect("..");
}

相关文章

微信公众号

最新文章

更多

Hudson类方法