Class ScoringLoadBalancer
- java.lang.Object
-
- hudson.model.LoadBalancer
-
- jp.ikedam.jenkins.plugins.scoringloadbalancer.ScoringLoadBalancer
-
- All Implemented Interfaces:
ExtensionPoint
,Describable<ScoringLoadBalancer>
public class ScoringLoadBalancer extends LoadBalancer implements Describable<ScoringLoadBalancer>
LoadBalancer using scores of nodes. Decides the nodes to execute tasks depending on scores of nodes. Scoring is performed byScoringRule
s enabled in System Configuration page.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ScoringLoadBalancer.DescriptorImpl
Descriptor forScoringLoadBalancer
Manages views and holds configuration forScoringLoadBalancer
.static class
ScoringLoadBalancer.NodesScore
Holds scores of nodes.-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Field Summary
-
Fields inherited from class hudson.model.LoadBalancer
CONSISTENT_HASH, DEFAULT
-
-
Constructor Summary
Constructors Constructor Description ScoringLoadBalancer(LoadBalancer fallback)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ScoringLoadBalancer.DescriptorImpl
getDescriptor()
Returns the instance ofScoringLoadBalancer.DescriptorImpl
.LoadBalancer
getFallback()
List<ScoringRule>
getScoringRuleList()
static void
installLoadBalancer()
ReplacesLoadBalancer
registered to Jenkins to ScoringLoadBalancer.boolean
isEnabled()
Return whether this LoadBalancer is enabled.boolean
isReportScoresEnabled()
Returns whether to log calculated scores.MappingWorksheet.Mapping
map(Queue.Task task, MappingWorksheet worksheet)
Decides nodes to run tasks on.protected void
reportScores(MappingWorksheet.WorkChunk wc, List<MappingWorksheet.ExecutorChunk> executors, ScoringLoadBalancer.NodesScore nodesScore)
Log scores.protected void
sortExecutors(List<MappingWorksheet.ExecutorChunk> executors, ScoringLoadBalancer.NodesScore nodesScore)
sortMappingWorksheet.ExecutorChunk
s (that is, nodes) by scores.-
Methods inherited from class hudson.model.LoadBalancer
sanitize
-
-
-
-
Constructor Detail
-
ScoringLoadBalancer
public ScoringLoadBalancer(LoadBalancer fallback)
Constructor.- Parameters:
fallback
- LoadBalancer to fall back. Specify originally registered LoadBalancer.
-
-
Method Detail
-
installLoadBalancer
@Initializer(after=PLUGINS_STARTED, fatal=false) public static void installLoadBalancer()
ReplacesLoadBalancer
registered to Jenkins to ScoringLoadBalancer. TheLoadBalancer
originally registered are used as one to fall back.
-
getFallback
public LoadBalancer getFallback()
- Returns:
LoadBalancer
to fall back
-
getScoringRuleList
public List<ScoringRule> getScoringRuleList()
- Returns:
- list of
ScoringRule
s
-
isEnabled
public boolean isEnabled()
Return whether this LoadBalancer is enabled. If disabled, simply call LoadBalancer to fall back.- Returns:
- whether this LoadBalancer is enabled.
-
isReportScoresEnabled
public boolean isReportScoresEnabled()
Returns whether to log calculated scores.- Returns:
- whether to log calculated scores.
-
map
public MappingWorksheet.Mapping map(Queue.Task task, MappingWorksheet worksheet)
Decides nodes to run tasks on.- Specified by:
map
in classLoadBalancer
- Parameters:
task
- the root task.worksheet
- an object containing information of subtasks to execute and nodes tasks can execute on.- Returns:
- mapping from subtasks to nodes.
- See Also:
LoadBalancer.map(hudson.model.Queue.Task, hudson.model.queue.MappingWorksheet)
-
sortExecutors
protected void sortExecutors(List<MappingWorksheet.ExecutorChunk> executors, ScoringLoadBalancer.NodesScore nodesScore)
sortMappingWorksheet.ExecutorChunk
s (that is, nodes) by scores.- Parameters:
executors
-nodesScore
-
-
reportScores
protected void reportScores(MappingWorksheet.WorkChunk wc, List<MappingWorksheet.ExecutorChunk> executors, ScoringLoadBalancer.NodesScore nodesScore)
Log scores. For diagnostics purpose.- Parameters:
executors
-nodesScore
-
-
getDescriptor
public ScoringLoadBalancer.DescriptorImpl getDescriptor()
Returns the instance ofScoringLoadBalancer.DescriptorImpl
.- Specified by:
getDescriptor
in interfaceDescribable<ScoringLoadBalancer>
- Returns:
- the instance of
ScoringLoadBalancer.DescriptorImpl
. - See Also:
Describable.getDescriptor()
-
-