public class StatusAndTiming extends Object
Concepts: a chunk, which is a set of FlowNodes in the same FlowExecution with a first and last node.
Chunks exist in a context: the FlowNode before and the FlowNode after. These follow common-sense rules:
FlowStartNode for that executionFlowEndNode for that executionWorkflowRun is a parameter, it and the FlowNodes must all belong to the same executionParallel branch handling:
| Modifier and Type | Class and Description |
|---|---|
static class |
StatusAndTiming.StatusApiVersion
Denotes the version of the status API supported, which marks the permitted
GenericStatus values it may return |
| Modifier and Type | Field and Description |
|---|---|
static StatusAndTiming.StatusApiVersion |
API_V1 |
static StatusAndTiming.StatusApiVersion |
API_V2 |
static StatusAndTiming.StatusApiVersion |
CURRENT_API_VERSION |
| Constructor and Description |
|---|
StatusAndTiming() |
| Modifier and Type | Method and Description |
|---|---|
static GenericStatus |
coerceStatusApi(GenericStatus rawStatus,
StatusAndTiming.StatusApiVersion desiredVersion)
Use this to permit consuming this API without having to be aware of new
GenericStatus codes. |
static Map<String,GenericStatus> |
computeBranchStatuses(org.jenkinsci.plugins.workflow.job.WorkflowRun run,
org.jenkinsci.plugins.workflow.graph.FlowNode parallelStart,
List<org.jenkinsci.plugins.workflow.graph.BlockStartNode> branchStarts,
List<org.jenkinsci.plugins.workflow.graph.FlowNode> branchEnds,
org.jenkinsci.plugins.workflow.graph.FlowNode parallelEnd)
Deprecated.
|
static Map<String,GenericStatus> |
computeBranchStatuses(org.jenkinsci.plugins.workflow.job.WorkflowRun run,
org.jenkinsci.plugins.workflow.graphanalysis.ParallelMemoryFlowChunk parallel)
Deprecated.
|
static Map<String,GenericStatus> |
computeBranchStatuses2(org.jenkinsci.plugins.workflow.job.WorkflowRun run,
org.jenkinsci.plugins.workflow.graph.FlowNode parallelStart,
List<org.jenkinsci.plugins.workflow.graph.BlockStartNode> branchStarts,
List<org.jenkinsci.plugins.workflow.graph.FlowNode> branchEnds,
org.jenkinsci.plugins.workflow.graph.FlowNode parallelEnd)
Compute status codes for a set of parallel branches.
|
static Map<String,GenericStatus> |
computeBranchStatuses2(org.jenkinsci.plugins.workflow.job.WorkflowRun run,
org.jenkinsci.plugins.workflow.graphanalysis.ParallelMemoryFlowChunk parallel) |
static GenericStatus |
computeChunkStatus(org.jenkinsci.plugins.workflow.job.WorkflowRun run,
org.jenkinsci.plugins.workflow.graph.FlowNode before,
org.jenkinsci.plugins.workflow.graph.FlowNode firstNode,
org.jenkinsci.plugins.workflow.graph.FlowNode lastNode,
org.jenkinsci.plugins.workflow.graph.FlowNode after)
Deprecated.
|
static GenericStatus |
computeChunkStatus(org.jenkinsci.plugins.workflow.job.WorkflowRun run,
org.jenkinsci.plugins.workflow.graphanalysis.MemoryFlowChunk chunk)
Deprecated.
|
static GenericStatus |
computeChunkStatus2(org.jenkinsci.plugins.workflow.job.WorkflowRun run,
org.jenkinsci.plugins.workflow.graph.FlowNode before,
org.jenkinsci.plugins.workflow.graph.FlowNode firstNode,
org.jenkinsci.plugins.workflow.graph.FlowNode lastNode,
org.jenkinsci.plugins.workflow.graph.FlowNode after)
Compute the overall status for a chunk comprising firstNode through lastNode, inclusive
|
static GenericStatus |
computeChunkStatus2(org.jenkinsci.plugins.workflow.job.WorkflowRun run,
org.jenkinsci.plugins.workflow.graphanalysis.MemoryFlowChunk chunk)
Return status or null if not executed all (null FlowExecution)
Note: API consumers MUST use
coerceStatusApi(GenericStatus, StatusApiVersion) on outputs
to safely handle addition of new statuses. |
static TimingInfo |
computeChunkTiming(org.jenkinsci.plugins.workflow.job.WorkflowRun run,
long internalPauseDuration,
org.jenkinsci.plugins.workflow.graph.FlowNode firstNode,
org.jenkinsci.plugins.workflow.graph.FlowNode lastNode,
org.jenkinsci.plugins.workflow.graph.FlowNode after)
Compute timing for a chunk of nodes
|
static TimingInfo |
computeChunkTiming(org.jenkinsci.plugins.workflow.job.WorkflowRun run,
long internalPauseDuration,
org.jenkinsci.plugins.workflow.graphanalysis.MemoryFlowChunk chunk) |
static TimingInfo |
computeOverallParallelTiming(org.jenkinsci.plugins.workflow.job.WorkflowRun run,
Map<String,TimingInfo> branchTimings,
org.jenkinsci.plugins.workflow.graph.FlowNode parallelStart,
org.jenkinsci.plugins.workflow.graph.FlowNode parallelEnd)
Computes the branch timings for a set of parallel branches.
|
static Map<String,TimingInfo> |
computeParallelBranchTimings(org.jenkinsci.plugins.workflow.job.WorkflowRun run,
org.jenkinsci.plugins.workflow.graph.FlowNode parallelStart,
List<org.jenkinsci.plugins.workflow.graph.BlockStartNode> branchStarts,
List<org.jenkinsci.plugins.workflow.graph.FlowNode> branchEnds,
org.jenkinsci.plugins.workflow.graph.FlowNode parallelEnd,
long[] pauseDurations)
Compute timing for all branches of a parallel
|
static GenericStatus |
condenseStatus(Collection<GenericStatus> statuses)
Combines the status results from a list of parallel branches to report a single overall status
|
static boolean |
isPendingInput(org.jenkinsci.plugins.workflow.job.WorkflowRun run)
Return true if the run is paused on input
|
static void |
printNodes(org.jenkinsci.plugins.workflow.job.WorkflowRun run,
boolean showTiming,
boolean showActions)
Helper, prints flow graph in some detail - now a common utility so others don't have to reinvent it
|
static void |
verifySameRun(org.jenkinsci.plugins.workflow.job.WorkflowRun run,
org.jenkinsci.plugins.workflow.graph.FlowNode... nodes)
Check that all the flownodes & run describe the same pipeline run/execution
|
public static final StatusAndTiming.StatusApiVersion API_V1
public static final StatusAndTiming.StatusApiVersion API_V2
public static final StatusAndTiming.StatusApiVersion CURRENT_API_VERSION
public static GenericStatus coerceStatusApi(GenericStatus rawStatus, StatusAndTiming.StatusApiVersion desiredVersion)
GenericStatus codes.
This will do a mapping from status codes to the closest equivalent in an older version of this API.
For example, GenericStatus.QUEUED was originally coded as GenericStatus.IN_PROGRESSrawStatus - Input status from recent forms of this APIdesiredVersion - Defines the statuses supported by the API version we wish to consumeStatusAndTiming.StatusApiVersion.allowedStatusespublic static void verifySameRun(@Nonnull org.jenkinsci.plugins.workflow.job.WorkflowRun run, @CheckForNull org.jenkinsci.plugins.workflow.graph.FlowNode... nodes) throws IllegalArgumentException
run - Run that nodes must belong tonodes - Nodes to match to runIllegalArgumentException - For the first flownode that doesn't belong to the FlowExecution of runpublic static boolean isPendingInput(org.jenkinsci.plugins.workflow.job.WorkflowRun run)
run - @CheckForNull @Deprecated public static GenericStatus computeChunkStatus(@Nonnull org.jenkinsci.plugins.workflow.job.WorkflowRun run, @Nonnull org.jenkinsci.plugins.workflow.graphanalysis.MemoryFlowChunk chunk)
GenericStatus values to the original set (without GenericStatus.QUEUED).
Most consumers should switch to computeChunkStatus2(WorkflowRun, MemoryFlowChunk) and use
coerceStatusApi(GenericStatus, StatusApiVersion) to map new statuses to recognized ones.@CheckForNull public static GenericStatus computeChunkStatus2(@Nonnull org.jenkinsci.plugins.workflow.job.WorkflowRun run, @Nonnull org.jenkinsci.plugins.workflow.graphanalysis.MemoryFlowChunk chunk)
coerceStatusApi(GenericStatus, StatusApiVersion) on outputs
to safely handle addition of new statuses.run - chunk - @CheckForNull @Deprecated public static GenericStatus computeChunkStatus(@Nonnull org.jenkinsci.plugins.workflow.job.WorkflowRun run, @CheckForNull org.jenkinsci.plugins.workflow.graph.FlowNode before, @Nonnull org.jenkinsci.plugins.workflow.graph.FlowNode firstNode, @Nonnull org.jenkinsci.plugins.workflow.graph.FlowNode lastNode, @CheckForNull org.jenkinsci.plugins.workflow.graph.FlowNode after)
GenericStatus values to the original set (without GenericStatus.QUEUED).
Most consumers should switch to computeChunkStatus2(WorkflowRun, FlowNode, FlowNode, FlowNode, FlowNode)
and handle unknown status codes.@CheckForNull public static GenericStatus computeChunkStatus2(@Nonnull org.jenkinsci.plugins.workflow.job.WorkflowRun run, @CheckForNull org.jenkinsci.plugins.workflow.graph.FlowNode before, @Nonnull org.jenkinsci.plugins.workflow.graph.FlowNode firstNode, @Nonnull org.jenkinsci.plugins.workflow.graph.FlowNode lastNode, @CheckForNull org.jenkinsci.plugins.workflow.graph.FlowNode after)
All nodes must be in the same execution
Note: for in-progress builds with parallel branches, if the branch is done, it has its own status.
Note: API consumers MUST usecoerceStatusApi(GenericStatus, StatusApiVersion) on outputs
to safely handle addition of new statuses.run - Run that nodes belong tobefore - Node before the first node in this piecefirstNode - First node of this piecelastNode - Last node of this piece (if lastNode==firstNode, it's a single FlowNode)after - Node after this piece, null if the lastNode is the currentHead of the flow@CheckForNull public static TimingInfo computeChunkTiming(@Nonnull org.jenkinsci.plugins.workflow.job.WorkflowRun run, long internalPauseDuration, @Nonnull org.jenkinsci.plugins.workflow.graphanalysis.MemoryFlowChunk chunk)
@CheckForNull public static TimingInfo computeChunkTiming(@Nonnull org.jenkinsci.plugins.workflow.job.WorkflowRun run, long internalPauseDuration, @Nonnull org.jenkinsci.plugins.workflow.graph.FlowNode firstNode, @Nonnull org.jenkinsci.plugins.workflow.graph.FlowNode lastNode, @CheckForNull org.jenkinsci.plugins.workflow.graph.FlowNode after)
Note: for in-progress builds with parallel branches, the running branches end at the current time.
Completed branches use the time at which the BlockEndNode terminating the branch was created.
run - WorkflowRun they all belong tointernalPauseDuration - Millis paused in the chunk (including the ends)firstNode - First node in the chunklastNode - Last node in the chunkafter - Node after the chunk, if null we assume this chunk is at the end of the flow@CheckForNull public static TimingInfo computeOverallParallelTiming(@Nonnull org.jenkinsci.plugins.workflow.job.WorkflowRun run, @Nonnull Map<String,TimingInfo> branchTimings, @Nonnull org.jenkinsci.plugins.workflow.graph.FlowNode parallelStart, @CheckForNull org.jenkinsci.plugins.workflow.graph.FlowNode parallelEnd)
run - branchTimings - Map of branch name : precomputed timing infoparallelStart - parallelEnd - @Nonnull public static Map<String,TimingInfo> computeParallelBranchTimings(@Nonnull org.jenkinsci.plugins.workflow.job.WorkflowRun run, @Nonnull org.jenkinsci.plugins.workflow.graph.FlowNode parallelStart, @Nonnull List<org.jenkinsci.plugins.workflow.graph.BlockStartNode> branchStarts, @Nonnull List<org.jenkinsci.plugins.workflow.graph.FlowNode> branchEnds, @CheckForNull org.jenkinsci.plugins.workflow.graph.FlowNode parallelEnd, @Nonnull long[] pauseDurations)
run - Run the branches belong toparallelStart - Start of parallel blockbranchStarts - Nodes that begin each parallel branchbranchEnds - Nodes that represent the "tip" of each parallel branch (may be the end node, or just the latest)parallelEnd - End of parallel block (null if in progress)pauseDurations - Accumulated pause durations for each of the branches, in order@Nonnull @Deprecated public static Map<String,GenericStatus> computeBranchStatuses(@Nonnull org.jenkinsci.plugins.workflow.job.WorkflowRun run, @Nonnull org.jenkinsci.plugins.workflow.graphanalysis.ParallelMemoryFlowChunk parallel)
@Nonnull public static Map<String,GenericStatus> computeBranchStatuses2(@Nonnull org.jenkinsci.plugins.workflow.job.WorkflowRun run, @Nonnull org.jenkinsci.plugins.workflow.graphanalysis.ParallelMemoryFlowChunk parallel)
@Deprecated @Nonnull public static Map<String,GenericStatus> computeBranchStatuses(@Nonnull org.jenkinsci.plugins.workflow.job.WorkflowRun run, @Nonnull org.jenkinsci.plugins.workflow.graph.FlowNode parallelStart, @Nonnull List<org.jenkinsci.plugins.workflow.graph.BlockStartNode> branchStarts, @Nonnull List<org.jenkinsci.plugins.workflow.graph.FlowNode> branchEnds, @CheckForNull org.jenkinsci.plugins.workflow.graph.FlowNode parallelEnd)
computeBranchStatuses2(WorkflowRun, FlowNode, List, List, FlowNode) once you support use of coerceStatusApi(GenericStatus, StatusApiVersion)
to protect against changes.@Nonnull public static Map<String,GenericStatus> computeBranchStatuses2(@Nonnull org.jenkinsci.plugins.workflow.job.WorkflowRun run, @Nonnull org.jenkinsci.plugins.workflow.graph.FlowNode parallelStart, @Nonnull List<org.jenkinsci.plugins.workflow.graph.BlockStartNode> branchStarts, @Nonnull List<org.jenkinsci.plugins.workflow.graph.FlowNode> branchEnds, @CheckForNull org.jenkinsci.plugins.workflow.graph.FlowNode parallelEnd)
Note per computeChunkStatus2(WorkflowRun, MemoryFlowChunk) for in-progress builds with
parallel branches, if the branch is done, it has its own status.
coerceStatusApi(GenericStatus, StatusApiVersion) on outputs
to safely handle addition of new statuses.run - Run containing these nodesbranchStarts - The nodes starting off each parallel branch (BlockStartNode)branchEnds - Last node in each parallel branch - might be the end of the branch, or might just be the latest step runparallelStart - Start node for overall parallel blockparallelEnd - End node for the overall parallelBlock (null if not complete)@CheckForNull public static GenericStatus condenseStatus(@Nonnull Collection<GenericStatus> statuses)
statuses - @Restricted(value=org.kohsuke.accmod.restrictions.DoNotUse.class) public static void printNodes(@Nonnull org.jenkinsci.plugins.workflow.job.WorkflowRun run, boolean showTiming, boolean showActions)
run - Run to show nodes forshowTiming - showActions - Copyright © 2016–2018. All rights reserved.