Class StandardChunkVisitor

java.lang.Object
org.jenkinsci.plugins.workflow.graphanalysis.StandardChunkVisitor
All Implemented Interfaces:
SimpleChunkVisitor

public class StandardChunkVisitor extends Object implements SimpleChunkVisitor
Simple handler for linear FlowChunks (basic stages, etc), and designed to be extended. Note: only tracks one chunk at a time, so it won't handle nesting or parallels. Specifically, it will reset with each chunk start. Extend handleChunkDone(MemoryFlowChunk) to gather up final chunks. Extend atomNode(FlowNode, FlowNode, FlowNode, ForkScanner) to gather data about nodes in a chunk.
Author:
Sam Van Oort
  • Field Details

  • Constructor Details

    • StandardChunkVisitor

      public StandardChunkVisitor()
  • Method Details

    • handleChunkDone

      protected void handleChunkDone(@NonNull MemoryFlowChunk chunk)
      Override me to do something once the chunk is finished (such as add it to a list). Note: the chunk will be mutated directly, so you need to copy it if you want to do something.
    • resetChunk

      protected void resetChunk(@NonNull MemoryFlowChunk chunk)
    • chunkStart

      public void chunkStart(@NonNull FlowNode startNode, @CheckForNull FlowNode beforeBlock, @NonNull ForkScanner scanner)
      Description copied from interface: SimpleChunkVisitor
      Called when hitting the start of a chunk.
      Specified by:
      chunkStart in interface SimpleChunkVisitor
      Parameters:
      startNode - First node in chunk (marker), included in node
      beforeBlock - First node before chunk (null if none exist)
      scanner - Forkscanner used (for state tracking)
    • chunkEnd

      public void chunkEnd(@NonNull FlowNode endNode, @CheckForNull FlowNode afterChunk, @NonNull ForkScanner scanner)
      Description copied from interface: SimpleChunkVisitor
      Called when hitting the end of a chunk.
      Specified by:
      chunkEnd in interface SimpleChunkVisitor
      Parameters:
      endNode - Last node in chunk
      afterChunk - Node after chunk (null if we are on the last node)
      scanner - Forkscanner used (for state tracking)
    • parallelStart

      public void parallelStart(@NonNull FlowNode parallelStartNode, @NonNull FlowNode branchNode, @NonNull ForkScanner scanner)
      Description copied from interface: SimpleChunkVisitor
      Notifies that we've hit the start of a parallel block (the point where it branches out).
      Specified by:
      parallelStart in interface SimpleChunkVisitor
      Parameters:
      parallelStartNode - The BlockStartNode beginning it, next will be branches
      branchNode - BlockStartNode for one of the branches (it will be labelled)
      scanner - ForkScanner used
    • parallelEnd

      public void parallelEnd(@NonNull FlowNode parallelStartNode, @NonNull FlowNode parallelEndNode, @NonNull ForkScanner scanner)
      Description copied from interface: SimpleChunkVisitor
      Notifies that we've seen the end of a parallel block
      Specified by:
      parallelEnd in interface SimpleChunkVisitor
      Parameters:
      parallelStartNode - First node of parallel (BlockStartNode before the branches)
      parallelEndNode - Last node of parallel (BlockEndNode)
      scanner - ForkScanner used
    • parallelBranchStart

      public void parallelBranchStart(@NonNull FlowNode parallelStartNode, @NonNull FlowNode branchStartNode, @NonNull ForkScanner scanner)
      Description copied from interface: SimpleChunkVisitor
      Hit the start of a parallel branch
      Specified by:
      parallelBranchStart in interface SimpleChunkVisitor
      Parameters:
      parallelStartNode - First node of parallel (BlockStartNode before the branches)
      branchStartNode - BlockStartNode beginning the branch (this will have the ThreadNameAction giving its name)
      scanner - ForkScanner used
    • parallelBranchEnd

      public void parallelBranchEnd(@NonNull FlowNode parallelStartNode, @NonNull FlowNode branchEndNode, @NonNull ForkScanner scanner)
      Description copied from interface: SimpleChunkVisitor
      Hit the end start of a parallel branch

      May not be invoked if we're inside an in-progress parallel

      Specified by:
      parallelBranchEnd in interface SimpleChunkVisitor
      Parameters:
      parallelStartNode - First node of parallel (BlockStartNode before the branches)
      branchEndNode - Final node of the branch (may be BlockEndNode if done, otherwise just the last one executed)
      scanner - ForkScanner used
    • atomNode

      public void atomNode(@CheckForNull FlowNode before, @NonNull FlowNode atomNode, @CheckForNull FlowNode after, @NonNull ForkScanner scan)
      Extend me to do something with nodes inside a chunk
      Specified by:
      atomNode in interface SimpleChunkVisitor
      Parameters:
      before - Node before the current
      atomNode - The node itself
      after - Node after the current
      scan - Reference to our forkscanner, if we want to poke at the state within