当前位置: 首页>>代码示例>>Java>>正文


Java Label.matches方法代码示例

本文整理汇总了Java中hudson.model.Label.matches方法的典型用法代码示例。如果您正苦于以下问题:Java Label.matches方法的具体用法?Java Label.matches怎么用?Java Label.matches使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在hudson.model.Label的用法示例。


在下文中一共展示了Label.matches方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTemplates

import hudson.model.Label; //导入方法依赖的package包/类
/**
 * Multiple templates may have the same label.
 *
 * @return Templates matched to requested label assuming slave Mode
 */
@Nonnull
public List<DockerSlaveTemplate> getTemplates(Label label) {
    List<DockerSlaveTemplate> dockerSlaveTemplates = new ArrayList<>();

    for (DockerSlaveTemplate t : templates) {
        if (isNull(label) && t.getMode() == Node.Mode.NORMAL) {
            dockerSlaveTemplates.add(t);
        }

        if (nonNull(label) && label.matches(t.getLabelSet())) {
            dockerSlaveTemplates.add(t);
        }
    }

    return dockerSlaveTemplates;
}
 
开发者ID:KostyaSha,项目名称:yet-another-docker-plugin,代码行数:22,代码来源:AbstractCloud.java

示例2: getTemplate

import hudson.model.Label; //导入方法依赖的package包/类
public SlaveTemplate getTemplate(Label label) {

        if (label == null && templates.size() > 0) {
            return templates.get(0);
        }

        if ("master".equals(label.getName())) {
            if (templates.size() > 0) {
                return templates.get(0);
            } else {
                return null;
            }
        }

        for (SlaveTemplate t : templates) {
            if(label == null || label.matches(t.getLabelSet())) {
                return t;
            }
        }
        return null;
    }
 
开发者ID:pulse00,项目名称:digitalocean-plugin,代码行数:22,代码来源:Cloud.java

示例3: getTemplates

import hudson.model.Label; //导入方法依赖的package包/类
/**
 * Multiple amis can have the same label.
 *
 * @return Templates matched to requested label assuming slave Mode
 */
public List<DockerTemplate> getTemplates(Label label) {
    ArrayList<DockerTemplate> dockerTemplates = new ArrayList<>();

    for (DockerTemplate t : templates) {
        if (label == null && t.getMode() == Node.Mode.NORMAL) {
            dockerTemplates.add(t);
        }

        if (label != null && label.matches(t.getLabelSet())) {
            dockerTemplates.add(t);
        }
    }

    // add temporary templates matched to requested label
    for (DockerTemplate template : getJobTemplates().values()) {
        if (label != null && label.matches(template.getLabelSet())) {
                dockerTemplates.add(template);
        }
    }

    return dockerTemplates;
}
 
开发者ID:jenkinsci,项目名称:docker-plugin,代码行数:28,代码来源:DockerCloud.java

示例4: getTemplate

import hudson.model.Label; //导入方法依赖的package包/类
public NomadSlaveTemplate getTemplate(Label label) {
    for (NomadSlaveTemplate t : templates) {
        if (label == null && !t.getLabelSet().isEmpty()) {
            continue;
        }
        if ((label == null && t.getLabelSet().isEmpty()) || (label != null && label.matches(t.getLabelSet()))) {
            return t;
        }
    }
    return null;
}
 
开发者ID:iverberk,项目名称:jenkins-nomad,代码行数:12,代码来源:NomadCloud.java

示例5: provision

import hudson.model.Label; //导入方法依赖的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

示例6: canProvision

import hudson.model.Label; //导入方法依赖的package包/类
@Override
public boolean canProvision(Label label)
{
	if (label != null)
	{
		for (ParallelsDesktopVM vm : vms)
		{
			if (label.matches(Label.parse(vm.getLabels())))
				return true;
		}
	}
	return false;
}
 
开发者ID:Parallels,项目名称:jenkins-parallels,代码行数:14,代码来源:ParallelsDesktopCloud.java

示例7: getTemplate

import hudson.model.Label; //导入方法依赖的package包/类
private ECSTaskTemplate getTemplate(Label label) {
    for (ECSTaskTemplate t : templates) {
        if (label == null || label.matches(t.getLabelSet())) {
            return t;
        }
    }
    return null;
}
 
开发者ID:cloudbees,项目名称:amazon-ecs-plugin,代码行数:9,代码来源:ECSCloud.java

示例8: getTemplate

import hudson.model.Label; //导入方法依赖的package包/类
/**
 * Gets {@link SlaveTemplate} that has the matching {@link Label}.
 */
public SlaveTemplate getTemplate(Label label) {
    for (SlaveTemplate t : templates) {
        if (t.getMode() == Node.Mode.NORMAL) {
            if (label == null || label.matches(t.getLabelSet())) {
                return t;
            }
        } else if (t.getMode() == Node.Mode.EXCLUSIVE) {
            if (label != null && label.matches(t.getLabelSet())) {
                return t;
            }
        }
    }
    return null;
}
 
开发者ID:hudson3-plugins,项目名称:ec2-plugin,代码行数:18,代码来源:EC2Cloud.java

示例9: getTemplateByLabel

import hudson.model.Label; //导入方法依赖的package包/类
/**
 * Gets the {@link PodTemplate} by {@link Label}.
 * @param label         The label.
 * @param templates     The list of all templates.
 * @return              The first pod template from the collection that has a matching label.
 */
public static PodTemplate getTemplateByLabel(@CheckForNull Label label, Collection<PodTemplate> templates) {
    for (PodTemplate t : templates) {
        if ((label == null && t.getNodeUsageMode() == Node.Mode.NORMAL) || (label != null && label.matches(t.getLabelSet()))) {
            return t;
        }
    }
    return null;
}
 
开发者ID:carlossg,项目名称:jenkins-kubernetes-plugin,代码行数:15,代码来源:PodTemplateUtils.java

示例10: getMatchingTemplates

import hudson.model.Label; //导入方法依赖的package包/类
/**
 * Gets all PodTemplates that have the matching {@link Label}.
 * @param label label to look for in templates
 * @return list of matching templates
 */
public ArrayList<PodTemplate> getMatchingTemplates(@CheckForNull Label label) {
    ArrayList<PodTemplate> podList = new ArrayList<PodTemplate>();
    List<PodTemplate> podTemplates = getAllTemplates();
    for (PodTemplate t : podTemplates) {
        if ((label == null && t.getNodeUsageMode() == Node.Mode.NORMAL) || (label != null && label.matches(t.getLabelSet()))) {
            podList.add(t);
        }
    }
    return podList;
}
 
开发者ID:carlossg,项目名称:jenkins-kubernetes-plugin,代码行数:16,代码来源:KubernetesCloud.java

示例11: getSlaveBlueprintByLabel

import hudson.model.Label; //导入方法依赖的package包/类
private RavelloSlaveBlueprint getSlaveBlueprintByLabel(final Label label){
    for(RavelloBlueprint b : getBlueprintRepository()){
        if(b instanceof RavelloSlaveBlueprint){
            if(label.matches(((RavelloSlaveBlueprint) b).getLabelSet())){
                return (RavelloSlaveBlueprint) b;
            }
        }
    }
    return null;
}
 
开发者ID:ravello,项目名称:ravello-jenkins-plugin,代码行数:11,代码来源:RavelloCloud.java

示例12: dockerImageMatchesLabel

import hudson.model.Label; //导入方法依赖的package包/类
private boolean dockerImageMatchesLabel(DockerImage image, Label label) {
	return label == null ? image.getMode() == Node.Mode.NORMAL : label.matches(Label.parse(image.getLabelString()));
}
 
开发者ID:kmbulebu,项目名称:docker-ephemeral-cloud,代码行数:4,代码来源:DockerCloud.java

示例13: provision

import hudson.model.Label; //导入方法依赖的package包/类
@Override
public Collection<PlannedNode> provision(Label label, int excessWorkload) {
    try {

        List<Node> nodes = Hudson.getInstance().getNodes();
        for (int i = 0, len = nodes.size(); i < len; i++) {
            if (!(nodes.get(i) instanceof EC2SpotSlave)) {
                continue;
            }
            EC2SpotSlave n = (EC2SpotSlave) nodes.get(i);
            //If the slave is online then it is already counted by Jenkins
            // We only want to count potential additional Spot instance slaves
            if (n.getComputer().isOffline() && label.matches(n.getAssignedLabels())) {
                DescribeSpotInstanceRequestsRequest dsir
                        = new DescribeSpotInstanceRequestsRequest().withSpotInstanceRequestIds(n.getSpotInstanceRequestId());

                for (SpotInstanceRequest sir : connect().describeSpotInstanceRequests(dsir).getSpotInstanceRequests()) {
                    // Count Spot requests that are open and still have a chance to be active
                    // A request can be active and not yet registered as a slave. We check above
                    // to ensure only unregistered slaves get counted
                    if (sir.getState().equals("open") || sir.getState().equals("active")) {
                        excessWorkload -= n.getNumExecutors();
                    }
                }
            }
        }
        LOGGER.log(Level.INFO, "Excess workload after pending Spot instances: " + excessWorkload);

        List<PlannedNode> r = new ArrayList<PlannedNode>();

        final SlaveTemplate t = getTemplate(label);
        int amiCap = t.getInstanceCap();

        while (excessWorkload > 0) {

            if (!addProvisionedSlave(t.ami, amiCap)) {
                break;
            }

            r.add(new PlannedNode(t.getDisplayName(),
                    Computer.threadPoolForRemoting.submit(new Callable<Node>() {
                        public Node call() throws Exception {
                            // TODO: record the output somewhere
                            try {
                                EC2AbstractSlave s = t.provision(new StreamTaskListener(System.out));
                                Hudson.getInstance().addNode(s);
                                // EC2 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;
                            } finally {
                                decrementAmiSlaveProvision(t.ami);
                            }
                        }
                    }), t.getNumExecutors()));

            excessWorkload -= t.getNumExecutors();

        }
        return r;
    } catch (AmazonClientException e) {
        LOGGER.log(Level.WARNING, "Failed to count the # of live instances on EC2", e);
        return Collections.emptyList();
    }
}
 
开发者ID:hudson3-plugins,项目名称:ec2-plugin,代码行数:73,代码来源:EC2Cloud.java

示例14: validateJob

import hudson.model.Label; //导入方法依赖的package包/类
private Optional<JobValidationResult> validateJob(Label label) {
    Set<LabelAtom> allLabels = Sets.union(_requiredLabels, _labels);

    if (label == null) {
        if (_requiredLabels.size() > 0) {
            LOG.log(FINE, "Condition does not include required labels: condition={0} cloud={1} required={2}", new Object[]{label, getDisplayName(), _requiredLabels});
            return Optional.absent();
        } else {
            LOG.log(FINE, "Condition matched cloud labels: condition={0} cloud={1} labels={2}", new Object[]{label, getDisplayName(), allLabels});
            return Optional.of(new JobValidationResult(allLabels, null, ImmutableMap.<String, String>of()));
        }
    }

    // Check that the condition includes all the required atoms
    if (!label.listAtoms().containsAll(_requiredLabels)) {
        LOG.log(FINE, "Condition does not include required labels: condition={0} cloud={1} required={2}", new Object[]{label, getDisplayName(), _requiredLabels});
        return Optional.absent();
    }

    // Check if the condition matches the cloud's labels
    if (label.matches(allLabels)) {
        LOG.log(FINE, "Condition matched cloud labels: condition={0} cloud={1} labels={2}", new Object[]{label, getDisplayName(), allLabels});
        return Optional.of(new JobValidationResult(allLabels, null, ImmutableMap.<String, String>of()));
    }

    // Check if the condition matches the cloud's labels combined with a specific image
    DockerJobGlobalConfiguration config = DockerJobGlobalConfiguration.get();

    for (LabeledDockerImage image : config.getLabeledImages()) {
        Set<LabelAtom> imageLabels = Sets.union(image.getLabels(), allLabels);

        if (label.matches(imageLabels)) {
            LOG.log(FINE, "Condition matched cloud+image labels: condition={0} cloud={1} image={2} labels={3}", new Object[]{label, getDisplayName(), image.imageName, imageLabels});
            return Optional.of(new JobValidationResult(imageLabels, image.imageName, image.getEnvironmentVars()));
        } else {
            LOG.log(FINE, "Condition does not match cloud+image labels: condition={0} cloud={1} image={2} labels={3}", new Object[]{label, getDisplayName(), image.imageName, imageLabels});
        }
    }

    LOG.log(FINE, "Condition does not match cloud: condition={0} cloud={1} labels={2} images={3}", new Object[]{label, getDisplayName(), allLabels, config.getLabeledImages().size()});
    return Optional.absent();
}
 
开发者ID:dump247,项目名称:jenkins-docker-build-plugin,代码行数:43,代码来源:DockerJobCloud.java


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