本文整理匯總了Java中jenkins.model.Jenkins.removeNode方法的典型用法代碼示例。如果您正苦於以下問題:Java Jenkins.removeNode方法的具體用法?Java Jenkins.removeNode怎麽用?Java Jenkins.removeNode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類jenkins.model.Jenkins
的用法示例。
在下文中一共展示了Jenkins.removeNode方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: removeNode
import jenkins.model.Jenkins; //導入方法依賴的package包/類
private synchronized void removeNode(String instanceId) {
final Jenkins jenkins=Jenkins.getInstance();
//noinspection SynchronizationOnLocalVariableOrMethodParameter
synchronized (jenkins) {
// If this node is dying, remove it from Jenkins
final Node n = jenkins.getNode(instanceId);
if (n != null) {
try {
jenkins.removeNode(n);
} catch(final Exception ex) {
LOGGER.log(Level.WARNING, "Error removing node " + instanceId);
throw new IllegalStateException(ex);
}
}
}
}
示例2: addNewSlave
import jenkins.model.Jenkins; //導入方法依賴的package包/類
private void addNewSlave(final AmazonEC2 ec2, final String instanceId) throws Exception {
// Generate a random FS root if one isn't specified
String fsRoot = this.fsRoot;
if (fsRoot == null || fsRoot.equals("")) {
fsRoot = "/tmp/jenkins-"+UUID.randomUUID().toString().substring(0, 8);
}
final DescribeInstancesResult result=ec2.describeInstances(
new DescribeInstancesRequest().withInstanceIds(instanceId));
if (result.getReservations().isEmpty()) //Can't find this instance, skip it
return;
final Instance instance=result.getReservations().get(0).getInstances().get(0);
final String address = isPrivateIpUsed() ?
instance.getPrivateIpAddress() : instance.getPublicIpAddress();
// Check if we have the address to use. Nodes don't get it immediately.
if (address == null)
return; // Wait some more...
final FleetNode slave = new FleetNode(instanceId, "Fleet slave for" + instanceId,
fsRoot, this.numExecutors.toString(), Node.Mode.NORMAL, this.labelString, new ArrayList<NodeProperty<?>>(),
FLEET_CLOUD_ID, computerConnector.launch(address, TaskListener.NULL));
// Initialize our retention strategy
if (getIdleMinutes() != null)
slave.setRetentionStrategy(new IdleRetentionStrategy(getIdleMinutes(), this));
final Jenkins jenkins=Jenkins.getInstance();
//noinspection SynchronizationOnLocalVariableOrMethodParameter
synchronized (jenkins) {
// Try to avoid duplicate nodes
final Node n = jenkins.getNode(instanceId);
if (n != null)
jenkins.removeNode(n);
jenkins.addNode(slave);
}
//A new node, wheee!
instancesSeen.add(instanceId);
if (!plannedNodes.isEmpty())
{
//If we're waiting for a new node - mark it as ready
final NodeProvisioner.PlannedNode curNode=plannedNodes.iterator().next();
plannedNodes.remove(curNode);
((SettableFuture<Node>)curNode.future).set(slave);
}
}