mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-14 04:22:16 +00:00
Allow Node and RetentionStrategy to contribute to Computer#isAcceptingTasks
This commit is contained in:
1 parent
582128b9ac
commit
f07fb85352
3 files changed
+33
-1
No files matched your search
@@ -24,6 +24,8 @@
|
||||
*/
|
||||
package hudson.model;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.OverrideMustInvoke;
|
||||
import edu.umd.cs.findbugs.annotations.When;
|
||||
import hudson.EnvVars;
|
||||
import hudson.Launcher.ProcStarter;
|
||||
import hudson.Util;
|
||||
@@ -1318,9 +1320,13 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
|
||||
* 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()
|
||||
*/
|
||||
@OverrideMustInvoke(When.ANYTIME)
|
||||
public boolean isAcceptingTasks() {
|
||||
return true;
|
||||
final Node node = getNode();
|
||||
return getRetentionStrategy().isAcceptingTasks(this) && (node == null || node.isAcceptingTasks());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -194,6 +194,19 @@ public abstract class Node extends AbstractModelObject implements Reconfigurable
|
||||
*/
|
||||
protected abstract Computer createComputer();
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the node is accepting tasks. Needed to allow slaves programmatic suspension of task
|
||||
* scheduling that does not overlap with being offline. Called by {@link Computer#isAcceptingTasks()}.
|
||||
* This method is distinct from {@link Computer#isAcceptingTasks()} as sometimes the {@link Node} concrete
|
||||
* class may not have control over the {@link hudson.model.Computer} concrete class associated with it.
|
||||
*
|
||||
* @return {@code true} if the node is accepting tasks.
|
||||
* @see Computer#isAcceptingTasks()
|
||||
*/
|
||||
public boolean isAcceptingTasks() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Let Nodes be aware of the lifecycle of their own {@link Computer}.
|
||||
*/
|
||||
|
||||
@@ -67,6 +67,19 @@ public abstract class RetentionStrategy<T extends Computer> extends AbstractDesc
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the computer is accepting tasks. Needed to allow retention strategies programmatic
|
||||
* suspension of task scheduling that in preparation for going offline. Called by
|
||||
* {@link hudson.model.Computer#isAcceptingTasks()}
|
||||
*
|
||||
* @param c the computer.
|
||||
* @return {@code true} if the computer is accepting tasks
|
||||
* @see hudson.model.Computer#isAcceptingTasks()
|
||||
*/
|
||||
public boolean isAcceptingTasks(T c) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a new {@link Computer} object is introduced (such as when Hudson started, or when
|
||||
* a new slave is added.)
|
||||
|
||||
Reference in new issue
Block a user