• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java NodeProvisioner类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中hudson.slaves.NodeProvisioner的典型用法代码示例。如果您正苦于以下问题:Java NodeProvisioner类的具体用法?Java NodeProvisioner怎么用?Java NodeProvisioner使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



NodeProvisioner类属于hudson.slaves包,在下文中一共展示了NodeProvisioner类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
    }
}
 
开发者ID:jenkinsci,项目名称:cloud-stats-plugin,代码行数:22,代码来源:CloudStatistics.java


示例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();
    }
}
 
开发者ID:cloudbees,项目名称:amazon-ecs-plugin,代码行数:19,代码来源:ECSCloud.java


示例3: setEnabled

import hudson.slaves.NodeProvisioner; //导入依赖的package包/类
/**
 * For groovy.
 */
public void setEnabled(boolean enabled) {
    final ExtensionList<NodeProvisioner.Strategy> strategies = lookup(NodeProvisioner.Strategy.class);
    DockerProvisioningStrategy strategy = strategies.get(DockerProvisioningStrategy.class);

    if (isNull(strategy)) {
        LOG.debug("YAD strategy was null, creating new.");
        strategy = new DockerProvisioningStrategy();
    } else {
        LOG.debug("Removing YAD strategy.");
        strategies.remove(strategy);
    }

    LOG.debug("Inserting YAD strategy at position 0");
    strategies.add(0, strategy);
}
 
开发者ID:KostyaSha,项目名称:yet-another-docker-plugin,代码行数:19,代码来源:DockerProvisioningStrategy.java


示例4: apply

import hudson.slaves.NodeProvisioner; //导入依赖的package包/类
@Nonnull
@Override
public StrategyDecision apply(@Nonnull NodeProvisioner.StrategyState state) {
    if (Jenkins.getInstance().isQuietingDown()) {
        return CONSULT_REMAINING_STRATEGIES;
    }


    for (Cloud cloud : Jenkins.getInstance().clouds) {
        if (cloud instanceof DockerCloud) {
            final StrategyDecision decision = applyFoCloud(state, (DockerCloud) cloud);
            if (decision == PROVISIONING_COMPLETED) return decision;
        }
    }
    return CONSULT_REMAINING_STRATEGIES;
}
 
开发者ID:jenkinsci,项目名称:docker-plugin,代码行数:17,代码来源:FastNodeProvisionerStrategy.java


示例5: 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);
}
 
开发者ID:iverberk,项目名称:jenkins-nomad,代码行数:8,代码来源:NomadCloudTest.java


示例6: 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;
}
 
开发者ID:awslabs,项目名称:ec2-spot-jenkins-plugin,代码行数:39,代码来源:EC2FleetCloud.java


示例7: 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);
    }
}
 
开发者ID:jenkinsci,项目名称:cloud-stats-plugin,代码行数:8,代码来源:CloudStatistics.java


示例8: 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);
    }
}
 
开发者ID:jenkinsci,项目名称:cloud-stats-plugin,代码行数:8,代码来源:CloudStatistics.java


示例9: 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();
}
 
开发者ID:jenkinsci,项目名称:cloud-stats-plugin,代码行数:9,代码来源:CloudStatistics.java


示例10: 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)
    ));
}
 
开发者ID:jenkinsci,项目名称:cloud-stats-plugin,代码行数:13,代码来源:TestCloud.java


示例11: before

import hudson.slaves.NodeProvisioner; //导入依赖的package包/类
@Before
public void before() throws Exception {
    // Pretend we are out of slaves
    j.jenkins.setNumExecutors(0);
    j.jenkins.setNodes(Collections.<Node>emptyList());

    // Do not provision when not expected
    ExtensionList<NodeProvisioner.NodeProvisionerInvoker> extensionList = j.jenkins.getExtensionList(NodeProvisioner.NodeProvisionerInvoker.class);
    provisionerInvoker = extensionList.get(0);
}
 
开发者ID:jenkinsci,项目名称:cloud-stats-plugin,代码行数:11,代码来源:CloudStatisticsTest.java


示例12: 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;
}
 
开发者ID:Parallels,项目名称:jenkins-parallels,代码行数:32,代码来源:ParallelsDesktopCloud.java


示例13: 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;
        }
    }
 
开发者ID:jenkinsci,项目名称:docker-plugin,代码行数:38,代码来源:FastNodeProvisionerStrategy.java


示例14: onEnterBuildable

import hudson.slaves.NodeProvisioner; //导入依赖的package包/类
@Override
public void onEnterBuildable(Queue.BuildableItem item) {
    final Jenkins jenkins = Jenkins.getInstance();
    final Label label = item.getAssignedLabel();
    for (Cloud cloud : Jenkins.getInstance().clouds) {
        if (cloud instanceof DockerCloud && cloud.canProvision(label)) {
            final NodeProvisioner provisioner = (label == null
                    ? jenkins.unlabeledNodeProvisioner
                    : label.nodeProvisioner);
            provisioner.suggestReviewNow();
        }
    }
}
 
开发者ID:jenkinsci,项目名称:docker-plugin,代码行数:14,代码来源:FastNodeProvisionerStrategy.java


示例15: 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);
    }
}
 
开发者ID:awslabs,项目名称:ec2-spot-jenkins-plugin,代码行数:48,代码来源:EC2FleetCloud.java


示例16: apply

import hudson.slaves.NodeProvisioner; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:KostyaSha,项目名称:yet-another-docker-plugin,代码行数:62,代码来源:DockerProvisioningStrategy.java


示例17: 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();
}
 
开发者ID:dump247,项目名称:jenkins-docker-build-plugin,代码行数:6,代码来源:DockerJobCloud.java


示例18: 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;
    }
 
开发者ID:ravello,项目名称:ravello-jenkins-plugin,代码行数:45,代码来源:RavelloCloud.java


示例19: 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();
    }
}
 
开发者ID:pulse00,项目名称:digitalocean-plugin,代码行数:52,代码来源:Cloud.java


示例20: provision

import hudson.slaves.NodeProvisioner; //导入依赖的package包/类
public Collection<NodeProvisioner.PlannedNode> provision(Label label, int excessWorkload) {
    return Collections.emptySet();
}
 
开发者ID:justnom,项目名称:proxmox-plugin,代码行数:4,代码来源:Datacenter.java



注:本文中的hudson.slaves.NodeProvisioner类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Node类代码示例发布时间:2022-05-21
下一篇:
Java DoubleMetaphone类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap