mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-17 22:12:25 +00:00
correcting when to display labels and what to show there, by considering the presence of a cloud
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@18327 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
54e156cb73
commit
f7ffc67fb7
2 files changed
+26
-9
No files matched your search
@@ -134,18 +134,35 @@ public class Label implements Comparable<Label>, ModelObject {
|
||||
return clouds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can jobs be assigned to this label?
|
||||
* <p>
|
||||
* The answer is yes if there is a reasonable basis to believe that Hudson can have
|
||||
* an executor under this label, given the current configuration. This includes
|
||||
* situations such as (1) there are offline slaves that have this label (2) clouds exist
|
||||
* that can provision slaves that have this label.
|
||||
*/
|
||||
public boolean isAssignable() {
|
||||
for (Node n : getNodes())
|
||||
if(n.getNumExecutors()>0)
|
||||
return true;
|
||||
return !getClouds().isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of total {@link Executor}s that belong to this label.
|
||||
* <p>
|
||||
* This includes executors that belong to offline nodes.
|
||||
* This includes executors that belong to offline nodes, so the result
|
||||
* can be thought of as a potential capacity, whereas {@link #getTotalExecutors()}
|
||||
* is the currently functioning total number of executors.
|
||||
* <p>
|
||||
* This method doesn't take the dynamically allocatable nodes (via {@link Cloud})
|
||||
* into account. If you just want to test if there's some executors, use {@link #isAssignable()}.
|
||||
*/
|
||||
public int getTotalConfiguredExecutors() {
|
||||
int r=0;
|
||||
for (Node n : getNodes()) {
|
||||
Computer c = n.toComputer();
|
||||
if(c!=null)
|
||||
r += c.countExecutors();
|
||||
}
|
||||
for (Node n : getNodes())
|
||||
r += n.getNumExecutors();
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user