本文整理汇总了Java中hudson.model.Label类的典型用法代码示例。如果您正苦于以下问题:Java Label类的具体用法?Java Label怎么用?Java Label使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Label类属于hudson.model包,在下文中一共展示了Label类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: NomadSlaveTemplate
import hudson.model.Label; //导入依赖的package包/类
@DataBoundConstructor
public NomadSlaveTemplate(
String cpu,
String memory,
String disk,
String labels,
String remoteFs,
String idleTerminationInMinutes,
String region,
String priority,
String image
) {
this.cpu = Integer.parseInt(cpu);
this.memory = Integer.parseInt(memory);
this.disk = Integer.parseInt(disk);
this.priority = Integer.parseInt(priority);
this.idleTerminationInMinutes = Integer.parseInt(idleTerminationInMinutes);
this.remoteFs = remoteFs;
this.labels = Util.fixNull(labels);
this.labelSet = Label.parse(labels);
this.region = region;
this.image = image;
readResolve();
}
示例2: provision
import hudson.model.Label; //导入依赖的package包/类
@Override
public Collection<NodeProvisioner.PlannedNode> provision(Label label, int excessWorkload) {
List<NodeProvisioner.PlannedNode> nodes = new ArrayList<>();
final NomadSlaveTemplate template = getTemplate(label);
try {
while (excessWorkload > 0) {
LOGGER.log(Level.INFO, "Excess workload, provisioning new Jenkins slave on Nomad cluster");
final String slaveName = template.createSlaveName();
nodes.add(new NodeProvisioner.PlannedNode(
slaveName,
NomadComputer.threadPoolForRemoting.submit(
new ProvisioningCallback(slaveName, template, this)
), template.getNumExecutors()));
excessWorkload -= template.getNumExecutors();
}
return nodes;
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Unable to schedule new Jenkins slave on Nomad cluster, message: " + e.getMessage());
}
return Collections.emptyList();
}
示例3: onStarted
import hudson.model.Label; //导入依赖的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();
}
}
示例4: provision
import hudson.model.Label; //导入依赖的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();
}
}
示例5: getDockerClouds
import hudson.model.Label; //导入依赖的package包/类
@Nonnull
public List<DockerCloud> getDockerClouds(Label label) {
List<DockerCloud> provisionClouds;
//create a random list of docker clouds and prioritize idle clouds
List<DockerCloud> availableClouds = getAvailableDockerClouds(label);
if (availableClouds.size() > 0) {
//select available clouds based on label which have potential capacity
LOG.debug("Picking from available clouds.");
provisionClouds = availableClouds;
} else {
//if there's no available clouds then fall back to original behavior
LOG.debug("Falling back to getting all clouds regardless of availability.");
provisionClouds = getAllDockerClouds();
}
//randomize the order of the DockerCloud list
Collections.shuffle(provisionClouds);
//sort by least loaded DockerCloud (i.e. fewest provisioned slaves)
provisionClouds.sort(new DockerCloudLoadComparator());
LOG.debug("Least loaded randomized DockerCloud: " +
((provisionClouds.size() > 0) ? provisionClouds.get(0).name : "none available"));
return provisionClouds;
}
示例6: 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;
}
示例7: readResolve
import hudson.model.Label; //导入依赖的package包/类
/**
* Initializes data structure that we don't persist.
*/
@SuppressWarnings("unused")
public Object readResolve() {
if (configVersion < 1) {
if (isNull(nodeProperties)) nodeProperties = new ArrayList<>();
nodeProperties.add(new DockerNodeProperty("DOCKER_CONTAINER_ID", "JENKINS_CLOUD_ID", "DOCKER_HOST"));
configVersion = 1;
}
// real @Nonnull
if (mode == null) {
mode = Node.Mode.NORMAL;
}
if (retentionStrategy == null) {
retentionStrategy = new DockerOnceRetentionStrategy(10);
}
try {
labelSet = Label.parse(getLabelString()); // fails sometimes under debugger
} catch (Throwable t) {
LOG.error("Can't parse labels: {}", t);
}
return this;
}
示例8: readResolve
import hudson.model.Label; //导入依赖的package包/类
/**
* Initializes data structure that we don't persist.
*/
protected Object readResolve() {
labelSet = Label.parse(labels);
securityGroupSet = parseSecurityGroups();
/**
* In releases of this plugin prior to 1.18, template-specific instance caps could be configured
* but were not enforced. As a result, it was possible to have the instance cap for a template
* be configured to 0 (zero) with no ill effects. Starting with version 1.18, template-specific
* instance caps are enforced, so if a configuration has a cap of zero for a template, no instances
* will be launched from that template. Since there is no practical value of intentionally setting
* the cap to zero, this block will override such a setting to a value that means 'no cap'.
*/
if (instanceCap == 0) {
instanceCap = Integer.MAX_VALUE;
}
if (amiType == null) {
amiType = new UnixData(rootCommandPrefix, sshPort);
}
return this;
}
示例9: RavelloSlaveBlueprint
import hudson.model.Label; //导入依赖的package包/类
@DataBoundConstructor
public RavelloSlaveBlueprint(String blueprintName, int blueprintId, String slaveName, String remoteFS, String nodeDescription, RetentionStrategy retentionStrategy, int port, String credentialsId,
String jvmOptions, String javaPath, String prefixStartSlaveCmd, String suffixStartSlaveCmd,
Integer launchTimeoutSeconds, Integer maxNumRetries, Integer retryWaitTime, String labelString){
super(blueprintName, blueprintId);
this.slaveName = slaveName;
this.remoteFS = remoteFS;
this.nodeDescription = nodeDescription;
this.retentionStrategy = retentionStrategy;
this.port = port;
this.credentialsId = credentialsId;
this.jvmOptions = jvmOptions;
this.javaPath = javaPath;
this.prefixStartSlaveCmd = prefixStartSlaveCmd;
this.suffixStartSlaveCmd = suffixStartSlaveCmd;
this.launchTimeoutSeconds = launchTimeoutSeconds;
this.maxNumRetries = maxNumRetries;
this.retryWaitTime = retryWaitTime;
this.labelString = labelString;
labelSet = Label.parse(labelString);
}
示例10: 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;
}
示例11: 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;
}
示例12: DockerTemplate
import hudson.model.Label; //导入依赖的package包/类
@DataBoundConstructor
public DockerTemplate(@Nonnull DockerTemplateBase dockerTemplateBase,
DockerComputerConnector connector,
String labelString,
String remoteFs,
String instanceCapStr
) {
this.dockerTemplateBase = dockerTemplateBase;
this.connector = connector;
this.labelString = Util.fixNull(labelString);
this.remoteFs = Strings.isNullOrEmpty(remoteFs) ? "/home/jenkins" : remoteFs;
if (instanceCapStr.equals("")) {
this.instanceCap = Integer.MAX_VALUE;
} else {
this.instanceCap = Integer.parseInt(instanceCapStr);
}
labelSet = Label.parse(labelString);
}
示例13: should_connect_agent
import hudson.model.Label; //导入依赖的package包/类
protected void should_connect_agent(DockerTemplate template) throws IOException, ExecutionException, InterruptedException {
// FIXME on CI windows nodes don't have Docker4Windows
Assume.assumeFalse(SystemUtils.IS_OS_WINDOWS);
String dockerHost = SystemUtils.IS_OS_WINDOWS ? "tcp://localhost:2375" : "unix:///var/run/docker.sock";
DockerCloud cloud = new DockerCloud("docker", new DockerAPI(new DockerServerEndpoint(dockerHost, null)),
Collections.singletonList(template));
j.jenkins.clouds.replaceBy(Collections.singleton(cloud));
final FreeStyleProject project = j.createFreeStyleProject("test-docker-ssh");
project.setAssignedLabel(Label.get("docker-agent"));
project.getBuildersList().add(new Shell("whoami"));
final FreeStyleBuild build = project.scheduleBuild2(0).get();
Assert.assertTrue(build.getResult() == Result.SUCCESS);
Assert.assertTrue(build.getLog().contains("jenkins"));
}
示例14: setLabel
import hudson.model.Label; //导入依赖的package包/类
/**
* Set the default Slave Info Label if no Label is assigned to the {@link Item}
* @param item
*/
private void setLabel(final Item item) {
if (item instanceof AbstractProject) {
AbstractProject<?, ?> job = (AbstractProject<?, ?>) item;
LOGGER.fine("MesosListener.setLabel(), setting label");
Label label = job.getAssignedLabel();
try {
if (label == null) { // No label assigned, override now
LOGGER.log(Level.FINE, "No label assigned to job - " + job.getDisplayName() + ". Assigning a label now...");
label = getLabel();
if (label != null) {
LOGGER.log(Level.INFO, "Assigned \"" + label.getName() + "\" to job \"" + job.getDisplayName() + "\"");
job.setAssignedLabel(label);
}
}
} catch (Exception e) {
LOGGER.log(Level.WARNING, "Failed to assign label \"" + label + "\" to " + job.getDisplayName(), e);
}
}
}
示例15: getLabel
import hudson.model.Label; //导入依赖的package包/类
/**
* Get the default Slave Info Label as Hudson {@link hudson.model.Label}
* @return
*/
private Label getLabel() {
Label label = null;
// get mesos cloud
MesosCloud cloud = MesosCloud.get();
if(cloud != null) {
// get all label associate with cloud
List<MesosSlaveInfo> list = cloud.getSlaveInfos();
if(list != null && list.size() > 0) {
for (MesosSlaveInfo slaveInfo: list) {
if (slaveInfo.isDefaultSlave()) {
label = Hudson.getInstance().getLabel(slaveInfo.getLabelString());
break;
}
}
}
}
return label;
}