Package hudson.model
Class LoadBalancer
- java.lang.Object
-
- hudson.model.LoadBalancer
-
- All Implemented Interfaces:
ExtensionPoint
public abstract class LoadBalancer extends Object implements ExtensionPoint
Strategy that decides whichQueue.Task
gets run on whichExecutor
.Even though this is marked as
ExtensionPoint
, you do not register your implementation with @Extension
. Instead, callQueue.setLoadBalancer(LoadBalancer)
to install your implementation.- Since:
- 1.301
- Author:
- Kohsuke Kawaguchi
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Field Summary
Fields Modifier and Type Field Description static LoadBalancer
CONSISTENT_HASH
Uses a consistent hash for scheduling.static LoadBalancer
DEFAULT
Deprecated.as of 1.377 The only implementation in the core now is the one based on consistent hash.
-
Constructor Summary
Constructors Constructor Description LoadBalancer()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract MappingWorksheet.Mapping
map(Queue.Task task, MappingWorksheet worksheet)
Chooses the executor(s) to carry out the build for the given task.protected LoadBalancer
sanitize()
Wraps thisLoadBalancer
into a decorator that tests the basic sanity of the implementation.
-
-
-
Field Detail
-
CONSISTENT_HASH
public static final LoadBalancer CONSISTENT_HASH
Uses a consistent hash for scheduling.
-
DEFAULT
@Deprecated public static final LoadBalancer DEFAULT
Deprecated.as of 1.377 The only implementation in the core now is the one based on consistent hash.Traditional implementation of this.
-
-
Method Detail
-
map
@CheckForNull public abstract MappingWorksheet.Mapping map(@NonNull Queue.Task task, MappingWorksheet worksheet)
Chooses the executor(s) to carry out the build for the given task.This method is invoked from different threads, but the execution is serialized by the caller. The thread that invokes this method always holds a lock to
Queue
, so queue contents can be safely introspected from this method, if that information is necessary to make decisions.- Parameters:
task
- The task whose execution is being considered. Never null.worksheet
- The work sheet that represents the matching that needs to be made. The job of this method is to determine which work units on this worksheet are executed on which executors (also on this worksheet.)- Returns:
- Build up the mapping by using the given worksheet and return it. Return null if you don't want the task to be executed right now, in which case this method will be called some time later with the same task.
-
sanitize
protected LoadBalancer sanitize()
Wraps thisLoadBalancer
into a decorator that tests the basic sanity of the implementation. Only override this if you find some of the checks excessive, but beware that it's like driving without a seat belt.
-
-