hudson.slaves.NodeProvisioner.PlannedNode Java Examples
The following examples show how to use
hudson.slaves.NodeProvisioner.PlannedNode.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KafkaKubernetesCloud.java From remoting-kafka-plugin with MIT License | 6 votes |
@Override public Collection<PlannedNode> provision(Label label, int excessWorkload) { Set<String> allInProvisioning = getNodesInProvisioning(label); LOGGER.info("In provisioning : " + allInProvisioning); int toBeProvisioned = Math.max(0, excessWorkload - allInProvisioning.size()); LOGGER.info("Excess workload after pending Kubernetes agents: " + toBeProvisioned); List<PlannedNode> provisionNodes = new ArrayList<>(); for (int i = 0; i < toBeProvisioned; i++) { PlannedNode node = new PlannedNode(name, Computer.threadPoolForRemoting.submit(() -> new KafkaCloudSlave(this)), AGENT_NUM_EXECUTORS); provisionNodes.add(node); } return provisionNodes; }
Example #2
Source File: ECSCloudTest.java From amazon-ecs-plugin with MIT License | 6 votes |
@Test public void provision_oneagent() throws Exception { List<ECSTaskTemplate> templates = new ArrayList<>(); templates.add(getTaskTemplate("my-template","label")); ECSCloud sut = new ECSCloud("mycloud", "", "mycluster"); sut.setTemplates(templates); sut.setRegionName("eu-west-1"); sut.setJenkinsUrl("http://jenkins.local"); sut.setSlaveTimeoutInSeconds(5); sut.setRetentionTimeout(5); Collection<PlannedNode> plannedNodes = sut.provision(new LabelAtom("label"), 1); Assert.assertEquals(1, plannedNodes.size()); }
Example #3
Source File: DummyCloudImpl.java From jenkins-test-harness with MIT License | 5 votes |
public Collection<PlannedNode> provision(Label label, int excessWorkload) { List<PlannedNode> r = new ArrayList<PlannedNode>(); if(label!=this.label) return r; // provisioning impossible while(excessWorkload>0) { System.out.println("Provisioning"); numProvisioned++; Future<Node> f = Computer.threadPoolForRemoting.submit(new Launcher(delay)); r.add(new PlannedNode(name+" #"+numProvisioned,f,1)); excessWorkload-=1; } return r; }
Example #4
Source File: DockerCloud.java From yet-another-docker-plugin with MIT License | 4 votes |
@SuppressFBWarnings(value = "REC_CATCH_EXCEPTION", justification = "docker-java uses runtime exceptions") @Nonnull @Override public synchronized Collection<PlannedNode> provision(@CheckForNull Label label, int excessWorkload) { LOG.info("Asked to provision load: '{}', for: '{}' label", excessWorkload, label); List<PlannedNode> r = new ArrayList<>(excessWorkload); final List<DockerSlaveTemplate> tryTemplates = getTemplates(label); while (excessWorkload > 0 && !tryTemplates.isEmpty()) { final DockerSlaveTemplate t = tryTemplates.get(0); // get first LOG.info("Will provision '{}', for label: '{}', in cloud: '{}'", t.getDockerContainerLifecycle().getImage(), label, getDisplayName()); try { if (!addProvisionedSlave(t)) { tryTemplates.remove(t); continue; } } catch (Exception e) { LOG.warn("Bad template '{}' in cloud '{}': '{}'. Trying next template...", t.getDockerContainerLifecycle().getImage(), getDisplayName(), e.getMessage(), e); tryTemplates.remove(t); continue; } final ProvisioningActivity.Id id = new ProvisioningActivity.Id(getDisplayName(), t.getDockerContainerLifecycle().getImage()); r.add(new TrackedPlannedNode( id, t.getNumExecutors(), Computer.threadPoolForRemoting.submit(() -> { get().onStarted(id); try { final DockerSlave dockerSlave = provisionWithWait(t, id); get().onComplete(id, dockerSlave); //rename return dockerSlave; } catch (Exception ex) { LOG.error("Error in provisioning; template='{}' for cloud='{}'", t, getDisplayName(), ex); get().onFailure(id, ex); throw Throwables.propagate(ex); } finally { decrementAmiSlaveProvision(t); } }) ) ); excessWorkload -= t.getNumExecutors(); } return r; }
Example #5
Source File: DockerProvisioningStrategy.java From yet-another-docker-plugin with MIT License | 4 votes |
/** * Do asap provisioning for OnceRetention with one executor. The * provisioning strategy is to attempt to find a random least loaded cloud. * Some other configuration may also want such behaviour? */ @Nonnull @Override public NodeProvisioner.StrategyDecision apply(@Nonnull NodeProvisioner.StrategyState strategyState) { LOG.debug("Applying provisioning."); final Label label = strategyState.getLabel(); LoadStatisticsSnapshot snapshot = strategyState.getSnapshot(); List<DockerCloud> provisionClouds; DockerCloudOrder cloudOrder = dockerGlobalConfig().getCloudOrder(); if (isNull(cloudOrder)) { provisionClouds = DEFAULT.getDockerClouds(label); } else { provisionClouds = cloudOrder.getDockerClouds(label); } for (DockerCloud dockerCloud : provisionClouds) { for (DockerSlaveTemplate template : dockerCloud.getTemplates(label)) { if (notAllowedStrategy(template)) { continue; } int availableCapacity = snapshot.getAvailableExecutors() + snapshot.getConnectingExecutors() + strategyState.getAdditionalPlannedCapacity() + strategyState.getPlannedCapacitySnapshot(); int currentDemand = snapshot.getQueueLength(); LOG.debug("Available capacity={}, currentDemand={}", availableCapacity, currentDemand); if (availableCapacity < currentDemand) { // may happen that would be provisioned with other template Collection<PlannedNode> plannedNodes = dockerCloud.provision(label, currentDemand - availableCapacity); LOG.debug("Planned {} new nodes", plannedNodes.size()); strategyState.recordPendingLaunches(plannedNodes); // FIXME calculate executors number? availableCapacity += plannedNodes.size(); LOG.debug("After '{}' provisioning, available capacity={}, currentDemand={}", dockerCloud, availableCapacity, currentDemand); } if (availableCapacity >= currentDemand) { LOG.debug("Provisioning completed"); return NodeProvisioner.StrategyDecision.PROVISIONING_COMPLETED; } else { LOG.debug("Provisioning not complete, trying next template"); } } LOG.debug("Provisioning not complete, trying next YAD Cloud"); } LOG.debug("Provisioning not complete, consulting remaining strategies"); return NodeProvisioner.StrategyDecision.CONSULT_REMAINING_STRATEGIES; }