Package org.opennms.netmgt.dao.support
Class FilesystemResourceStorageDao
- java.lang.Object
-
- org.opennms.netmgt.dao.support.FilesystemResourceStorageDao
-
- All Implemented Interfaces:
ResourceStorageDao,org.springframework.beans.factory.InitializingBean
public class FilesystemResourceStorageDao extends Object implements ResourceStorageDao, org.springframework.beans.factory.InitializingBean
Used in conjunction with RRD/JRB strategies that persist metrics to the local disk.- Author:
- jwhite
-
-
Constructor Summary
Constructors Constructor Description FilesystemResourceStorageDao()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterPropertiesSet()Set<ResourcePath>children(ResourcePath path, int depth)Retrieves the set of child paths one level bellow the given path which contain one or more metrics at the given depth.booleandelete(ResourcePath path)Deletes all of the resources and metric bellow the given path.booleanexists(ResourcePath path, int depth)Verifies if a path contains one or more metrics at the given depth.booleanexistsWithin(ResourcePath path, int depth)Verifies if a path contains one or more metrics within the given depth.Set<OnmsAttribute>getAttributes(ResourcePath path)Retrieves the set of (resource-level) attributes stored at the given path.Map<String,String>getMetaData(ResourcePath path)Retrieves the meta-data stored at the given path.FilegetRrdDirectory()StringgetStringAttribute(ResourcePath path, String key)Returns the value for the given (resource-level) attribute, or null if it does not exist.Map<String,String>getStringAttributes(ResourcePath path)Returns the value for the given (resource-level) attribute, or null if it does not exist.voidsetRrdDirectory(File rrdDirectory)voidsetRrdExtension(String rrdExtension)voidsetRrdStrategy(RrdStrategy<?,?> rrdStrategy)voidsetStringAttribute(ResourcePath path, String key, String value)Sets the specified (resource-level) attribute at the given path.voidupdateMetricToResourceMappings(ResourcePath path, Map<String,String> metricsNameToResourceNames)Maps the given metric names to the their associated resources names.
-
-
-
Method Detail
-
afterPropertiesSet
public void afterPropertiesSet() throws Exception- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
Exception
-
exists
public boolean exists(ResourcePath path, int depth)
Description copied from interface:ResourceStorageDaoVerifies if a path contains one or more metrics at the given depth.For example, assume we are working with file-system paths, and we have the following file on disk /a/b/c/some.metric. The function should behave as follows:
- exists('/a/b/c', 0) -> true
- exists('/a/b', 1) -> true
- exists('/a/b', 2) -> false
- Specified by:
existsin interfaceResourceStorageDao- Parameters:
path- resource path used as the root of the checkdepth- a non-negative integer- Returns:
- true if one or more metrics exist, false otherwise
-
existsWithin
public boolean existsWithin(ResourcePath path, int depth)
Description copied from interface:ResourceStorageDaoVerifies if a path contains one or more metrics within the given depth.For example, assume we are working with file-system paths, and we have the following file on disk /a/b/c/some.metric. The function should behave as follows:
- exists('/a/b/c', 0) -> true
- exists('/a/b', 1) -> true
- exists('/a/b', 2) -> true
- exists('/a', 1) -> false
- Specified by:
existsWithinin interfaceResourceStorageDao- Parameters:
path- resource path used as the root of the checkdepth- a non-negative integer- Returns:
- true if one or more metrics exist, false otherwise
-
children
public Set<ResourcePath> children(ResourcePath path, int depth)
Description copied from interface:ResourceStorageDaoRetrieves the set of child paths one level bellow the given path which contain one or more metrics at the given depth.For example, assume we are working with file-system paths, and we have the following file on disk /a/b/c/some.metric. The function should behave as follows:
- children('/a/b', 1) -> {'/a/b/c'}
- children('/a/b', 2) -> {}
- children('/a', 2) -> {'b'}
- Specified by:
childrenin interfaceResourceStorageDao- Parameters:
path- resource path used as the root of the checkdepth- a positive integer- Returns:
- the set of child paths containing metrics
-
getAttributes
public Set<OnmsAttribute> getAttributes(ResourcePath path)
Description copied from interface:ResourceStorageDaoRetrieves the set of (resource-level) attributes stored at the given path.- Specified by:
getAttributesin interfaceResourceStorageDao
-
setStringAttribute
public void setStringAttribute(ResourcePath path, String key, String value)
Description copied from interface:ResourceStorageDaoSets the specified (resource-level) attribute at the given path. Should not be called directly but only through the BasePersister.- Specified by:
setStringAttributein interfaceResourceStorageDao
-
getStringAttribute
public String getStringAttribute(ResourcePath path, String key)
Description copied from interface:ResourceStorageDaoReturns the value for the given (resource-level) attribute, or null if it does not exist.- Specified by:
getStringAttributein interfaceResourceStorageDao
-
getStringAttributes
public Map<String,String> getStringAttributes(ResourcePath path)
Description copied from interface:ResourceStorageDaoReturns the value for the given (resource-level) attribute, or null if it does not exist.- Specified by:
getStringAttributesin interfaceResourceStorageDao
-
updateMetricToResourceMappings
public void updateMetricToResourceMappings(ResourcePath path, Map<String,String> metricsNameToResourceNames)
Description copied from interface:ResourceStorageDaoMaps the given metric names to the their associated resources names. The resource names are relative to the given path. When persisting to .rrd of .jrb files with storeByGroup enabled, this is used to map the data sources names (metrics) to associated .rrd files (resource names). Other strategies that can infer this information at runtime may chose to ignore calls to this method.- Specified by:
updateMetricToResourceMappingsin interfaceResourceStorageDao- Parameters:
path- parent resource pathmetricsNameToResourceNames- metric to resource mappings
-
getMetaData
public Map<String,String> getMetaData(ResourcePath path)
Description copied from interface:ResourceStorageDaoRetrieves the meta-data stored at the given path.- Specified by:
getMetaDatain interfaceResourceStorageDao
-
delete
public boolean delete(ResourcePath path)
Description copied from interface:ResourceStorageDaoDeletes all of the resources and metric bellow the given path. Returns true if the operation succeeded.- Specified by:
deletein interfaceResourceStorageDao
-
setRrdDirectory
public void setRrdDirectory(File rrdDirectory)
-
getRrdDirectory
public File getRrdDirectory()
-
setRrdStrategy
public void setRrdStrategy(RrdStrategy<?,?> rrdStrategy)
-
setRrdExtension
public void setRrdExtension(String rrdExtension)
-
-