Class AbstractPersister
- java.lang.Object
-
- org.opennms.netmgt.collection.support.AbstractCollectionSetVisitor
-
- org.opennms.netmgt.collection.api.AbstractPersister
-
- All Implemented Interfaces:
CollectionSetVisitor
,Persister
- Direct Known Subclasses:
AbstractEvaluatePersister
,BasePersister
,NewtsPersister
,TcpBasePersister
,TimeseriesPersister
public abstract class AbstractPersister extends AbstractCollectionSetVisitor implements Persister
Common persister code that performs the following: 1) Determines which attributes should be persisted. A stack is used to keep track of the "persist" flag for resources and groups as they are visited. 2) Delegates the persistence of numeric attributes viaPersistOperationBuilder
. Subclasses must callsetBuilder(org.opennms.netmgt.collection.api.PersistOperationBuilder)
with an implementation before any attributes are visited. 3) Delegates the persistence of string attributes via calls topersistStringAttribute(org.opennms.netmgt.model.ResourcePath, java.lang.String, java.lang.String)
.- Author:
- jwhite
-
-
Field Summary
Fields Modifier and Type Field Description protected static org.slf4j.Logger
LOG
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractPersister(ServiceParameters params, RrdRepository repository)
Constructor for BasePersister.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
commitBuilder()
commitBuildervoid
completeAttribute(CollectionAttribute attribute)
completeAttributevoid
completeGroup(AttributeGroup group)
completeGroupvoid
completeResource(CollectionResource resource)
completeResourceRrdRepository
getRepository()
getRepositoryboolean
isIgnorePersist()
isIgnorePersistvoid
persistNumericAttribute(CollectionAttribute attribute)
persistNumericAttributevoid
persistStringAttribute(CollectionAttribute attribute)
persistStringAttributeprotected abstract void
persistStringAttribute(ResourcePath path, java.lang.String key, java.lang.String value)
boolean
popShouldPersist()
popShouldPersistprotected void
pushShouldPersist(AttributeGroup group)
pushShouldPersistvoid
pushShouldPersist(CollectionAttribute attribute)
pushShouldPersistvoid
pushShouldPersist(CollectionResource resource)
PushCollectionResource
instances directly onto the stack without checkingtop()
since they are the top-level resources.protected void
setBuilder(PersistOperationBuilder builder)
void
setIgnorePersist(boolean ignore)
setIgnorePersistvoid
setRepository(RrdRepository repository)
setRepositoryprotected boolean
shouldPersist()
shouldPersistvoid
storeAttribute(CollectionAttribute attribute)
storeAttributevoid
visitAttribute(CollectionAttribute attribute)
visitAttributevoid
visitGroup(AttributeGroup group)
visitGroupvoid
visitResource(CollectionResource resource)
visitResource-
Methods inherited from class org.opennms.netmgt.collection.support.AbstractCollectionSetVisitor
completeCollectionSet, visitCollectionSet
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.opennms.netmgt.collection.api.CollectionSetVisitor
completeCollectionSet, visitCollectionSet
-
-
-
-
Constructor Detail
-
AbstractPersister
protected AbstractPersister(ServiceParameters params, RrdRepository repository)
Constructor for BasePersister.
- Parameters:
params
- aServiceParameters
object.repository
- aRrdRepository
object.
-
-
Method Detail
-
persistStringAttribute
protected abstract void persistStringAttribute(ResourcePath path, java.lang.String key, java.lang.String value) throws PersistException
- Throws:
PersistException
-
commitBuilder
public void commitBuilder()
commitBuilder
-
completeAttribute
public void completeAttribute(CollectionAttribute attribute)
completeAttribute
- Specified by:
completeAttribute
in interfaceCollectionSetVisitor
- Overrides:
completeAttribute
in classAbstractCollectionSetVisitor
- Parameters:
attribute
- aorg.opennms.netmgt.collection.api.collectd.CollectionAttribute
object.
-
completeGroup
public void completeGroup(AttributeGroup group)
completeGroup
- Specified by:
completeGroup
in interfaceCollectionSetVisitor
- Overrides:
completeGroup
in classAbstractCollectionSetVisitor
- Parameters:
group
- aorg.opennms.netmgt.collectd.AttributeGroup
object.
-
completeResource
public void completeResource(CollectionResource resource)
completeResource
- Specified by:
completeResource
in interfaceCollectionSetVisitor
- Overrides:
completeResource
in classAbstractCollectionSetVisitor
- Parameters:
resource
- aCollectionResource
object.
-
getRepository
public RrdRepository getRepository()
getRepository
- Returns:
- a
RrdRepository
object.
-
setRepository
public void setRepository(RrdRepository repository)
setRepository
- Parameters:
repository
- aRrdRepository
object.
-
persistNumericAttribute
public void persistNumericAttribute(CollectionAttribute attribute)
persistNumericAttribute
- Specified by:
persistNumericAttribute
in interfacePersister
- Parameters:
attribute
- aCollectionAttribute
object.
-
persistStringAttribute
public void persistStringAttribute(CollectionAttribute attribute)
persistStringAttribute
- Specified by:
persistStringAttribute
in interfacePersister
- Parameters:
attribute
- aCollectionAttribute
object.
-
popShouldPersist
public boolean popShouldPersist()
popShouldPersist
- Returns:
- a boolean.
-
pushShouldPersist
public void pushShouldPersist(CollectionAttribute attribute)
pushShouldPersist
- Parameters:
attribute
- aCollectionAttribute
object.
-
pushShouldPersist
protected void pushShouldPersist(AttributeGroup group)
pushShouldPersist
- Parameters:
group
- aAttributeGroup
object.
-
pushShouldPersist
public void pushShouldPersist(CollectionResource resource)
PushCollectionResource
instances directly onto the stack without checkingtop()
since they are the top-level resources.- Parameters:
resource
- aCollectionResource
object.
-
shouldPersist
protected boolean shouldPersist()
shouldPersist
- Returns:
- a boolean.
-
storeAttribute
public void storeAttribute(CollectionAttribute attribute)
storeAttribute
- Parameters:
attribute
- aCollectionAttribute
object.
-
visitAttribute
public void visitAttribute(CollectionAttribute attribute)
visitAttribute
- Specified by:
visitAttribute
in interfaceCollectionSetVisitor
- Overrides:
visitAttribute
in classAbstractCollectionSetVisitor
- Parameters:
attribute
- aorg.opennms.netmgt.collection.api.collectd.CollectionAttribute
object.
-
visitGroup
public void visitGroup(AttributeGroup group)
visitGroup
- Specified by:
visitGroup
in interfaceCollectionSetVisitor
- Overrides:
visitGroup
in classAbstractCollectionSetVisitor
- Parameters:
group
- aorg.opennms.netmgt.collectd.AttributeGroup
object.
-
visitResource
public void visitResource(CollectionResource resource)
visitResource
- Specified by:
visitResource
in interfaceCollectionSetVisitor
- Overrides:
visitResource
in classAbstractCollectionSetVisitor
- Parameters:
resource
- aCollectionResource
object.
-
isIgnorePersist
public boolean isIgnorePersist()
isIgnorePersist
- Returns:
- a boolean.
-
setIgnorePersist
public void setIgnorePersist(boolean ignore)
setIgnorePersist
- Parameters:
ignore
- a boolean.
-
setBuilder
protected void setBuilder(PersistOperationBuilder builder)
-
-