java.lang.Object | |
↳ | org.rrd4j.data.DataProcessor |
Class which should be used for all calculations based on the data fetched from RRD files. This class
supports ordinary DEF datasources (defined in RRD files), CDEF datasources (RPN expressions evaluation),
SDEF (static datasources - extension of Rrd4j) and PDEF (plottables, see
Plottable
for more information.
Typical class usage:
final long t1 = ... final long t2 = ... DataProcessor dp = new DataProcessor(t1, t2); // DEF datasource dp.addDatasource("x", "demo.rrd", "some_source", "AVERAGE"); // DEF datasource dp.addDatasource("y", "demo.rrd", "some_other_source", "AVERAGE"); // CDEF datasource, z = (x + y) / 2 dp.addDatasource("z", "x,y,+,2,/"); // ACTION! dp.processData(); // Dump calculated values System.out.println(dp.dump());
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | DEFAULT_PIXEL_COUNT | Constant representing the default number of pixels on a Rrd4j graph (will be used if
no other value is specified with setStep() method. |
|||||||||
boolean | DEFAULT_POOL_USAGE_POLICY | Constant that defines the default RrdDbPool usage policy. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates new DataProcessor object for the given time span.
| |||||||||||
Creates new DataProcessor object for the given time span.
| |||||||||||
Creates new DataProcessor object for the given time span.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Adds a custom, | |||||||||||
Adds simple datasource (DEF). | |||||||||||
Adds static source (SDEF). | |||||||||||
Adds simple source (DEF). | |||||||||||
Adds DEF datasource with datasource values already available in the FetchData object.
| |||||||||||
Adds complex source (CDEF). | |||||||||||
Dumps timestamps and values of all datasources in a tabelar form.
| |||||||||||
This method is just an alias for
getPercentile(String) method. | |||||||||||
Returns single aggregated value for a single datasource.
| |||||||||||
Returns all (MIN, MAX, LAST, FIRST, AVERAGE and TOTAL) aggregated values for a single datasource.
| |||||||||||
Returns ending timestamp.
| |||||||||||
Returns desired RRD archive step (resolution) in seconds to be used while fetching data
from RRD files.
| |||||||||||
Returns time when last RRD archive was updated (all RRD files are considered).
| |||||||||||
The same as
getPercentile(String) but with a possibility to define custom percentile boundary
(different from 95). | |||||||||||
Used by ISPs which charge for bandwidth utilization on a "95th percentile" basis.
| |||||||||||
Returns the number of pixels (target graph width).
| |||||||||||
Returns array of datasource names defined in this DataProcessor.
| |||||||||||
Returns the time step used for data processing.
| |||||||||||
Returns consolidated timestamps created with the
processData() method. | |||||||||||
Calculates timestamps which correspond to individual pixels on the graph
based on the graph width set with a
setPixelCount(int) method call. | |||||||||||
Calculates timestamps which correspond to individual pixels on the graph.
| |||||||||||
Returns calculated values for a single datasource.
| |||||||||||
Returns an array of all datasource values for all datasources.
| |||||||||||
Method used to calculate datasource values which should be presented on the graph
based on the graph width set with a
setPixelCount(int) method call. | |||||||||||
Method used to calculate datasource values which should be presented on the graph
based on the desired graph width.
| |||||||||||
Returns boolean value representing
RrdDbPool usage policy. | |||||||||||
Cute little demo.
| |||||||||||
Method that should be called once all datasources are defined.
| |||||||||||
Sets desired RRD archive step in seconds to be used internally while fetching data
from RRD files.
| |||||||||||
Sets the number of pixels (target graph width).
| |||||||||||
Sets the
RrdDbPool usage policy. | |||||||||||
Roughly corresponds to the --step option in RRDTool's graph/xport commands.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Constant representing the default number of pixels on a Rrd4j graph (will be used if
no other value is specified with setStep()
method.
Constant that defines the default RrdDbPool
usage policy. Defaults to false
(i.e. the pool will not be used to fetch data from RRD files)
Creates new DataProcessor object for the given time span. Ending timestamp may be set to zero.
In that case, the class will try to find the optimal ending timestamp based on the last update time of
RRD files processed with the processData()
method.
t1 | Starting timestamp in seconds without milliseconds |
---|---|
t2 | Ending timestamp in seconds without milliseconds |
Creates new DataProcessor object for the given time span. Ending date may be set to null.
In that case, the class will try to find optimal ending date based on the last update time of
RRD files processed with the processData()
method.
d1 | Starting date |
---|---|
d2 | Ending date |
Creates new DataProcessor object for the given time span. Ending date may be set to null.
In that case, the class will try to find optimal ending date based on the last update time of
RRD files processed with the processData()
method.
gc1 | Starting Calendar date |
---|---|
gc2 | Ending Calendar date |
Adds simple datasource (DEF). Simple source name
can be used:
name | source name. |
---|---|
file | Path to RRD file. |
dsName | Datasource name defined in the RRD file. |
consolFunc | Consolidation function that will be used to extract data from the RRD |
Adds static source (SDEF). Static sources are the result of a consolidation function applied to *any* other source that has been defined previously.
name | source name. |
---|---|
defName | Name of the datasource to calculate the value from. |
consolFun | Consolidation function to use for value calculation |
Adds simple source (DEF). Source name
can be used:
name | Source name. |
---|---|
file | Path to RRD file. |
dsName | Data source name defined in the RRD file. |
consolFunc | Consolidation function that will be used to extract data from the RRD
file ("AVERAGE", "MIN", "MAX" or "LAST" - these string constants are conveniently defined
in the ConsolFun class). |
backend | Name of the RrdBackendFactory that should be used for this RrdDb. |
Adds DEF datasource with datasource values already available in the FetchData object. This method is used internally by Rrd4j and probably has no purpose outside of it.
name | Source name. |
---|---|
fetchData | Fetched data containing values for the given source name. |
Adds complex source (CDEF).
Complex sources are evaluated using the supplied RPN
expression.
Complex source name
can be used:
Rrd4j supports the following RPN functions, operators and constants: +, -, *, /, %, SIN, COS, LOG, EXP, FLOOR, CEIL, ROUND, POW, ABS, SQRT, RANDOM, LT, LE, GT, GE, EQ, IF, MIN, MAX, LIMIT, DUP, EXC, POP, UN, UNKN, NOW, TIME, PI, E, AND, OR, XOR, PREV, PREV(sourceName), INF, NEGINF, STEP, YEAR, MONTH, DATE, HOUR, MINUTE, SECOND, WEEK, SIGN and RND.
Rrd4j does not force you to specify at least one simple source name as RRDTool.
For more details on RPN see RRDTool's rrdgraph man page.
name | source name. |
---|---|
rpnExpression | RPN expression containig comma (or space) delimited simple and complex source names, RPN constants, functions and operators. |
Dumps timestamps and values of all datasources in a tabelar form. Very useful for debugging.
This method is just an alias for getPercentile(String)
method.
Used by ISPs which charge for bandwidth utilization on a "95th percentile" basis.
The 95th percentile is the highest source value left when the top 5% of a numerically sorted set of source data is discarded. It is used as a measure of the peak value used when one discounts a fair amount for transitory spikes. This makes it markedly different from the average.
sourceName | Datasource name |
---|
Returns single aggregated value for a single datasource.
sourceName | Datasource name |
---|---|
consolFun | Consolidation function to be applied to fetched datasource values.
Valid consolidation functions are MIN, MAX, LAST, FIRST, AVERAGE and TOTAL
(these string constants are conveniently defined in the ConsolFun class) |
IllegalArgumentException | Thrown if invalid datasource name is specified,
or if datasource values are not yet calculated (method processData()
was not called)
|
---|
Returns all (MIN, MAX, LAST, FIRST, AVERAGE and TOTAL) aggregated values for a single datasource.
sourceName | Datasource name |
---|
IllegalArgumentException | Thrown if invalid datasource name is specified,
or if datasource values are not yet calculated (method processData()
was not called)
|
---|
Returns ending timestamp. Basically, this value is equal to the ending timestamp
specified in the constructor. However, if the ending timestamps was zero, it
will be replaced with the real timestamp when the processData()
method returns. The real
value will be calculated from the last update times of processed RRD files.
Returns desired RRD archive step (resolution) in seconds to be used while fetching data
from RRD files. In other words, this value will used as the last parameter of
RrdDb.createFetchRequest()
method
when this method is called internally by this DataProcessor.
Returns time when last RRD archive was updated (all RRD files are considered).
The same as getPercentile(String)
but with a possibility to define custom percentile boundary
(different from 95).
sourceName | Datasource name. |
---|---|
percentile | Boundary percentile. Value of 95 (%) is suitable in most cases, but you are free to provide your own percentile boundary between zero and 100. |
Used by ISPs which charge for bandwidth utilization on a "95th percentile" basis.
The 95th percentile is the highest source value left when the top 5% of a numerically sorted set of source data is discarded. It is used as a measure of the peak value used when one discounts a fair amount for transitory spikes. This makes it markedly different from the average.
sourceName | Datasource name |
---|
Returns the number of pixels (target graph width). See setPixelCount(int)
for more information.
Returns array of datasource names defined in this DataProcessor.
Returns the time step used for data processing. Initially, this method returns zero.
Once processData()
is finished, the method will return the real value used for
all internal computations. Roughly corresponds to the --step option in RRDTool's graph/xport commands.
Returns consolidated timestamps created with the processData()
method.
Calculates timestamps which correspond to individual pixels on the graph
based on the graph width set with a setPixelCount(int)
method call.
Calculates timestamps which correspond to individual pixels on the graph.
pixelCount | Graph width |
---|
Returns calculated values for a single datasource. Corresponding timestamps can be obtained from
the getTimestamps()
method.
sourceName | Datasource name |
---|
IllegalArgumentException | Thrown if invalid datasource name is specified,
or if datasource values are not yet calculated (method processData()
was not called)
|
---|
Returns an array of all datasource values for all datasources. Each row in this two-dimensional array represents an array of calculated values for a single datasource. The order of rows is the same as the order in which datasources were added to this DataProcessor object.
getTimestamps()
method.IllegalArgumentException | Thrown if invalid datasource name is specified,
or if datasource values are not yet calculated (method processData()
was not called)
|
---|
Method used to calculate datasource values which should be presented on the graph
based on the graph width set with a setPixelCount(int)
method call.
Each value returned represents a single pixel on the graph. Corresponding timestamp can be
found in the array returned from getTimestampsPerPixel()
method.
sourceName | Datasource name |
---|
IllegalArgumentException | Thrown if datasource values are not yet calculated (method processData()
was not called)
|
---|
Method used to calculate datasource values which should be presented on the graph
based on the desired graph width. Each value returned represents a single pixel on the graph.
Corresponding timestamp can be found in the array returned from getTimestampsPerPixel()
method.
sourceName | Datasource name |
---|---|
pixelCount | Graph width |
IllegalArgumentException | Thrown if datasource values are not yet calculated (method processData()
was not called)
|
---|
Returns boolean value representing RrdDbPool
usage policy.
Cute little demo. Uses demo.rrd file previously created by basic Rrd4j demo.
args | Not used |
---|
IOException |
---|
Method that should be called once all datasources are defined. Data will be fetched from RRD files, RPN expressions will be calculated, etc.
IOException | Thrown in case of I/O error (while fetching data from RRD files) |
---|
Sets desired RRD archive step in seconds to be used internally while fetching data
from RRD files. In other words, this value will used as the last parameter of
RrdDb.createFetchRequest()
method
when this method is called internally by this DataProcessor. If this method is never called, fetch
request resolution defaults to 1 (smallest possible archive step will be chosen automatically).
fetchRequestResolution | Desired archive step (fetch resoltuion) in seconds. |
---|
Sets the number of pixels (target graph width). This number is used only to calculate pixel coordinates
for Rrd4j graphs (methods getValuesPerPixel(String)
and getTimestampsPerPixel()
),
but has influence neither on datasource values calculated with the
processData()
method nor on aggregated values returned from getAggregates(String)
and similar methods. In other words, aggregated values will not change once you decide to change
the dimension of your graph.
The default number of pixels is defined by constant DEFAULT_PIXEL_COUNT
and can be changed with a setPixelCount(int)
method.
pixelCount | The number of pixels. If you process RRD data in order to display it on the graph, this should be the width of your graph. |
---|
Sets the RrdDbPool
usage policy.
poolUsed | true, if the pool should be used to fetch data from RRD files, false otherwise. |
---|
Roughly corresponds to the --step option in RRDTool's graph/xport commands. Here is an explanation borrowed from RRDTool:
"By default rrdgraph calculates the width of one pixel in the time domain and tries to get data at that resolution from the RRD. With this switch you can override this behavior. If you want rrdgraph to get data at 1 hour resolution from the RRD, then you can set the step to 3600 seconds. Note, that a step smaller than 1 pixel will be silently ignored."
I think this option is not that useful, but it's here just for compatibility.
step | Time step at which data should be fetched from RRD files. If this method is not used, the step will be equal to the smallest RRD step of all processed RRD files. If no RRD file is processed, the step will be roughly equal to the with of one graph pixel (in seconds). |
---|