Class TimeseriesResourceStorageDao
- java.lang.Object
-
- org.opennms.netmgt.timeseries.resource.TimeseriesResourceStorageDao
-
- All Implemented Interfaces:
ResourceStorageDao
public class TimeseriesResourceStorageDao extends java.lang.Object implements ResourceStorageDao
Resource Storage Dao implementation for Timeseries Integration Layer that leverages the Search API for walking the resource tree. In Timeseries Integration Layer, samples are associated with metrics, which are in turn associated with resources. Here we split the resource id into two parts: bucket: last element of the resource id resource path: all the elements before the bucket Relating this to .rrd file on disk, the bucket would be the filename, and the resource path would be its folder.
-
-
Constructor Summary
Constructors Constructor Description TimeseriesResourceStorageDao()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.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.boolean
delete(ResourcePath path)
Deletes all of the resources and metric bellow the given path.boolean
exists(ResourcePath path, int depth)
Verifies if a path contains one or more metrics at the given depth.boolean
existsWithin(ResourcePath path, int depth)
Verifies if a path contains one or more metrics within the given depth.java.util.Set<OnmsAttribute>
getAttributes(ResourcePath path)
Retrieves the set of (resource-level) attributes stored at the given path.java.util.Map<java.lang.String,java.lang.String>
getMetaData(ResourcePath path)
Retrieves the meta-data stored at the given path.java.lang.String
getStringAttribute(ResourcePath path, java.lang.String key)
Returns the value for the given (resource-level) attribute, or null if it does not exist.java.util.Map<java.lang.String,java.lang.String>
getStringAttributes(ResourcePath path)
Returns the value for the given (resource-level) attribute, or null if it does not exist.void
setSearcher(TimeseriesSearcher searcher)
void
setStringAttribute(ResourcePath path, java.lang.String key, java.lang.String value)
Sets the specified (resource-level) attribute at the given path.void
setWriter(TimeseriesWriter writer)
protected static ResourcePath
toChildResourcePath(ResourcePath parent, java.lang.String resourceId)
void
updateMetricToResourceMappings(ResourcePath path, java.util.Map<java.lang.String,java.lang.String> metricsNameToResourceNames)
Maps the given metric names to the their associated resources names.
-
-
-
Method Detail
-
exists
public boolean exists(ResourcePath path, int depth)
Description copied from interface:ResourceStorageDao
Verifies 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:
exists
in 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:ResourceStorageDao
Verifies 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:
existsWithin
in 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 java.util.Set<ResourcePath> children(ResourcePath path, int depth)
Description copied from interface:ResourceStorageDao
Retrieves 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:
children
in interfaceResourceStorageDao
- Parameters:
path
- resource path used as the root of the checkdepth
- a positive integer- Returns:
- the set of child paths containing metrics
-
delete
public boolean delete(ResourcePath path)
Description copied from interface:ResourceStorageDao
Deletes all of the resources and metric bellow the given path. Returns true if the operation succeeded.- Specified by:
delete
in interfaceResourceStorageDao
-
getAttributes
public java.util.Set<OnmsAttribute> getAttributes(ResourcePath path)
Description copied from interface:ResourceStorageDao
Retrieves the set of (resource-level) attributes stored at the given path.- Specified by:
getAttributes
in interfaceResourceStorageDao
-
setStringAttribute
public void setStringAttribute(ResourcePath path, java.lang.String key, java.lang.String value)
Description copied from interface:ResourceStorageDao
Sets the specified (resource-level) attribute at the given path.- Specified by:
setStringAttribute
in interfaceResourceStorageDao
-
getStringAttribute
public java.lang.String getStringAttribute(ResourcePath path, java.lang.String key)
Description copied from interface:ResourceStorageDao
Returns the value for the given (resource-level) attribute, or null if it does not exist.- Specified by:
getStringAttribute
in interfaceResourceStorageDao
-
getStringAttributes
public java.util.Map<java.lang.String,java.lang.String> getStringAttributes(ResourcePath path)
Description copied from interface:ResourceStorageDao
Returns the value for the given (resource-level) attribute, or null if it does not exist.- Specified by:
getStringAttributes
in interfaceResourceStorageDao
-
getMetaData
public java.util.Map<java.lang.String,java.lang.String> getMetaData(ResourcePath path)
Description copied from interface:ResourceStorageDao
Retrieves the meta-data stored at the given path.- Specified by:
getMetaData
in interfaceResourceStorageDao
-
updateMetricToResourceMappings
public void updateMetricToResourceMappings(ResourcePath path, java.util.Map<java.lang.String,java.lang.String> metricsNameToResourceNames)
Description copied from interface:ResourceStorageDao
Maps 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:
updateMetricToResourceMappings
in interfaceResourceStorageDao
- Parameters:
path
- parent resource pathmetricsNameToResourceNames
- metric to resource mappings
-
toChildResourcePath
protected static ResourcePath toChildResourcePath(ResourcePath parent, java.lang.String resourceId)
-
setWriter
public void setWriter(TimeseriesWriter writer)
-
setSearcher
public void setSearcher(TimeseriesSearcher searcher)
-
-