Class WriteUtil
- java.lang.Object
-
- org.somda.sdc.biceps.common.access.helper.WriteUtil
-
public class WriteUtil extends Object
Common code for write description and states that can be used by BICEPS providers and consumers.Remark: The operations do not copy descriptors or states.
-
-
Constructor Summary
Constructors Constructor Description WriteUtil(org.slf4j.Logger logger, Distributor eventDistributor, MdibStoragePreprocessingChain mdibAccessPreprocessing, ReentrantReadWriteLock readWriteLock, MdibAccess mdibAccess)Constructor that accepts the dependencies in order to properly process write operations.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description WriteDescriptionResultwriteDescription(Function<MdibDescriptionModifications,WriteDescriptionResult> lockedWriteDescription, MdibDescriptionModifications descriptionModifications)Performs preprocessing, write operation and event distribution of description modifications.WriteStateResultwriteStates(Function<MdibStateModifications,WriteStateResult> lockedWriteStates, MdibStateModifications stateModifications)Performs preprocessing, write operation and event distribution of state modifications.
-
-
-
Constructor Detail
-
WriteUtil
public WriteUtil(org.slf4j.Logger logger, Distributor eventDistributor, MdibStoragePreprocessingChain mdibAccessPreprocessing, ReentrantReadWriteLock readWriteLock, MdibAccess mdibAccess)Constructor that accepts the dependencies in order to properly process write operations.- Parameters:
logger- the utility owner's logger to be used for logging.eventDistributor- the event distributor to send event messages after write operation is done.mdibAccessPreprocessing- the preprocessing chain that is invoked before writing to the MDIB storage.readWriteLock- a read write lock to protect against concurrent access.mdibAccess- the MDIB access that is passed on event distribution.
-
-
Method Detail
-
writeDescription
public WriteDescriptionResult writeDescription(Function<MdibDescriptionModifications,WriteDescriptionResult> lockedWriteDescription, MdibDescriptionModifications descriptionModifications) throws PreprocessingException
Performs preprocessing, write operation and event distribution of description modifications.The write operation gains a write lock, downgrades it to a read lock during event distribution and releases the read lock by the end of the function.
- Parameters:
lockedWriteDescription- locked callback to finally write description.descriptionModifications- the description modifications to write.- Returns:
- a write description result that contains inserted, updated and deleted entities.
- Throws:
PreprocessingException- in case a consistency check or modifier fails.
-
writeStates
public WriteStateResult writeStates(Function<MdibStateModifications,WriteStateResult> lockedWriteStates, MdibStateModifications stateModifications) throws PreprocessingException
Performs preprocessing, write operation and event distribution of state modifications.The write operation gains a write lock, downgrades it to a read lock during event distribution and releases the read lock by the end of the function.
- Parameters:
lockedWriteStates- locked callback to finally write states.stateModifications- the state modifications to write.- Returns:
- a write state result that contains updated states.
- Throws:
PreprocessingException- in case a consistency check or modifier fails.
-
-