Class FlowNodeStorage
- java.lang.Object
-
- org.jenkinsci.plugins.workflow.support.storage.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 persistFlowNode
, for thoseFlowExecution
s 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 invokingflush()
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 theFlowNode.actions
.void
flush()
Invoke this to insure any unwrittenFlowNode
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 invokingflush()
?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.
-
-
-
Method Detail
-
isAvoidAtomicWrite
public boolean isAvoidAtomicWrite()
If true, we use non-atomic write of XML files for this storage. SeeAtomicFileWriter
.
-
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 storedelayWritingActions
- If true, node will avoid persisting actions except on explicit flush or when you callautopersist(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 theFlowNode.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 unwrittenFlowNode
data is persisted to disk. Should be invoked byFlowExecution.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 invokingflush()
?
-
-