本文整理汇总了Java中hudson.slaves.NodeProvisioner.PlannedNode方法的典型用法代码示例。如果您正苦于以下问题:Java NodeProvisioner.PlannedNode方法的具体用法?Java NodeProvisioner.PlannedNode怎么用?Java NodeProvisioner.PlannedNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hudson.slaves.NodeProvisioner
的用法示例。
在下文中一共展示了NodeProvisioner.PlannedNode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onStarted
import hudson.slaves.NodeProvisioner; //导入方法依赖的package包/类
@Override @Restricted(DoNotUse.class)
public void onStarted(Cloud cloud, Label label, Collection<NodeProvisioner.PlannedNode> plannedNodes) {
BulkChange change = new BulkChange(stats);
try {
boolean changed = false;
for (NodeProvisioner.PlannedNode plannedNode : plannedNodes) {
ProvisioningActivity.Id id = getIdFor(plannedNode);
if (id != null) {
onStarted(id);
changed = true;
}
}
if (changed) {
// Not using change.commit() here as persist handles exceptions already
stats.persist();
}
} finally {
change.abort();
}
}
示例2: provision
import hudson.slaves.NodeProvisioner; //导入方法依赖的package包/类
@Override
public Collection<NodeProvisioner.PlannedNode> provision(Label label, int excessWorkload) {
try {
List<NodeProvisioner.PlannedNode> r = new ArrayList<NodeProvisioner.PlannedNode>();
final ECSTaskTemplate template = getTemplate(label);
for (int i = 1; i <= excessWorkload; i++) {
r.add(new NodeProvisioner.PlannedNode(template.getDisplayName(), Computer.threadPoolForRemoting
.submit(new ProvisioningCallback(template, label)), 1));
}
return r;
} catch (Exception e) {
LOGGER.log(Level.WARNING, "Failed to provision ECS slave", e);
return Collections.emptyList();
}
}
示例3: testProvision
import hudson.slaves.NodeProvisioner; //导入方法依赖的package包/类
@Test
public void testProvision() {
int workload = 3;
Collection<NodeProvisioner.PlannedNode> plannedNodes = nomadCloud.provision(label, workload);
Assert.assertEquals(plannedNodes.size(), workload);
}
示例4: provision
import hudson.slaves.NodeProvisioner; //导入方法依赖的package包/类
@Override public synchronized Collection<NodeProvisioner.PlannedNode> provision(
final Label label, final int excessWorkload) {
final FleetStateStats stats=updateStatus();
final int maxAllowed = this.getMaxSize();
if (stats.getNumDesired() >= maxAllowed || !"active".equals(stats.getState()))
return Collections.emptyList();
int targetCapacity = stats.getNumDesired() + excessWorkload;
if (targetCapacity > maxAllowed)
targetCapacity = maxAllowed;
int toProvision = targetCapacity - stats.getNumDesired();
LOGGER.log(Level.INFO, "Provisioning nodes. Excess workload: " + Integer.toString(excessWorkload) + ", Provisioning: " + Integer.toString(toProvision));
final ModifySpotFleetRequestRequest request=new ModifySpotFleetRequestRequest();
request.setSpotFleetRequestId(fleet);
request.setTargetCapacity(targetCapacity);
final AmazonEC2 ec2=connect(credentialsId, region);
ec2.modifySpotFleetRequest(request);
final List<NodeProvisioner.PlannedNode> resultList =
new ArrayList<NodeProvisioner.PlannedNode>();
for(int f=0;f<toProvision; ++f)
{
final SettableFuture<Node> futureNode=SettableFuture.create();
final NodeProvisioner.PlannedNode plannedNode=
new NodeProvisioner.PlannedNode("FleetNode-"+f, futureNode, 1);
resultList.add(plannedNode);
this.plannedNodes.add(plannedNode);
}
return resultList;
}
示例5: onComplete
import hudson.slaves.NodeProvisioner; //导入方法依赖的package包/类
@Override @Restricted(DoNotUse.class)
public void onComplete(NodeProvisioner.PlannedNode plannedNode, Node node) {
ProvisioningActivity.Id id = getIdFor(plannedNode);
if (id != null) {
onComplete(id, node);
}
}
示例6: onFailure
import hudson.slaves.NodeProvisioner; //导入方法依赖的package包/类
@Override @Restricted(DoNotUse.class)
public void onFailure(NodeProvisioner.PlannedNode plannedNode, Throwable t) {
ProvisioningActivity.Id id = getIdFor(plannedNode);
if (id != null) {
onFailure(id, t);
}
}
示例7: getIdFor
import hudson.slaves.NodeProvisioner; //导入方法依赖的package包/类
private static @CheckForNull ProvisioningActivity.Id getIdFor(NodeProvisioner.PlannedNode plannedNode) {
if (!(plannedNode instanceof TrackedItem)) {
logTypeNotSupported(plannedNode.getClass());
return null;
}
return ((TrackedItem) plannedNode).getId();
}
示例8: provision
import hudson.slaves.NodeProvisioner; //导入方法依赖的package包/类
@Override
public Collection<NodeProvisioner.PlannedNode> provision(Label label, int excessWorkload) {
assert provision != null;
provision.j = j;
int i = seq.getAndIncrement();
provision.id = new ProvisioningActivity.Id(name, null, name + "-slave-" + i);
return Collections.<NodeProvisioner.PlannedNode>singletonList(new TrackedPlannedNode(
provision.id, 1, Computer.threadPoolForRemoting.submit(provision)
));
}
示例9: provision
import hudson.slaves.NodeProvisioner; //导入方法依赖的package包/类
@Override
public Collection<NodeProvisioner.PlannedNode> provision(Label label, int excessWorkload)
{
LOGGER.log(Level.SEVERE, "Going to provision " + excessWorkload + " executors");
Collection<NodeProvisioner.PlannedNode> result = new ArrayList<NodeProvisioner.PlannedNode>();
final ParallelsDesktopConnectorSlaveComputer connector = getConnector();
for (int i = 0; (i < vms.size()) && (excessWorkload > 0); i++)
{
final ParallelsDesktopVM vm = vms.get(i);
if (vm.isProvisioned())
continue;
if (!label.matches(Label.parse(vm.getLabels())))
continue;
final String vmId = vm.getVmid();
final String slaveName = name + " " + vmId;
vm.setSlaveName(slaveName);
vm.setProvisioned(true);
--excessWorkload;
result.add(new NodeProvisioner.PlannedNode(slaveName,
Computer.threadPoolForRemoting.submit(new Callable<Node>()
{
@Override
public Node call() throws Exception
{
connector.checkVmExists(vmId);
return connector.createSlaveOnVM(vm);
}
}), 1));
}
return result;
}
示例10: applyFoCloud
import hudson.slaves.NodeProvisioner; //导入方法依赖的package包/类
private StrategyDecision applyFoCloud(@Nonnull NodeProvisioner.StrategyState state, DockerCloud cloud) {
final Label label = state.getLabel();
if (!cloud.canProvision(label)) {
return CONSULT_REMAINING_STRATEGIES;
}
LoadStatistics.LoadStatisticsSnapshot snapshot = state.getSnapshot();
LOGGER.log(FINEST, "Available executors={0}, connecting={1}, planned={2}",
new Object[]{snapshot.getAvailableExecutors(), snapshot.getConnectingExecutors(), state.getPlannedCapacitySnapshot()});
int availableCapacity =
snapshot.getAvailableExecutors()
+ snapshot.getConnectingExecutors()
+ state.getPlannedCapacitySnapshot();
int currentDemand = snapshot.getQueueLength();
LOGGER.log(FINE, "Available capacity={0}, currentDemand={1}",
new Object[]{availableCapacity, currentDemand});
if (availableCapacity < currentDemand) {
Collection<NodeProvisioner.PlannedNode> plannedNodes = cloud.provision(label, currentDemand - availableCapacity);
LOGGER.log(FINE, "Planned {0} new nodes", plannedNodes.size());
state.recordPendingLaunches(plannedNodes);
availableCapacity += plannedNodes.size();
LOGGER.log(FINE, "After provisioning, available capacity={0}, currentDemand={1}",
new Object[]{availableCapacity, currentDemand});
}
if (availableCapacity >= currentDemand) {
LOGGER.log(FINE, "Provisioning completed");
return PROVISIONING_COMPLETED;
} else {
LOGGER.log(FINE, "Provisioning not complete, consulting remaining strategies");
return CONSULT_REMAINING_STRATEGIES;
}
}
示例11: addNewSlave
import hudson.slaves.NodeProvisioner; //导入方法依赖的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);
}
}
示例12: provision
import hudson.slaves.NodeProvisioner; //导入方法依赖的package包/类
@Override
public Collection<NodeProvisioner.PlannedNode> provision(Label label, int excessWorkload) {
// Don't provision a node here. Provisioning is handled in DockerJobLoadBalancer.
return ImmutableList.of();
}
示例13: provision
import hudson.slaves.NodeProvisioner; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public Collection<NodeProvisioner.PlannedNode> provision(Label label, int excessWorkload) {
final RavelloSlaveBlueprint t = getSlaveBlueprintByLabel(label);
List<NodeProvisioner.PlannedNode> r = new ArrayList<NodeProvisioner.PlannedNode>();
// while (excessWorkload > 0
// && !Jenkins.getInstance().isQuietingDown()
// && !Jenkins.getInstance().isTerminating()) {
// if ((getRunningNodesCount() + r.size()) >= instanceCap) {
// LOGGER.info("Instance cap reached while adding capacity for label " + ((label != null) ? label.toString() : "null"));
// break; // maxed out
// }
//
// r.add(new NodeProvisioner.PlannedNode(t.name, RavelloSlaveComputer.threadPoolForRemoting.submit(new Callable<RavelloSlave>() {
// public RavelloSlave call() throws Exception {
// // TODO: record the output somewhere
// RavelloSlaveBlueprint s = t.provisionSlave(new StreamTaskListener(System.out));
// Hudson.getInstance().addNode(s);
// // Cloud instances may have a long init script. If
// // we declare
// // the provisioning complete by returning without
// // the connect
// // operation, NodeProvisioner may decide that it
// // still wants
// // one more instance, because it sees that (1) all
// // the slaves
// // are offline (because it's still being launched)
// // and
// // (2) there's no capacity provisioned yet.
// //
// // deferring the completion of provisioning until
// // the launch
// // goes successful prevents this problem.
// s.toComputer().connect(false).get();
// return s;
// }
// }), Util.tryParseNumber(t.numExecutors, 1).intValue()));
// excessWorkload -= t.getNumExecutors();
// }
return r;
}
示例14: provision
import hudson.slaves.NodeProvisioner; //导入方法依赖的package包/类
/**
* The actual logic for provisioning a new droplet when it's needed by Jenkins.
*
* @param label
* @param excessWorkload
* @return
*/
@Override
public Collection<NodeProvisioner.PlannedNode> provision(Label label, int excessWorkload) {
if (label != null) {
LOGGER.info("Provisioning digitalocean droplet for label " + label.getName() + ", excessWorkload " + excessWorkload);
} else {
LOGGER.info("Provisioning digitalocean droplet without label, excessWorkload " + excessWorkload);
}
List<NodeProvisioner.PlannedNode> nodes = new ArrayList<NodeProvisioner.PlannedNode>();
final DigitalOceanClient apiClient = new DigitalOceanClient(clientId, apiKey);
final SlaveTemplate template = getTemplate(label);
try {
while (excessWorkload > 0) {
if (!addProvisionedSlave(template.getImageId())) {
break;
}
nodes.add(new NodeProvisioner.PlannedNode(template.getDropletName(), Computer.threadPoolForRemoting.submit(new Callable<Node>() {
public Node call() throws Exception {
// TODO: record the output somewhere
try {
Slave slave = template.provision(apiClient, privateKey, sshKeyId, new StreamTaskListener(System.out, Charset.defaultCharset()));
Jenkins.getInstance().addNode(slave);
slave.toComputer().connect(false).get();
return slave;
} finally {
decrementDropletSlaveProvision(template.imageId);
}
}
}), template.getNumExecutors()));
excessWorkload -= template.getNumExecutors();
}
LOGGER.info("Provisioning " + nodes.size() + " DigitalOcean nodes");
return nodes;
} catch (Exception e) {
LOGGER.log(Level.WARNING, e.getMessage(), e);
return Collections.emptyList();
}
}
示例15: provision
import hudson.slaves.NodeProvisioner; //导入方法依赖的package包/类
public Collection<NodeProvisioner.PlannedNode> provision(Label label, int excessWorkload) {
return Collections.emptySet();
}