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
Nested ClassesModifier 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the instance ofScoringLoadBalancer.DescriptorImpl
.int
Returns the throttle time of the workaround for simultaneous builds, which only allows a single build to start within the amount of milliseconds that is returned by this method.static void
ReplacesLoadBalancer
registered to Jenkins to ScoringLoadBalancer.boolean
Return whether this LoadBalancer is enabled.boolean
Returns whether to log calculated scores.boolean
Returns whether to enable the workaround for simultaneous builds, which throttles builds / only allows a single build to start within a certain time.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.
-
isSimultaneousBuildsWorkaroundEnabled
public boolean isSimultaneousBuildsWorkaroundEnabled()Returns whether to enable the workaround for simultaneous builds, which throttles builds / only allows a single build to start within a certain time.- Returns:
- whether to enable the workaround and throttle builds.
-
getSimultaneousBuildsWorkaroundThrottleTime
public int getSimultaneousBuildsWorkaroundThrottleTime()Returns the throttle time of the workaround for simultaneous builds, which only allows a single build to start within the amount of milliseconds that is returned by this method.- Returns:
- the throttle time in milliseconds of the workaround.
-
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:
-