mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-28 11:15:41 +00:00
JENKINS-36547: Introduce Queue.Task.getAffinityKey() (#3611)
* JENKINS-36547: Introduce Queue.Task.getAffinityKey() and use it in LoadBalancer.assignGreedily() to find a node for a task. * JENKINS-36547: Fix Javadoc error * fixup! JENKINS-36547: Fix Javadoc error * Fixed Javadoc for Queue.getAffinityKey()
This commit is contained in:
1 parent
943e27e00c
commit
d4121efe10
2 files changed
+13
-1
No files matched your search
@@ -112,7 +112,7 @@ public abstract class LoadBalancer implements ExtensionPoint {
|
||||
private boolean assignGreedily(Mapping m, Task task, List<ConsistentHash<ExecutorChunk>> hashes, int i) {
|
||||
if (i==hashes.size()) return true; // fully assigned
|
||||
|
||||
String key = task.getFullDisplayName() + (i>0 ? String.valueOf(i) : "");
|
||||
String key = task.getAffinityKey() + (i>0 ? String.valueOf(i) : "");
|
||||
|
||||
for (ExecutorChunk ec : hashes.get(i).list(key)) {
|
||||
// let's attempt this assignment
|
||||
|
||||
@@ -1896,6 +1896,18 @@ public class Queue extends ResourceController implements Saveable {
|
||||
*/
|
||||
String getFullDisplayName();
|
||||
|
||||
/**
|
||||
* Returns task-specific key which is used by the {@link LoadBalancer} to choose one particular executor
|
||||
* amongst all the free executors on all possibly suitable nodes.
|
||||
* NOTE: To be able to re-use the same node during the next run this key should not change from one run to
|
||||
* another. You probably want to compute that key based on the job's name.
|
||||
* <p>
|
||||
* @return by default: {@link #getFullDisplayName()}
|
||||
*
|
||||
* @see hudson.model.LoadBalancer
|
||||
*/
|
||||
default String getAffinityKey() { return getFullDisplayName(); }
|
||||
|
||||
/**
|
||||
* Checks the permission to see if the current user can abort this executable.
|
||||
* Returns normally from this method if it's OK.
|
||||
|
||||
Reference in new issue
Block a user