hudson.model.Node.getAssignedLabels()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(223)

本文整理了Java中hudson.model.Node.getAssignedLabels()方法的一些代码示例,展示了Node.getAssignedLabels()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.getAssignedLabels()方法的具体详情如下:
包路径:hudson.model.Node
类名称:Node
方法名:getAssignedLabels

Node.getAssignedLabels介绍

[英]Returns the possibly empty set of labels that are assigned to this node, including the automatic #getSelfLabel(), manually assigned labels and dynamically assigned labels via the LabelFinder extension point. This method has a side effect of updating the hudson-wide set of labels and should be called after events that will change that - e.g. a slave connecting.
[中]返回分配给此节点的可能为空的标签集,包括自动#getSelfLabel()、手动分配的标签和通过LabelFinder扩展点动态分配的标签。此方法的副作用是更新hudson范围内的标签集,并且应在将改变该方法的事件后调用,例如,从机连接。

代码示例

代码示例来源:origin: jenkinsci/jenkins

  1. /**
  2. * Return the possibly empty tag cloud for the labels of this node.
  3. */
  4. public TagCloud<LabelAtom> getLabelCloud() {
  5. return new TagCloud<LabelAtom>(getAssignedLabels(),new WeightFunction<LabelAtom>() {
  6. public float weight(LabelAtom item) {
  7. return item.getTiedJobCount();
  8. }
  9. });
  10. }
  11. /**

代码示例来源:origin: jenkinsci/jenkins

  1. public final boolean matches(Node n) {
  2. return matches(n.getAssignedLabels());
  3. }

代码示例来源:origin: jenkinsci/jenkins

  1. @Exported
  2. public Set<LabelAtom> getAssignedLabels() {
  3. Node node = getNode();
  4. return (node != null) ? node.getAssignedLabels() : Collections.EMPTY_SET;
  5. }

代码示例来源:origin: jenkinsci/jenkins

  1. slave.getAssignedLabels();
  2. getAssignedLabels();

代码示例来源:origin: jenkinsci/jenkins

  1. @Override
  2. public void buildEnvironmentFor(Job j, EnvVars env, TaskListener listener) throws IOException, InterruptedException {
  3. Jenkins jenkins = Jenkins.getInstance();
  4. String rootUrl = jenkins.getRootUrl();
  5. if(rootUrl!=null) {
  6. env.put("JENKINS_URL", rootUrl);
  7. env.put("HUDSON_URL", rootUrl); // Legacy compatibility
  8. env.put("JOB_URL", rootUrl+j.getUrl());
  9. }
  10. String root = jenkins.getRootDir().getPath();
  11. env.put("JENKINS_HOME", root);
  12. env.put("HUDSON_HOME", root); // legacy compatibility
  13. Thread t = Thread.currentThread();
  14. if (t instanceof Executor) {
  15. Executor e = (Executor) t;
  16. env.put("EXECUTOR_NUMBER", String.valueOf(e.getNumber()));
  17. if (e.getOwner() instanceof MasterComputer) {
  18. env.put("NODE_NAME", "master");
  19. } else {
  20. env.put("NODE_NAME", e.getOwner().getName());
  21. }
  22. Node n = e.getOwner().getNode();
  23. if (n != null)
  24. env.put("NODE_LABELS", Util.join(n.getAssignedLabels(), " "));
  25. }
  26. }
  27. }

代码示例来源:origin: org.jenkins-ci.plugins/python-wrapper

  1. public Set<LabelAtom> superGetAssignedLabels() {
  2. return super.getAssignedLabels();
  3. }

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

  1. /**
  2. * Return the possibly empty tag cloud for the labels of this node.
  3. */
  4. public TagCloud<LabelAtom> getLabelCloud() {
  5. return new TagCloud<LabelAtom>(getAssignedLabels(),new WeightFunction<LabelAtom>() {
  6. public float weight(LabelAtom item) {
  7. return item.getTiedJobs().size();
  8. }
  9. });
  10. }
  11. /**

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

  1. /**
  2. * Return the possibly empty tag cloud for the labels of this node.
  3. */
  4. public TagCloud<LabelAtom> getLabelCloud() {
  5. return new TagCloud<LabelAtom>(getAssignedLabels(),new WeightFunction<LabelAtom>() {
  6. public float weight(LabelAtom item) {
  7. return item.getTiedJobCount();
  8. }
  9. });
  10. }
  11. /**

代码示例来源:origin: org.eclipse.hudson/hudson-core

  1. /**
  2. * Return the possibly empty tag cloud for the labels of this node.
  3. */
  4. public TagCloud<LabelAtom> getLabelCloud() {
  5. return new TagCloud<LabelAtom>(getAssignedLabels(), new WeightFunction<LabelAtom>() {
  6. public float weight(LabelAtom item) {
  7. return item.getTiedJobs().size();
  8. }
  9. });
  10. }

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

  1. /**
  2. * Return the possibly empty tag cloud for the labels of this node.
  3. */
  4. public TagCloud<LabelAtom> getLabelCloud() {
  5. return new TagCloud<LabelAtom>(getAssignedLabels(),new WeightFunction<LabelAtom>() {
  6. public float weight(LabelAtom item) {
  7. return item.getTiedJobs().size();
  8. }
  9. });
  10. }
  11. /**

代码示例来源:origin: hudson/hudson-2.x

  1. /**
  2. * Return the possibly empty tag cloud for the labels of this node.
  3. */
  4. public TagCloud<LabelAtom> getLabelCloud() {
  5. return new TagCloud<LabelAtom>(getAssignedLabels(),new WeightFunction<LabelAtom>() {
  6. public float weight(LabelAtom item) {
  7. return item.getTiedJobs().size();
  8. }
  9. });
  10. }
  11. /**

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

  1. public final boolean matches(Node n) {
  2. return matches(n.getAssignedLabels());
  3. }

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

  1. public final boolean matches(Node n) {
  2. return matches(n.getAssignedLabels());
  3. }

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

  1. public final boolean matches(Node n) {
  2. return matches(n.getAssignedLabels());
  3. }

代码示例来源:origin: org.eclipse.hudson/hudson-core

  1. public final boolean matches(Node n) {
  2. return matches(n.getAssignedLabels());
  3. }

代码示例来源:origin: hudson/hudson-2.x

  1. public final boolean matches(Node n) {
  2. return matches(n.getAssignedLabels());
  3. }

代码示例来源:origin: jenkinsci/swarm-plugin

  1. /**
  2. * Remove labels from a slave
  3. */
  4. @SuppressWarnings({ "unchecked", "rawtypes" })
  5. public void doRemoveSlaveLabels(StaplerRequest req, StaplerResponse rsp, @QueryParameter String name,
  6. @QueryParameter String secret, @QueryParameter String labels) throws IOException {
  7. if (!getSwarmSecret().equals(secret)) {
  8. rsp.setStatus(SC_FORBIDDEN);
  9. return;
  10. }
  11. Node nn = getNodeByName(name, rsp);
  12. if (nn == null) {
  13. return;
  14. }
  15. String sCurrentLabels = nn.getLabelString();
  16. List<String> lCurrentLabels = Arrays.asList(sCurrentLabels.split("\\s+"));
  17. HashSet<String> hs = new HashSet<>(lCurrentLabels);
  18. List<String> lBadLabels = Arrays.asList(labels.split("\\s+"));
  19. hs.removeAll(lBadLabels);
  20. nn.setLabelString(hashSetToString(hs));
  21. nn.getAssignedLabels();
  22. normalResponse(req, rsp, nn.getLabelString());
  23. }

代码示例来源:origin: jenkinsci/swarm-plugin

  1. /**
  2. * Adds labels to a slave.
  3. */
  4. @SuppressWarnings({ "unchecked", "rawtypes" })
  5. public void doAddSlaveLabels(StaplerRequest req, StaplerResponse rsp, @QueryParameter String name,
  6. @QueryParameter String secret, @QueryParameter String labels) throws IOException{
  7. if (!getSwarmSecret().equals(secret)) {
  8. rsp.setStatus(SC_FORBIDDEN);
  9. return;
  10. }
  11. Node nn = getNodeByName(name, rsp);
  12. if (nn == null) {
  13. return;
  14. }
  15. String sCurrentLabels = nn.getLabelString();
  16. List<String> lCurrentLabels = Arrays.asList(sCurrentLabels.split("\\s+"));
  17. HashSet<String> hs = new HashSet<>(lCurrentLabels);
  18. List<String> lNewLabels = Arrays.asList(labels.split("\\s+"));
  19. hs.addAll(lNewLabels);
  20. nn.setLabelString(hashSetToString(hs));
  21. nn.getAssignedLabels();
  22. normalResponse(req, rsp, nn.getLabelString());
  23. }

代码示例来源:origin: org.jenkins-ci.plugins/python-wrapper

  1. @Override
  2. @Exported
  3. public Set<LabelAtom> getAssignedLabels() {
  4. initPython();
  5. if (pexec.isImplemented(4)) {
  6. return (Set) pexec.execPython("get_assigned_labels");
  7. } else {
  8. return super.getAssignedLabels();
  9. }
  10. }

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

  1. @Override
  2. public void buildEnvironmentFor(Job j, EnvVars env, TaskListener listener) throws IOException, InterruptedException {
  3. Jenkins jenkins = Jenkins.getInstance();
  4. String rootUrl = jenkins.getRootUrl();
  5. if(rootUrl!=null) {
  6. env.put("JENKINS_URL", rootUrl);
  7. env.put("HUDSON_URL", rootUrl); // Legacy compatibility
  8. env.put("JOB_URL", rootUrl+j.getUrl());
  9. }
  10. String root = jenkins.getRootDir().getPath();
  11. env.put("JENKINS_HOME", root);
  12. env.put("HUDSON_HOME", root); // legacy compatibility
  13. Thread t = Thread.currentThread();
  14. if (t instanceof Executor) {
  15. Executor e = (Executor) t;
  16. env.put("EXECUTOR_NUMBER", String.valueOf(e.getNumber()));
  17. if (e.getOwner() instanceof MasterComputer) {
  18. env.put("NODE_NAME", "master");
  19. } else {
  20. env.put("NODE_NAME", e.getOwner().getName());
  21. }
  22. Node n = e.getOwner().getNode();
  23. if (n != null)
  24. env.put("NODE_LABELS", Util.join(n.getAssignedLabels(), " "));
  25. }
  26. }
  27. }

相关文章