/** * Obtains all the instances of {@link NodeMonitor}s that are alive. * @since 1.187 */ public static List<NodeMonitor> getAll() { return ComputerSet.getMonitors().toList(); }
@Override public int computeIdleExecutors() { return new ComputerSet().getIdleExecutors(); }
/** * Handles the form submission from the "/computer/new" page, which is the first form for creating a new node. * By default, it shows the configuration page for entering details, but subtypes can override this differently. * * @param name * Name of the new node. */ public void handleNewNodePage(ComputerSet computerSet, String name, StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { computerSet.checkName(name); req.setAttribute("descriptor", this); req.getView(computerSet,"_new.jelly").forward(req,rsp); }
@Override public int computeTotalExecutors() { return new ComputerSet().getTotalExecutors(); }
/** * Accepts submission from the configuration page. */ @RequirePOST public synchronized HttpResponse doConfigSubmit( StaplerRequest req) throws IOException, ServletException, FormException { BulkChange bc = new BulkChange(MONITORS_OWNER); try { Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER); monitors.rebuild(req,req.getSubmittedForm(),getNodeMonitorDescriptors()); // add in the rest of instances are ignored instances for (Descriptor<NodeMonitor> d : NodeMonitor.all()) if(monitors.get(d)==null) { NodeMonitor i = createDefaultInstance(d, true); if(i!=null) monitors.add(i); } // recompute the data for (NodeMonitor nm : monitors) { nm.triggerUpdate(); } return FormApply.success("."); } finally { bc.commit(); } }
protected void doRun() { Hudson h = Hudson.getInstance(); List<hudson.model.Queue.BuildableItem> bis = h.getQueue().getBuildableItems(); // update statistics on slaves for (Label l : h.getLabels()) { l.loadStatistics.totalExecutors.update(l.getTotalExecutors()); l.loadStatistics.busyExecutors.update(l.getBusyExecutors()); int q = 0; for (hudson.model.Queue.BuildableItem bi : bis) { if (bi.task.getAssignedLabel() == l) { q++; } } l.loadStatistics.queueLength.update(q); } // update statistics of the entire system ComputerSet cs = new ComputerSet(); h.overallLoad.totalExecutors.update(cs.getTotalExecutors()); h.overallLoad.busyExecutors.update(cs.getBusyExecutors()); int q = 0; for (hudson.model.Queue.BuildableItem bi : bis) { if (bi.task.getAssignedLabel() == null) { q++; } } h.overallLoad.queueLength.update(q); h.overallLoad.totalQueueLength.update(bis.size()); } }
public ContextMenu doChildrenContextMenu(StaplerRequest request, StaplerResponse response) throws Exception { ContextMenu m = new ContextMenu(); for (Computer c : get_all()) { m.add(c); } return m; }
/** * @deprecated * UI method. Not meant to be used programmatically. */ @Deprecated public ComputerSet getComputer() { return new ComputerSet(); }
public void doRun() { ComputerSet.initialize(); } }, 10, TimeUnit.SECONDS);
/** * Really creates a new slave. */ public synchronized void doDoCreateItem(StaplerRequest req, StaplerResponse rsp, @QueryParameter String name, @QueryParameter String type) throws IOException, ServletException, FormException { final Hudson app = Hudson.getInstance(); if (app.getTeamManager().isTeamManagementEnabled()) { app.checkPermission(Computer.CREATE); } else { app.checkPermission(Hudson.ADMINISTER); // TODO: new permission? } checkName(name); Node result = NodeDescriptor.all().find(type).newInstance(req, req.getSubmittedForm()); app.addNode(result); addToTeam(result.getNodeName(), null); // take the user back to the slave list top page rsp.sendRedirect2("."); }
protected void doRun() { Hudson h = Hudson.getInstance(); List<hudson.model.Queue.BuildableItem> bis = h.getQueue().getBuildableItems(); // update statistics on slaves for( Label l : h.getLabels() ) { l.loadStatistics.totalExecutors.update(l.getTotalExecutors()); l.loadStatistics.busyExecutors .update(l.getBusyExecutors()); int q=0; for (hudson.model.Queue.BuildableItem bi : bis) { if(bi.task.getAssignedLabel()==l) q++; } l.loadStatistics.queueLength.update(q); } // update statistics of the entire system ComputerSet cs = new ComputerSet(); h.overallLoad.totalExecutors.update(cs.getTotalExecutors()); h.overallLoad.busyExecutors .update(cs.getBusyExecutors()); int q=0; for (hudson.model.Queue.BuildableItem bi : bis) { if(bi.task.getAssignedLabel()==null) q++; } h.overallLoad.queueLength.update(q); h.overallLoad.totalQueueLength.update(bis.size()); } }
@Override public int computeTotalExecutors() { return new ComputerSet().getTotalExecutors(); }
/** * Accepts submission from the configuration page. */ public synchronized void doConfigSubmit( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException, FormException { BulkChange bc = new BulkChange(MONITORS_OWNER); try { Hudson.getInstance().checkPermission(Hudson.ADMINISTER); monitors.rebuild(req,req.getSubmittedForm(),getNodeMonitorDescriptors()); // add in the rest of instances are ignored instances for (Descriptor<NodeMonitor> d : NodeMonitor.all()) if(monitors.get(d)==null) { NodeMonitor i = createDefaultInstance(d, true); if(i!=null) monitors.add(i); } rsp.sendRedirect2("."); } finally { bc.commit(); } }
/** * Number of busy {@link Executor}s that are carrying out some work right now. */ @Exported public int getBusyExecutors() { int r=0; for (Computer c : get_all()) { if(c.isOnline()) r += c.countBusy(); } return r; }
/** * @deprecated * UI method. Not meant to be used programatically. */ public ComputerSet getComputer() { return new ComputerSet(); }
public void doRun() { ComputerSet.initialize(); } }, 10, TimeUnit.SECONDS);
public CauseOfBlockage getCauseOfBlockage() { Jenkins jenkins = Jenkins.getInstance(); if(isBlockedByShutdown(task)) return CauseOfBlockage.fromMessage(Messages._Queue_HudsonIsAboutToShutDown()); List<CauseOfBlockage> causesOfBlockage = transientCausesOfBlockage; Label label = getAssignedLabel(); List<Node> allNodes = jenkins.getNodes(); if (allNodes.isEmpty()) label = null; // no master/agent. pointless to talk about nodes if (label != null) { Set<Node> nodes = label.getNodes(); if (label.isOffline()) { if (nodes.size() != 1) return new BecauseLabelIsOffline(label); else return new BecauseNodeIsOffline(nodes.iterator().next()); } else { if (causesOfBlockage != null && label.getIdleExecutors() > 0) { return new CompositeCauseOfBlockage(causesOfBlockage); } if (nodes.size() != 1) return new BecauseLabelIsBusy(label); else return new BecauseNodeIsBusy(nodes.iterator().next()); } } else if (causesOfBlockage != null && new ComputerSet().getIdleExecutors() > 0) { return new CompositeCauseOfBlockage(causesOfBlockage); } else { return CauseOfBlockage.createNeedsMoreExecutor(Messages._Queue_WaitingForNextAvailableExecutor()); } }