Class ScoringLoadBalancer
java.lang.Object
hudson.model.LoadBalancer
jp.ikedam.jenkins.plugins.scoringloadbalancer.ScoringLoadBalancer
- All Implemented Interfaces:
ExtensionPoint
,Describable<ScoringLoadBalancer>
LoadBalancer using scores of nodes.
Decides the nodes to execute tasks depending on scores of nodes.
Scoring is performed by
ScoringRule
s enabled in System Configuration page.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Descriptor forScoringLoadBalancer
Manages views and holds configuration forScoringLoadBalancer
.static class
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
-
Method Summary
Modifier and TypeMethodDescriptionReturns the instance ofScoringLoadBalancer.DescriptorImpl
.static void
ReplacesLoadBalancer
registered to Jenkins to ScoringLoadBalancer.boolean
Return whether this LoadBalancer is enabled.boolean
Returns whether to log calculated scores.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 Details
-
ScoringLoadBalancer
Constructor.- Parameters:
fallback
- LoadBalancer to fall back. Specify originally registered LoadBalancer.
-
-
Method Details
-
installLoadBalancer
ReplacesLoadBalancer
registered to Jenkins to ScoringLoadBalancer. TheLoadBalancer
originally registered are used as one to fall back. -
getFallback
- Returns:
LoadBalancer
to fall back
-
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
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:
-
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
Returns the instance ofScoringLoadBalancer.DescriptorImpl
.- Specified by:
getDescriptor
in interfaceDescribable<ScoringLoadBalancer>
- Returns:
- the instance of
ScoringLoadBalancer.DescriptorImpl
. - See Also:
-