Class RemoteMdibAccessImpl
- java.lang.Object
-
- org.somda.sdc.biceps.consumer.access.RemoteMdibAccessImpl
-
- All Implemented Interfaces:
MdibAccess,MdibAccessObservable,ReadTransactionProvider,RemoteMdibAccess
public class RemoteMdibAccessImpl extends Object implements RemoteMdibAccess
Default implementation of RemoteMdibAccessImpl.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends AbstractContextState>
List<T>findContextStatesByType(Class<T> stateClass)Gets all context states of a specific type.<T extends AbstractDescriptor>
Collection<MdibEntity>findEntitiesByType(Class<T> type)Searches all entities that match a specific type.<T extends AbstractDescriptor>
List<MdibEntity>getChildrenByType(String handle, Class<T> type)Resolves the children of a specific type given a parent handle.List<AbstractContextState>getContextStates()Gets all context states.List<AbstractContextState>getContextStates(String descriptorHandle)Finds all context states of a certain descriptor.<T extends AbstractContextState>
List<T>getContextStates(String descriptorHandle, Class<T> stateClass)Finds all context states of a certain descriptor given a state class.Optional<AbstractDescriptor>getDescriptor(String handle)Retrieves a specific abstract descriptor of the hostedMdib.<T extends AbstractDescriptor>
Optional<T>getDescriptor(String handle, Class<T> descrClass)Retrieves a specific descriptor of the hostedMdib.Optional<MdibEntity>getEntity(String handle)Gets anMdibEntityobject with a specific handle.BigIntegergetMdDescriptionVersion()The latest known MD description version.MdibVersiongetMdibVersion()The latest known MDIB version.BigIntegergetMdStateVersion()The latest known MD description version.List<MdibEntity>getRootEntities()Gets allMdibEntityobjects that are root elements.Optional<AbstractState>getState(String handle)Retrieves a specific abstract state of the hostedMdib.<T extends AbstractState>
Optional<T>getState(String handle, Class<T> stateClass)Retrieves a specific state of the hostedMdib.voidregisterObserver(MdibAccessObserver observer)Register for MDIB modification reports.ReadTransactionstartTransaction()Starts a read transaction.voidunregisterObserver(MdibAccessObserver observer)Unregister from MDIB modification reports.WriteDescriptionResultwriteDescription(MdibVersion mdibVersion, BigInteger mdDescriptionVersion, BigInteger mdStateVersion, MdibDescriptionModifications mdibDescriptionModifications)Processes the description modifications object, stores the data internally and trigger an event.WriteStateResultwriteStates(MdibVersion mdibVersion, MdibStateModifications mdibStateModifications)Processes the state modifications object, stores the data internally and triggers an event.
-
-
-
Method Detail
-
writeDescription
public WriteDescriptionResult writeDescription(MdibVersion mdibVersion, @Nullable BigInteger mdDescriptionVersion, @Nullable BigInteger mdStateVersion, MdibDescriptionModifications mdibDescriptionModifications) throws PreprocessingException
Description copied from interface:RemoteMdibAccessProcesses the description modifications object, stores the data internally and trigger an event.Data is passed through if the elements of the modification change set do not violate the MDIB storage.
Attention: description modifications are expensive. Even if this operation allows to change states, it should only be used for changes that affect descriptors.
- Specified by:
writeDescriptionin interfaceRemoteMdibAccess- Parameters:
mdibVersion- the MDIB version to apply.mdDescriptionVersion- the MD description version to apply. Leave null if unknown.mdStateVersion- the MD state version to apply. Leave null if unknown.mdibDescriptionModifications- a set of insertions, updates and deletes.- Returns:
- a write result including inserted, updates and deleted entities.
- Throws:
PreprocessingException- if something goes wrong during preprocessing, i.e., the consistency of the MDIB would be violated.
-
writeStates
public WriteStateResult writeStates(MdibVersion mdibVersion, MdibStateModifications mdibStateModifications) throws PreprocessingException
Description copied from interface:RemoteMdibAccessProcesses the state modifications object, stores the data internally and triggers an event.Data is passed through if the elements of the modification change set do not violate the MDIB storage.
Hint: this function cheap in terms of runtime and should be used for state changes.
- Specified by:
writeStatesin interfaceRemoteMdibAccess- Parameters:
mdibVersion- the MDIB version to apply.mdibStateModifications- a set of state updates.- Returns:
- a write result including the updated entities.
- Throws:
PreprocessingException- if something goes wrong during preprocessing, i.e., the consistency of the MDIB would be violated.
-
registerObserver
public void registerObserver(MdibAccessObserver observer)
Description copied from interface:MdibAccessObservableRegister for MDIB modification reports.- Specified by:
registerObserverin interfaceMdibAccessObservable- Parameters:
observer- the observer to subscribe.
-
unregisterObserver
public void unregisterObserver(MdibAccessObserver observer)
Description copied from interface:MdibAccessObservableUnregister from MDIB modification reports.- Specified by:
unregisterObserverin interfaceMdibAccessObservable- Parameters:
observer- the observer to unsubscribe.
-
getMdibVersion
public MdibVersion getMdibVersion()
Description copied from interface:MdibAccessThe latest known MDIB version.This object returns the last known MDIB version which in case of remote access may not necessarily reflect the MDIB version of the whole MDIB. For local access the MDIB version reflects the latest state.
- Specified by:
getMdibVersionin interfaceMdibAccess- Returns:
- the latest known MDIB version.
-
getMdDescriptionVersion
public BigInteger getMdDescriptionVersion()
Description copied from interface:MdibAccessThe latest known MD description version.This object returns the last known MDIB version which in case of remote access may be outdated. For local access the MD description version reflects the latest state.
- Specified by:
getMdDescriptionVersionin interfaceMdibAccess- Returns:
- the latest known MD description version.
-
getMdStateVersion
public BigInteger getMdStateVersion()
Description copied from interface:MdibAccessThe latest known MD description version.This object returns the last known MDIB version which in case of remote access may be outdated. For local access the MD description version reflects the latest state.
- Specified by:
getMdStateVersionin interfaceMdibAccess- Returns:
- The latest known MD state version.
-
getDescriptor
public <T extends AbstractDescriptor> Optional<T> getDescriptor(String handle, Class<T> descrClass)
Description copied from interface:MdibAccessRetrieves a specific descriptor of the hostedMdib.- Specified by:
getDescriptorin interfaceMdibAccess- Type Parameters:
T- any descriptor type.- Parameters:
handle- Handle name of the descriptor.descrClass- Class to cast to. If cast fails,Optional.empty()will be returned.- Returns:
Optionalof the requested descriptor orOptional.empty()if not found or something went wrong.
-
getDescriptor
public Optional<AbstractDescriptor> getDescriptor(String handle)
Description copied from interface:MdibAccessRetrieves a specific abstract descriptor of the hostedMdib.- Specified by:
getDescriptorin interfaceMdibAccess- Parameters:
handle- Handle name of the descriptor.- Returns:
Optionalof the requested descriptor orOptional.empty()if not found or something went wrong.
-
getEntity
public Optional<MdibEntity> getEntity(String handle)
Description copied from interface:MdibAccessGets anMdibEntityobject with a specific handle.- Specified by:
getEntityin interfaceMdibAccess- Parameters:
handle- the handle to seek.- Returns:
- the entity of
Optional.empty()if not found.
-
getRootEntities
public List<MdibEntity> getRootEntities()
Description copied from interface:MdibAccessGets allMdibEntityobjects that are root elements.- Specified by:
getRootEntitiesin interfaceMdibAccess- Returns:
- the root elements, i.e., entities whose descriptors are of type
MdsDescriptor.
-
getState
public Optional<AbstractState> getState(String handle)
Description copied from interface:MdibAccessRetrieves a specific abstract state of the hostedMdib.- Specified by:
getStatein interfaceMdibAccess- Parameters:
handle- the state or descriptor handle of the state to request (descriptor handle is used in case of single states).- Returns:
Optionalof the requested state orOptional.empty()if not found or something went wrong.
-
getState
public <T extends AbstractState> Optional<T> getState(String handle, Class<T> stateClass)
Description copied from interface:MdibAccessRetrieves a specific state of the hostedMdib.- Specified by:
getStatein interfaceMdibAccess- Type Parameters:
T- any state type.- Parameters:
handle- the state or descriptor handle of the state to request (descriptor handle is used in case of single states).stateClass- the class to cast to. If cast fails,Optional.empty()will be returned.- Returns:
Optionalof the requested state orOptional.empty()if not found or something went wrong.
-
getContextStates
public <T extends AbstractContextState> List<T> getContextStates(String descriptorHandle, Class<T> stateClass)
Description copied from interface:MdibAccessFinds all context states of a certain descriptor given a state class.Attention: collections may be created on function call, hence be careful with performance issues.
- Specified by:
getContextStatesin interfaceMdibAccess- Type Parameters:
T- any context state type.- Parameters:
descriptorHandle- the descriptor handle to seek.stateClass- the class to filter for.- Returns:
- a list of the context states of
descriptorHandle.
-
getContextStates
public List<AbstractContextState> getContextStates(String descriptorHandle)
Description copied from interface:MdibAccessFinds all context states of a certain descriptor.Attention: collections may be created on function call, hence be careful with performance issues.
- Specified by:
getContextStatesin interfaceMdibAccess- Parameters:
descriptorHandle- the descriptor handle to seek.- Returns:
- a list of the context states of
descriptorHandle.
-
getContextStates
public List<AbstractContextState> getContextStates()
Description copied from interface:MdibAccessGets all context states.Attention: collections may be created on function call, hence be careful with performance issues.
- Specified by:
getContextStatesin interfaceMdibAccess- Returns:
- a list of all context states.
-
findContextStatesByType
public <T extends AbstractContextState> List<T> findContextStatesByType(Class<T> stateClass)
Description copied from interface:MdibAccessGets all context states of a specific type.Attention: collections may be created on function call, hence be careful with performance issues.
- Specified by:
findContextStatesByTypein interfaceMdibAccess- Type Parameters:
T- the type to filter for.- Parameters:
stateClass- the class information to filter for.- Returns:
- a list of all context states of the specific type.
-
findEntitiesByType
public <T extends AbstractDescriptor> Collection<MdibEntity> findEntitiesByType(Class<T> type)
Description copied from interface:MdibAccessSearches all entities that match a specific type.- Specified by:
findEntitiesByTypein interfaceMdibAccess- Type Parameters:
T- the descriptor type defined by the class.- Parameters:
type- the class to filter for.- Returns:
- a collection of entities where
typematches.
-
getChildrenByType
public <T extends AbstractDescriptor> List<MdibEntity> getChildrenByType(String handle, Class<T> type)
Description copied from interface:MdibAccessResolves the children of a specific type given a parent handle.- Specified by:
getChildrenByTypein interfaceMdibAccess- Type Parameters:
T- the descriptor type defined by the class.- Parameters:
handle- the parent handle of the entity.type- The class to filter for.- Returns:
- a list of children that matches
type(while preserving ordering).
-
startTransaction
public ReadTransaction startTransaction()
Description copied from interface:ReadTransactionProviderStarts a read transaction.Use the read transaction in an auto-closeable
try...block in order to ensure releasing the lock that is gained before this function returns.- Specified by:
startTransactionin interfaceReadTransactionProvider- Returns:
- a new locked MDIB access transaction to operate on (read-only).
-
-