Package org.jenkinsci.plugins.workflow.graphanalysis
Provides a library of methods to work with and analyze the graph of
FlowNode
s produced from a pipeline execution.
The core APIs are described in the javadocs for AbstractFlowScanner
But in general it provides for iteration through the Directed Acyclic Graph (DAG) of a flow, filtering, search for matches, and
visiting all nodes via internal iteration.
Static methods and a few implementations are also provided in FlowScanningUtils
.
How To Pick A FlowScanner For Iteration
- Want fast iteration, don't care about visiting every node or parallels?
LinearScanner
- Visit every node as fast as possible?
DepthFirstScanner
- Visit every block in a predictable order, from end to start?
ForkScanner
- Fastest way to find preceding sibling or enclosing nodes?
LinearBlockHoppingScanner
Methods to iterate through flow graph and break it into chunks (regions) of interest, with nesting possible and reporting of branches:
Basic APIs
ChunkFinder
- API to define conditions for starting/ending a chunkSimpleChunkVisitor
- Visitor API that accepts callbacks for chunk boundaries/contenst + parallel branchingFlowChunk
- A region of interest, defined by its first and last nodesFlowChunkWithContext
- A FlowChunk that knows about the nodes before/after it, to give context for determining success/failure and the time taken to execute
Data structures and implementations:
MemoryFlowChunk
- A FlowChunkWithContext that just directly stores FlowNodesParallelFlowChunk
ParallelMemoryFlowChunk
StandardChunkVisitor
- a basic concrete implementation of SimpleChunkVisitor that tracks one chunk at a time (no nesting) and runs a callback when the chunk is doneLabelledChunkFinder
- ChunkFinder that matches against nodes with a labelBlockChunkFinder
- ChunkFinder that creates chunks from blocks
-
Interface Summary Interface Description ChunkFinder Think of this as setting conditions to mark a region of interest in the graph ofFlowNode
from aFlowExecution
.Filterator<T> Iterator that may be navigated through a filtered wrapper.FlowChunk Common container interface for a series ofFlowNode
s with a logical start and end.FlowChunkWithContext FlowChunk with information about what comes before/afterFlowNodeVisitor Interface used when examining a pipeline FlowNode graph node by node, and terminating when a condition is metParallelFlowChunk<ChunkType extends FlowChunk> FlowChunk mapping to the block from a Parallel step (with parallel branches inside)SimpleChunkVisitor This visitor's callbacks are invoked as we walk through a pipeline flow graph, and it splits it into chunks. -
Class Summary Class Description AbstractFlowScanner Core APIs and base logic for FlowScanners that extract information from a pipeline execution.BlockChunkFinder Matches start and end of a block.DepthFirstScanner Does a simple and somewhat efficient depth-first search of all FlowNodes in the DAG.FlowScanningUtils Library of common functionality when analyzing/walking flow graphsForkScanner Scanner that will scan down all forks when we hit parallel blocks before continuing, but generally runs in linear orderLabelledChunkFinder Splits a flow execution intoFlowChunk
s whenever you have a label.LinearBlockHoppingScanner Extension ofLinearScanner
that skips nested blocks at the current level, useful for finding enclosing blocks.LinearScanner Scans through the flow graph in strictly linear fashion, visiting only the first branch in parallel blocks.MemoryFlowChunk FlowChunk that holds direct references to theFlowNode
instances and context info This makes it easy to use in analysis and visualizations, but inappropriate to retain in caches, etcNodeStepNamePredicate NodeStepTypePredicate ParallelMemoryFlowChunk Corresponds to a parallel block, acts as an in-memory container that can plug into status/timing APIsStandardChunkVisitor Simple handler for linearFlowChunk
s (basic stages, etc), and designed to be extended.