Class FlowNodeStorage

  • All Implemented Interfaces:
    org.jenkinsci.plugins.workflow.graph.FlowActionStorage
    Direct Known Subclasses:
    BulkFlowNodeStorage, SimpleXStreamFlowNodeStorage

    public abstract class FlowNodeStorage
    extends Object
    implements org.jenkinsci.plugins.workflow.graph.FlowActionStorage
    Abstraction of various ways to persist FlowNode, for those FlowExecutions who want to store them within Jenkins. A flow graph has a characteristic that it is additive. Flow nodes may be stored in memory or directly persisted to disk at any given moment, but invoking flush() should always guarantee that everything currently in memory is written.
    Author:
    Kohsuke Kawaguchi, Sam Van Oort
    • Constructor Summary

      Constructors 
      Constructor Description
      FlowNodeStorage()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void autopersist​(org.jenkinsci.plugins.workflow.graph.FlowNode n)
      Flushes the node if needed, and if supported, marks it as needing to flush with EVERY write to the FlowNode.actions.
      void flush()
      Invoke this to insure any unwritten FlowNode data is persisted to disk.
      void flushNode​(org.jenkinsci.plugins.workflow.graph.FlowNode n)
      Persists node fully to disk, ensuring it is written out to storage.
      abstract org.jenkinsci.plugins.workflow.graph.FlowNode getNode​(String id)  
      boolean isAvoidAtomicWrite()
      If true, we use non-atomic write of XML files for this storage.
      boolean isPersistedFully()
      Have we written everything to disk that we need to, or is there something waiting to be written by invoking flush()?
      void setAvoidAtomicWrite​(boolean avoidAtomicWrite)
      Set whether we should avoid using atomic write for node files (ensures valid node data if write is interrupted) or not.
      abstract void storeNode​(org.jenkinsci.plugins.workflow.graph.FlowNode n)
      Registers node in this storage, potentially persisting to disk.
      void storeNode​(org.jenkinsci.plugins.workflow.graph.FlowNode n, boolean delayWritingActions)
      Register the given node to the storage, potentially flushing to disk, and optionally marking the node as deferring writes.
      • Methods inherited from interface org.jenkinsci.plugins.workflow.graph.FlowActionStorage

        loadActions, saveActions
    • Constructor Detail

      • FlowNodeStorage

        public FlowNodeStorage()
    • Method Detail

      • isAvoidAtomicWrite

        public boolean isAvoidAtomicWrite()
        If true, we use non-atomic write of XML files for this storage. See AtomicFileWriter.
      • setAvoidAtomicWrite

        public void setAvoidAtomicWrite​(boolean avoidAtomicWrite)
        Set whether we should avoid using atomic write for node files (ensures valid node data if write is interrupted) or not.
      • getNode

        @CheckForNull
        public abstract org.jenkinsci.plugins.workflow.graph.FlowNode getNode​(String id)
                                                                       throws IOException
        Returns:
        null If no node of the given ID has been persisted before.
        Throws:
        IOException
      • storeNode

        public abstract void storeNode​(@NonNull
                                       org.jenkinsci.plugins.workflow.graph.FlowNode n)
                                throws IOException
        Registers node in this storage, potentially persisting to disk. flushNode(FlowNode) will guarantee it is persisted.
        Throws:
        IOException
      • storeNode

        public void storeNode​(@NonNull
                              org.jenkinsci.plugins.workflow.graph.FlowNode n,
                              boolean delayWritingActions)
                       throws IOException
        Register the given node to the storage, potentially flushing to disk, and optionally marking the node as deferring writes.

        This should be invoked with delayWritingAction=true until you have a fully configured node to write out. Generally autopersist(FlowNode) should be automatically invoked before Step execution begins unless the step is block-scoped (in which case the FlowNode will handle this).

        Parameters:
        n - Node to store
        delayWritingActions - If true, node will avoid persisting actions except on explicit flush or when you call autopersist(FlowNode).
        Throws:
        IOException
      • autopersist

        public void autopersist​(@NonNull
                                org.jenkinsci.plugins.workflow.graph.FlowNode n)
                         throws IOException
        Flushes the node if needed, and if supported, marks it as needing to flush with EVERY write to the FlowNode.actions.
        Throws:
        IOException
      • flushNode

        public void flushNode​(@NonNull
                              org.jenkinsci.plugins.workflow.graph.FlowNode n)
                       throws IOException
        Persists node fully to disk, ensuring it is written out to storage.
        Throws:
        IOException
      • flush

        public void flush()
                   throws IOException
        Invoke this to insure any unwritten FlowNode data is persisted to disk. Should be invoked by FlowExecution.notifyShutdown() to ensure disk state is persisted.
        Throws:
        IOException
      • isPersistedFully

        public boolean isPersistedFully()
        Have we written everything to disk that we need to, or is there something waiting to be written by invoking flush()?