Class FetchData
public class FetchData extends Object
fetchData()
is
called on a FetchRequest
object.
Data returned from the RRD is, simply, just one big table filled with
timestamps and corresponding datasource values.
Use getRowCount()
method to count the number
of returned timestamps (table rows).
The first table column is filled with timestamps. Time intervals
between consecutive timestamps are guaranteed to be equal. Use
getTimestamps()
method to get an array of
timestamps returned.
Remaining columns are filled with datasource values for the whole timestamp range,
on a column-per-datasource basis. Use getColumnCount()
to find
the number of datasources and getValues(i)
method to obtain
all values for the i-th datasource. Returned datasource values correspond to
the values returned with getTimestamps()
method.
- Author:
- Sasa Markovic
-
Constructor Summary
Constructors Constructor Description FetchData(Archive matchingArchive, FetchRequest request)
-
Method Summary
Modifier and Type Method Description String
dump()
Dumps the content of the whole FetchData object.String
exportXml()
Dumps fetch data in XML format.void
exportXml(OutputStream outputStream)
Dumps fetch data to output stream in XML format.void
exportXml(String filepath)
Dumps fetch data to file in XML format.double
get95Percentile(String dsName)
Deprecated.This method is deprecated.double
getAggregate(String dsName, ConsolFun consolFun)
Deprecated.This method is deprecated.Aggregates
getAggregates(String dsName)
Deprecated.This method is deprecated.long
getArcEndTime()
Returns the timestamp of the last populated slot in the corresponding RRA archivelong
getArcStep()
Returns the step of the corresponding RRA archiveint
getColumnCount()
Returns the number of columns fetched from the corresponding RRD.int
getDsIndex(String dsName)
Retrieve the table index number of a datasource by name.String[]
getDsNames()
Returns array of datasource names found in the corresponding RRD.long
getFirstTimestamp()
Returns the first timestamp in this FetchData object.long
getLastTimestamp()
Returns the last timestamp in this FecthData object.Archive
getMatchingArchive()
Returns Archive object which is determined to be the best match for the timestamps specified in the fetch request.FetchRequest
getRequest()
ReturnsFetchRequest
object used to create this FetchData object.int
getRowCount()
Returns the number of rows fetched from the corresponding RRD.double
getRpn95Percentile(String rpnExpression)
Deprecated.This method is deprecated.double
getRpnAggregate(String rpnExpression, ConsolFun consolFun)
Deprecated.This method is deprecated.Aggregates
getRpnAggregates(String rpnExpression)
Deprecated.This method is deprecated.double[]
getRpnValues(String rpnExpression)
Returns a set of values created by applying RPN expression to the fetched data.long
getStep()
Returns the step with which this data was fetched.long[]
getTimestamps()
Returns an array of timestamps covering the whole range specified in theFetchReguest
object.double[][]
getValues()
Returns all archived values for all datasources.double[]
getValues(int dsIndex)
Returns all archived values for a single datasource.double[]
getValues(String dsName)
Returns all archived values for a single datasource.(package private) void
setTimestamps(long[] timestamps)
(package private) void
setValues(double[][] values)
String
toString()
Returns string representing fetched data in a RRDTool-like form.
-
Constructor Details
-
FetchData
- Throws:
IOException
-
-
Method Details
-
setTimestamps
void setTimestamps(long[] timestamps) -
setValues
void setValues(double[][] values) -
getRowCount
public int getRowCount()Returns the number of rows fetched from the corresponding RRD. Each row represents datasource values for the specific timestamp.- Returns:
- Number of rows.
-
getColumnCount
public int getColumnCount()Returns the number of columns fetched from the corresponding RRD. This number is always equal to the number of datasources defined in the RRD. Each column represents values of a single datasource.- Returns:
- Number of columns (datasources).
-
getTimestamps
public long[] getTimestamps()Returns an array of timestamps covering the whole range specified in theFetchReguest
object.- Returns:
- Array of equidistant timestamps.
-
getStep
public long getStep()Returns the step with which this data was fetched.- Returns:
- Step as long.
-
getValues
public double[] getValues(int dsIndex)Returns all archived values for a single datasource. Returned values correspond to timestamps returned withgetTimestamps()
method.- Parameters:
dsIndex
- Datasource index.- Returns:
- Array of single datasource values.
-
getValues
public double[][] getValues()Returns all archived values for all datasources. Returned values correspond to timestamps returned withgetTimestamps()
method.- Returns:
- Two-dimensional aray of all datasource values.
-
getValues
Returns all archived values for a single datasource. Returned values correspond to timestamps returned withgetTimestamps()
method.- Parameters:
dsName
- Datasource name.- Returns:
- Array of single datasource values.
-
getRpnValues
Returns a set of values created by applying RPN expression to the fetched data. For example, if you have two datasources namedx
andy
in this FetchData and you want to calculate values for(x+y)/2
use something like:getRpnValues("x,y,+,2,/");
- Parameters:
rpnExpression
- RRDTool-like RPN expression- Returns:
- Calculated values
- Throws:
IllegalArgumentException
- Thrown if invalid RPN expression is supplied
-
getRequest
ReturnsFetchRequest
object used to create this FetchData object.- Returns:
- Fetch request object.
-
getFirstTimestamp
public long getFirstTimestamp()Returns the first timestamp in this FetchData object.- Returns:
- The smallest timestamp.
-
getLastTimestamp
public long getLastTimestamp()Returns the last timestamp in this FecthData object.- Returns:
- The biggest timestamp.
-
getMatchingArchive
Returns Archive object which is determined to be the best match for the timestamps specified in the fetch request. All datasource values are obtained from round robin archives belonging to this archive.- Returns:
- Matching archive.
-
getDsNames
Returns array of datasource names found in the corresponding RRD. If the request was filtered (data was fetched only for selected datasources), only datasources selected for fetching are returned.- Returns:
- Array of datasource names.
-
getDsIndex
Retrieve the table index number of a datasource by name. Names are case sensitive.- Parameters:
dsName
- Name of the datasource for which to find the index.- Returns:
- Index number of the datasources in the value table.
-
dump
Dumps the content of the whole FetchData object. Useful for debugging.- Returns:
- a
String
containing the contents of this object, for debugging.
-
toString
Returns string representing fetched data in a RRDTool-like form. -
getAggregate
Deprecated.This method is deprecated. Uses instance ofVariable
, used withDataProcessor.addDatasource(String, String, Variable)
Returns single aggregated value from the fetched data for a single datasource.- Parameters:
dsName
- Datasource nameconsolFun
- 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 theConsolFun
class)- Returns:
- a double.
- Throws:
IllegalArgumentException
- Thrown if the given datasource name cannot be found in fetched data.
-
getRpnAggregate
Deprecated.This method is deprecated. Uses instance ofVariable
, used withDataProcessor.addDatasource(String, String, Variable)
Returns aggregated value for a set of values calculated by applying an RPN expression to the fetched data. For example, if you have two datasources namedx
andy
in this FetchData and you want to calculate MAX value of(x+y)/2
use something like:getRpnAggregate("x,y,+,2,/", "MAX");
- Parameters:
rpnExpression
- RRDTool-like RPN expressionconsolFun
- Consolidation function (MIN, MAX, LAST, FIRST, AVERAGE or TOTAL)- Returns:
- Aggregated value
- Throws:
IllegalArgumentException
- Thrown if invalid RPN expression is supplied
-
getAggregates
Deprecated.This method is deprecated. Uses instance ofVariable
, used withDataProcessor.addDatasource(String, String, Variable)
Returns all aggregated values (MIN, MAX, LAST, FIRST, AVERAGE or TOTAL) calculated from the fetched data for a single datasource.- Parameters:
dsName
- Datasource name.- Returns:
- Simple object containing all aggregated values.
- Throws:
IllegalArgumentException
- Thrown if the given datasource name cannot be found in the fetched data.
-
getRpnAggregates
Deprecated.This method is deprecated. Uses instance ofVariable
, used withDataProcessor.addDatasource(String, String, Variable)
Returns all aggregated values for a set of values calculated by applying an RPN expression to the fetched data. For example, if you have two datasources namedx
andy
in this FetchData and you want to calculate MIN, MAX, LAST, FIRST, AVERAGE and TOTAL value of(x+y)/2
use something like:getRpnAggregates("x,y,+,2,/");
- Parameters:
rpnExpression
- RRDTool-like RPN expression- Returns:
- Object containing all aggregated values
- Throws:
IllegalArgumentException
- Thrown if invalid RPN expression is suppliedIOException
- if any.
-
get95Percentile
Deprecated.This method is deprecated. Uses instance ofVariable.PERCENTILE
, used withDataProcessor.addDatasource(String, String, Variable)
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.
Read more about this topic at:
- Parameters:
dsName
- Datasource name- Returns:
- 95th percentile of fetched source values
- Throws:
IllegalArgumentException
- Thrown if invalid source name is supplied
-
getRpn95Percentile
Deprecated.This method is deprecated. Uses instance ofVariable.PERCENTILE
, used withDataProcessor.addDatasource(String, String, Variable)
Same asget95Percentile(String)
, but for a set of values calculated with the given RPN expression.- Parameters:
rpnExpression
- RRDTool-like RPN expression- Returns:
- 95-percentile
- Throws:
IllegalArgumentException
- Thrown if invalid RPN expression is supplied
-
exportXml
Dumps fetch data to output stream in XML format. A flush is issued at the end of the xml generation.- Parameters:
outputStream
- Output stream to dump fetch data to- Throws:
IOException
- Thrown in case of I/O error
-
exportXml
Dumps fetch data to file in XML format.- Parameters:
filepath
- Path to destination file- Throws:
IOException
- Thrown in case of I/O error
-
exportXml
Dumps fetch data in XML format.- Returns:
- String containing XML formatted fetch data
- Throws:
IOException
- Thrown in case of I/O error
-
getArcStep
public long getArcStep()Returns the step of the corresponding RRA archive- Returns:
- Archive step in seconds
-
getArcEndTime
public long getArcEndTime()Returns the timestamp of the last populated slot in the corresponding RRA archive- Returns:
- Timestamp in seconds
-