Class BulkFlowNodeStorage
- java.lang.Object
-
- org.jenkinsci.plugins.workflow.support.storage.FlowNodeStorage
-
- org.jenkinsci.plugins.workflow.support.storage.BulkFlowNodeStorage
-
- All Implemented Interfaces:
org.jenkinsci.plugins.workflow.graph.FlowActionStorage
public class BulkFlowNodeStorage extends FlowNodeStorage
FlowNodeStorage
implementation that stores all theFlowNode
s together in one file for efficient bulk I/OThis defers persisting until
flush()
is called (or until we flush individual nodes explicitly or by storing them without specifying delayWritingActions=true. It also doesn't use the atomic write operations. Performance characteristics: much better use of the filesystem and far more efficient read/write if you do it all at once. HOWEVER, if you insist on explicitly writing out each node, this reverts to overall O(n^2) performance, where n is node count. For these reasons, this implementation should only be used whereFlowDurabilityHint.isPersistWithEveryStep()
is false.
-
-
Constructor Summary
Constructors Constructor Description BulkFlowNodeStorage(org.jenkinsci.plugins.workflow.flow.FlowExecution exec, File dir)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
flush()
Force persisting any nodes that had writing deferredvoid
flushNode(org.jenkinsci.plugins.workflow.graph.FlowNode n)
Persists a single FlowNode to disk (if not already persisted).org.jenkinsci.plugins.workflow.graph.FlowNode
getNode(String id)
boolean
isPersistedFully()
Have we written everything to disk that we need to, or is there something waiting to be writtenList<Action>
loadActions(org.jenkinsci.plugins.workflow.graph.FlowNode node)
void
saveActions(org.jenkinsci.plugins.workflow.graph.FlowNode node, List<Action> actions)
Just stores this one nodevoid
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 class org.jenkinsci.plugins.workflow.support.storage.FlowNodeStorage
autopersist, isAvoidAtomicWrite, setAvoidAtomicWrite
-
-
-
-
Field Detail
-
XSTREAM
public static final XStream2 XSTREAM
-
-
Constructor Detail
-
BulkFlowNodeStorage
public BulkFlowNodeStorage(org.jenkinsci.plugins.workflow.flow.FlowExecution exec, File dir)
-
-
Method Detail
-
getNode
@CheckForNull public org.jenkinsci.plugins.workflow.graph.FlowNode getNode(@NonNull String id) throws IOException
- Specified by:
getNode
in classFlowNodeStorage
- Returns:
- null If no node of the given ID has been persisted before.
- Throws:
IOException
-
storeNode
public void storeNode(@NonNull org.jenkinsci.plugins.workflow.graph.FlowNode n, boolean delayWritingActions) throws IOException
Description copied from class:FlowNodeStorage
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
FlowNodeStorage.autopersist(FlowNode)
should be automatically invoked before Step execution begins unless the step is block-scoped (in which case the FlowNode will handle this).- Overrides:
storeNode
in classFlowNodeStorage
- Parameters:
n
- Node to storedelayWritingActions
- If true, node will avoid persisting actions except on explicit flush or when you callFlowNodeStorage.autopersist(FlowNode)
.- Throws:
IOException
-
storeNode
public void storeNode(org.jenkinsci.plugins.workflow.graph.FlowNode n) throws IOException
Description copied from class:FlowNodeStorage
Registers node in this storage, potentially persisting to disk.FlowNodeStorage.flushNode(FlowNode)
will guarantee it is persisted.- Specified by:
storeNode
in classFlowNodeStorage
- Throws:
IOException
-
flushNode
public void flushNode(@NonNull org.jenkinsci.plugins.workflow.graph.FlowNode n) throws IOException
Persists a single FlowNode to disk (if not already persisted).- Overrides:
flushNode
in classFlowNodeStorage
- Parameters:
n
- Node to persist- Throws:
IOException
-
flush
public void flush() throws IOException
Force persisting any nodes that had writing deferred- Overrides:
flush
in classFlowNodeStorage
- Throws:
IOException
-
loadActions
public List<Action> loadActions(@NonNull org.jenkinsci.plugins.workflow.graph.FlowNode node) throws IOException
- Throws:
IOException
-
saveActions
public void saveActions(@NonNull org.jenkinsci.plugins.workflow.graph.FlowNode node, @NonNull List<Action> actions) throws IOException
Just stores this one node- Throws:
IOException
-
isPersistedFully
public boolean isPersistedFully()
Have we written everything to disk that we need to, or is there something waiting to be written- Overrides:
isPersistedFully
in classFlowNodeStorage
-
-