Package hudson.model
Class LoadStatistics
- java.lang.Object
-
- hudson.model.LoadStatistics
-
- Direct Known Subclasses:
OverallLoadStatistics
,UnlabeledLoadStatistics
@ExportedBean public abstract class LoadStatistics extends Object
Utilization statistics for a node or a set of nodes.Implementation Note
Instances of this class is not capable of updating the statistics itself — instead, it's done by the
LoadStatistics.LoadStatisticsUpdater
timer. This is more efficient (as it allows us a single pass to update all stats), but it's not clear to me if the loss of autonomy is worth it.- Author:
- Kohsuke Kawaguchi
- See Also:
Label.loadStatistics
,Jenkins.overallLoad
,Jenkins.unlabeledLoad
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LoadStatistics.LoadStatisticsSnapshot
Holds a snapshot of the current statistics.static class
LoadStatistics.LoadStatisticsUpdater
Periodically update the load statistics average.
-
Field Summary
Fields Modifier and Type Field Description MultiStageTimeSeries
availableExecutors
Number of executors not executing and available to take work and how it changes over time.MultiStageTimeSeries
busyExecutors
Number of busy executors and how it changes over time.static int
CLOCK
Load statistics clock cycle in milliseconds.MultiStageTimeSeries
connectingExecutors
Number of executors in the process of coming on-line and how it changes over time.static float
DECAY
With 0.90 decay ratio for every 10sec, half reduction is about 1 min.MultiStageTimeSeries
definedExecutors
Number of executors defined for Jenkins and how it changes over time.MultiStageTimeSeries
idleExecutors
Number of executors not executing and how it changes over time.MultiStageTimeSeries
onlineExecutors
Number of executors on-line and how it changes over time.MultiStageTimeSeries
queueLength
Number ofQueue.BuildableItem
s that can run on any node in this node set but blocked.MultiStageTimeSeries
totalExecutors
Deprecated.useonlineExecutors
.
-
Constructor Summary
Constructors Modifier Constructor Description protected
LoadStatistics(int initialOnlineExecutors, int initialBusyExecutors)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description abstract int
computeIdleExecutors()
Deprecated.abstract int
computeQueueLength()
Deprecated.LoadStatistics.LoadStatisticsSnapshot
computeSnapshot()
Computes a self-consistent snapshot of the load statistics.protected LoadStatistics.LoadStatisticsSnapshot
computeSnapshot(Iterable<Queue.BuildableItem> queue)
Computes the self-consistent snapshot with the specified queue items.abstract int
computeTotalExecutors()
Deprecated.protected void
configureRenderer(org.jfree.chart.renderer.category.LineAndShapeRenderer renderer)
org.jfree.chart.JFreeChart
createChart(org.jfree.data.category.CategoryDataset ds)
Creates a trend chart.MultiStageTimeSeries.TrendChart
createTrendChart(MultiStageTimeSeries.TimeScale timeScale)
CreatesCategoryDataset
which then becomes the basis of the load statistics graph.MultiStageTimeSeries.TrendChart
doGraph(String type)
Generates the load statistics graph.Api
getApi()
float
getLatestIdleExecutors(MultiStageTimeSeries.TimeScale timeScale)
Deprecated.useidleExecutors
directly.protected abstract Iterable<Node>
getNodes()
Returns theNode
instances that this statistic counts.protected abstract boolean
matches(Queue.Item item, SubTask subTask)
protected void
updateCounts(LoadStatistics.LoadStatisticsSnapshot current)
Updates all the series from the current snapshot.protected void
updateExecutorCounts()
Deprecated.
-
-
-
Field Detail
-
definedExecutors
@Exported public final MultiStageTimeSeries definedExecutors
Number of executors defined for Jenkins and how it changes over time.- Since:
- 1.607
-
onlineExecutors
@Exported public final MultiStageTimeSeries onlineExecutors
Number of executors on-line and how it changes over time. ReplacestotalExecutors
- Since:
- 1.607
-
connectingExecutors
@Exported public final MultiStageTimeSeries connectingExecutors
Number of executors in the process of coming on-line and how it changes over time.- Since:
- 1.607
-
busyExecutors
@Exported public final MultiStageTimeSeries busyExecutors
Number of busy executors and how it changes over time.
-
idleExecutors
@Exported public final MultiStageTimeSeries idleExecutors
Number of executors not executing and how it changes over time. Note the these executors may not be able to take work, seeavailableExecutors
.- Since:
- 1.607
-
availableExecutors
@Exported public final MultiStageTimeSeries availableExecutors
Number of executors not executing and available to take work and how it changes over time.- Since:
- 1.607
-
totalExecutors
@Exported @Deprecated public final MultiStageTimeSeries totalExecutors
Deprecated.useonlineExecutors
. NotetotalExecutors==onlineExecutors
for backward compatibility support.Number of total executors and how it changes over time.
-
queueLength
@Exported public final MultiStageTimeSeries queueLength
Number ofQueue.BuildableItem
s that can run on any node in this node set but blocked.
-
DECAY
public static final float DECAY
With 0.90 decay ratio for every 10sec, half reduction is about 1 min. Put differently, the half reduction time isCLOCK*log(0.5)/log(DECAY)
-
CLOCK
public static int CLOCK
Load statistics clock cycle in milliseconds. Specify a small value for quickly debugging this feature and node provisioning through cloud.
-
-
Method Detail
-
getLatestIdleExecutors
@Deprecated public float getLatestIdleExecutors(MultiStageTimeSeries.TimeScale timeScale)
Deprecated.useidleExecutors
directly.
-
computeIdleExecutors
@Deprecated public abstract int computeIdleExecutors()
Deprecated.Computes the # of idle executors right now and obtains the snapshot value.
-
computeTotalExecutors
@Deprecated public abstract int computeTotalExecutors()
Deprecated.Computes the # of total executors right now and obtains the snapshot value.
-
computeQueueLength
@Deprecated public abstract int computeQueueLength()
Deprecated.Computes the # of queue length right now and obtains the snapshot value.
-
createChart
public org.jfree.chart.JFreeChart createChart(org.jfree.data.category.CategoryDataset ds)
Creates a trend chart.
-
configureRenderer
protected void configureRenderer(org.jfree.chart.renderer.category.LineAndShapeRenderer renderer)
-
createTrendChart
public MultiStageTimeSeries.TrendChart createTrendChart(MultiStageTimeSeries.TimeScale timeScale)
CreatesCategoryDataset
which then becomes the basis of the load statistics graph.
-
doGraph
public MultiStageTimeSeries.TrendChart doGraph(@QueryParameter String type) throws IOException
Generates the load statistics graph.- Throws:
IOException
-
getApi
public Api getApi()
-
updateExecutorCounts
@Deprecated protected void updateExecutorCounts()
Deprecated.
-
updateCounts
protected void updateCounts(LoadStatistics.LoadStatisticsSnapshot current)
Updates all the series from the current snapshot.- Parameters:
current
- the current snapshot.- Since:
- 1.607
-
getNodes
protected abstract Iterable<Node> getNodes()
Returns theNode
instances that this statistic counts.- Returns:
- the
Node
- Since:
- 1.607
-
matches
protected abstract boolean matches(Queue.Item item, SubTask subTask)
- Parameters:
item
- theQueue.Item
that thebelongs to
subTask
- theSubTask
- Returns:
true
IFF the specifiedSubTask
from theQueue
should be counted.- Since:
- 1.607
-
computeSnapshot
public LoadStatistics.LoadStatisticsSnapshot computeSnapshot()
Computes a self-consistent snapshot of the load statistics. Note: The original method of computing load statistics would compute the total and idle counts independently which could lead to counting errors while jobs started in between the different state counting operations. By returning aLoadStatistics.LoadStatisticsSnapshot
we get a single consistent view of the counts which was valid for at least one point in time during the execution of this method.- Returns:
- a self-consistent snapshot of the load statistics.
- Since:
- 1.607
-
computeSnapshot
protected LoadStatistics.LoadStatisticsSnapshot computeSnapshot(Iterable<Queue.BuildableItem> queue)
Computes the self-consistent snapshot with the specified queue items.- Parameters:
queue
- the queue items.- Returns:
- a self-consistent snapshot of the load statistics.
- Since:
- 1.607
-
-