public class Sample extends Object
To update a RRD with JRobin use the following procedure:
createSample()
on respective RrdDb
object.
setTime()
method).
setValue()
).
update()
method.
Newly created Sample object contains all data source values set to 'unknown'.
You should specifify only 'known' data source values. However, if you want to specify
'unknown' values too, use Double.NaN
.
Modifier and Type | Method and Description |
---|---|
String |
dump()
Dumps sample content using the syntax of RRDTool's update command.
|
String[] |
getDsNames()
Returns an array of all data source names.
|
(package private) String |
getRrdToolCommand() |
long |
getTime()
Returns sample timestamp (in seconds, without milliseconds).
|
double[] |
getValues()
Returns all current data source values in the sample.
|
Sample |
set(String timeAndValues)
Sets sample timestamp and data source values in a fashion similar to RRDTool.
|
void |
setAndUpdate(String timeAndValues)
Creates sample with the timestamp and data source values supplied
in the argument string and stores sample in the corresponding RRD.
|
Sample |
setTime(long time)
Sets sample timestamp.
|
Sample |
setValue(int i,
double value)
Sets single datasource value using data source index.
|
Sample |
setValue(String dsName,
double value)
Sets single data source value in the sample.
|
Sample |
setValues(double[] values)
Sets some (possibly all) data source values in bulk.
|
String |
toString() |
void |
update()
Stores sample in the corresponding RRD.
|
Sample(RrdDb parentDb, long time) throws IOException
IOException
public Sample setValue(String dsName, double value) throws RrdException
dsName
- Data source name.value
- Data source value.Sample
objectRrdException
- Thrown if invalid data source name is supplied.public Sample setValue(int i, double value) throws RrdException
i
- Data source indexvalue
- Data source valuesSample
objectRrdException
- Thrown if data source index is invalid.public Sample setValues(double[] values) throws RrdException
values
- Data source values.Sample
objectRrdException
- Thrown if the number of supplied values is zero or greater
than the number of data sources defined in the RRD.public double[] getValues()
public long getTime()
public Sample setTime(long time)
time
- New sample timestamp.Sample
objectpublic String[] getDsNames()
public Sample set(String timeAndValues) throws RrdException
timestamp:value1:value2:...:valueN
.
You don't have to supply all datasource values. Unspecified values will be treated as unknowns. To specify unknown value in the argument string, use letter 'U'.
timeAndValues
- String made by concatenating sample timestamp with corresponding
data source values delmited with colons. For example:
1005234132:12.2:35.6:U:24.5 NOW:12.2:35.6:U:24.5'N' stands for the current timestamp (can be replaced with 'NOW')
Method will throw an exception if timestamp is invalid (cannot be parsed as Long, and is not 'N' or 'NOW'). Datasource value which cannot be parsed as 'double' will be silently set to NaN.
Sample
objectRrdException
- Thrown if too many datasource values are suppliedpublic void update() throws IOException, RrdException
IOException
- Thrown in case of I/O error.RrdException
- Thrown in case of JRobin related error.public void setAndUpdate(String timeAndValues) throws IOException, RrdException
Creates sample with the timestamp and data source values supplied in the argument string and stores sample in the corresponding RRD. This method is just a shortcut for:
set(timeAndValues); update();
timeAndValues
- String made by concatenating sample timestamp with corresponding
data source values delmited with colons. For example:1005234132:12.2:35.6:U:24.5
NOW:12.2:35.6:U:24.5
IOException
- Thrown in case of I/O error.RrdException
- Thrown in case of JRobin related error.public String dump()
String getRrdToolCommand()