@CheckForNull @Override public Slave getNode() { Node node = super.getNode(); if (node == null || node instanceof Slave) { return (Slave)node; } else { logger.log(Level.WARNING, "found an unexpected kind of node {0} from {1} with nodeName={2}", new Object[] {node, this, nodeName}); return null; } }
/** * Implementation can choose to provide different ACL for different computers. * This can be used as a basis for more fine-grained access control. * * <p> * The default implementation delegates to {@link #getACL(Node)} * * @since 1.220 */ public @Nonnull ACL getACL(@Nonnull Computer computer) { return getACL(computer.getNode()); }
@Override protected Callable<ClockDifference,IOException> createCallable(Computer c) { Node n = c.getNode(); if(n==null) return null; return n.getClockDifferenceCallable(); }
private void _getBuildableItems(Computer c, List<BuildableItem> col, List<BuildableItem> result) { Node node = c.getNode(); if (node == null) // Deleted computers cannot take build items... return; for (BuildableItem p : col) { if (node.canTake(p) == null) result.add(p); } }
@CheckForNull public Node getNode() { return executor.getOwner().getNode(); }
private boolean isRelevant(Collection<Label> labels, Computer computer) { Node node = computer.getNode(); if (node == null) return false; if (labels.contains(null) && node.getMode() == Node.Mode.NORMAL) return true; for (Label l : labels) if (l != null && l.contains(node)) return true; return false; }
@Override public void run() { Node n = c.getNode(); if (n!=null && n.isHoldOffLaunchUntilSave()) return; if (!nextCheck.containsKey(c) || startRun > nextCheck.get(c)) { // at the moment I don't trust strategies to wait more than 60 minutes // strategies need to wait at least one minute final long waitInMins = Math.max(1, Math.min(60, c.getRetentionStrategy().check(c))); nextCheck.put(c, startRun + waitInMins*1000*60 /*MINS->MILLIS*/); } } });
@Exported public Set<LabelAtom> getAssignedLabels() { Node node = getNode(); return (node != null) ? node.getAssignedLabels() : Collections.EMPTY_SET; }
/** * Returns projects that are tied on this node. */ public List<AbstractProject> getTiedJobs() { Node node = getNode(); return (node != null) ? node.getSelfLabel().getTiedJobs() : Collections.EMPTY_LIST; }
@Override public void onOnline(Computer c, TaskListener listener) { Node node = c.getNode(); // At startup, we need to restore any previously in-effect temp offline cause. // We wait until the computer is started rather than getting the data to it sooner // so that the normal computer start up processing works as expected. if (node!= null && node.temporaryOfflineCause != null && node.temporaryOfflineCause != c.getOfflineCause()) { c.setTemporarilyOffline(true, node.temporaryOfflineCause); } } }
private ExecutorChunk(List<ExecutorSlot> base, int index) { super(base); this.index = index; assert !base.isEmpty(); computer = base.get(0).getExecutor().getOwner(); node = computer.getNode(); nodeAcl = node.getACL(); }
/** * Returns the {@link Node} description for this computer */ @Restricted(DoNotUse.class) @Exported public @Nonnull String getDescription() { Node node = getNode(); return (node != null) ? node.getNodeDescription() : null; }
@Override protected Callable<DiskSpace, IOException> createCallable(Computer c) { Node node = c.getNode(); if (node == null) return null; FilePath p = node.getRootPath(); if(p==null) return null; return p.asCallableWith(new GetUsableSpace()); } };
@Override protected Callable<DiskSpace,IOException> createCallable(Computer c) { Node node = c.getNode(); if (node == null) return null; FilePath p = node.getRootPath(); if(p==null) return null; return p.asCallableWith(new GetTempSpace()); } }
/** * Returns {@code true} if the computer is accepting tasks. Needed to allow agents programmatic suspension of task * scheduling that does not overlap with being offline. * * @return {@code true} if the computer is accepting tasks * @see hudson.slaves.RetentionStrategy#isAcceptingTasks(Computer) * @see hudson.model.Node#isAcceptingTasks() */ @OverridingMethodsMustInvokeSuper public boolean isAcceptingTasks() { final Node node = getNode(); return getRetentionStrategy().isAcceptingTasks(this) && (node == null || node.isAcceptingTasks()); }
public RunList getBuilds() { return RunList.fromJobs((Iterable)Jenkins.getInstance().allItems(Job.class)).node(getNode()); }
@Override public int computeTotalExecutors() { int r=0; for (Computer c : Jenkins.getInstance().getComputers()) { Node node = c.getNode(); if (node != null && node.getMode() == Mode.NORMAL && c.isOnline()) { r += c.countExecutors(); } } return r; }
/** * Updates Job by its XML definition. * * @since 1.526 */ public void updateByXml(final InputStream source) throws IOException, ServletException { checkPermission(CONFIGURE); Node result = (Node)Jenkins.XSTREAM2.fromXML(source); Jenkins.getInstance().getNodesObject().replaceNode(this.getNode(), result); }
@Override public int computeIdleExecutors() { int r=0; for (Computer c : Jenkins.getInstance().getComputers()) { Node node = c.getNode(); if (node != null && node.getMode() == Mode.NORMAL && (c.isOnline() || c.isConnecting()) && c.isAcceptingTasks()) { r += c.countIdle(); } } return r; }