public class RrdDef extends Object
RrdDb constructor argument
(see documentation for RrdDb class). RrdDef object
does not actually create new RRD. It just holds all necessary information which will be
used during the actual creation process.
RRD definition (RrdDef object) consists of the following elements:
RrdDef provides API to set all these elements. For the complete explanation of all RRD definition parameters, see RRDTool's rrdcreate man page.
| Modifier and Type | Field and Description |
|---|---|
static long |
DEFAULT_INITIAL_SHIFT
If not specified in constructor, starting timestamp will be set to current timestamp plus
DEFAULT_INITIAL_SHIFT seconds (-10).
|
static long |
DEFAULT_STEP
Default RRD step to be used if not specified in constructor (300 seconds).
|
static int |
DEFAULTVERSION
Default RRD file format version.
|
| Constructor and Description |
|---|
RrdDef(String rrdpath)
Creates new RRD definition object with the given path.
|
RrdDef(String path,
long step)
Creates new RRD definition object with the given path and step.
|
RrdDef(String path,
long startTime,
long step)
Creates new RRD definition object with the given path, starting timestamp and step.
|
RrdDef(String path,
long startTime,
long step,
int version)
Creates new RRD definition object with the given path, starting timestamp, step and version.
|
RrdDef(URI uri)
Creates new RRD definition object with the given path.
|
RrdDef(URI uri,
long step)
Creates new RRD definition object with the given path and step.
|
RrdDef(URI uri,
long startTime,
long step)
Creates new RRD definition object with the given path, starting timestamp and step.
|
RrdDef(URI uri,
long startTime,
long step,
int version)
Creates new RRD definition object with the given path, starting timestamp, step and version.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addArchive(ArcDef... arcDefs)
Adds archive definitions to RRD definition in bulk.
|
void |
addArchive(ArcDef arcDef)
Adds single archive definition represented with object of class
ArcDef. |
void |
addArchive(ConsolFun consolFun,
double xff,
int steps,
int rows)
Adds single archive definition by specifying its consolidation function, X-files factor,
number of steps and rows.
|
void |
addArchive(String rrdToolArcDef)
Adds single archive to RRD definition from a RRDTool-like archive definition string.
|
void |
addDatasource(DsDef... dsDefs)
Adds data source definitions to RRD definition in bulk.
|
void |
addDatasource(DsDef dsDef)
Adds single datasource definition represented with object of class
DsDef. |
void |
addDatasource(String rrdToolDsDef)
Adds single datasource to RRD definition from a RRDTool-like datasource definition string.
|
void |
addDatasource(String dsName,
DsType dsType,
long heartbeat,
double minValue,
double maxValue)
Adds single datasource to RRD definition by specifying its data source name, source type,
heartbeat, minimal and maximal value.
|
(package private) static long |
calculateSize(int dsCount,
int arcCount,
int rowsCount,
String[] dsNames) |
String |
dump()
Returns string that represents all specified RRD creation parameters.
|
boolean |
equals(Object obj) |
String |
exportXmlTemplate()
Exports RrdDef object to string in XML format.
|
String |
exportXmlTemplate(boolean compatible)
Exports RrdDef object to string in XML format.
|
void |
exportXmlTemplate(OutputStream out)
Exports RrdDef object to output stream in XML format.
|
void |
exportXmlTemplate(OutputStream out,
boolean compatible)
Exports RrdDef object to output stream in XML format.
|
void |
exportXmlTemplate(String filePath)
Exports RrdDef object to a file in XML format.
|
void |
exportXmlTemplate(String filePath,
boolean compatible)
Exports RrdDef object to a file in XML format.
|
void |
exportXmlTemplate(XmlWriter xml,
boolean compatible)
Exports RrdDef object to output stream in XML format.
|
(package private) ArcDef |
findArchive(ConsolFun consolFun,
int steps) |
int |
getArcCount()
Returns number of defined archives.
|
ArcDef[] |
getArcDefs()
Returns all archive definition objects specified so far.
|
int |
getDsCount()
Returns number of defined datasources.
|
DsDef[] |
getDsDefs()
Returns all data source definition objects specified so far.
|
long |
getEstimatedSize()
Returns the number of storage bytes required to create RRD from this RrdDef object.
|
String |
getPath()
Returns path for the new RRD.
|
(package private) String |
getRrdToolCommand() |
long |
getStartTime()
Returns starting time stamp for the RRD that should be created.
|
long |
getStep()
Returns time step for the RRD that will be created.
|
URI |
getUri()
Returns URI for the new RRD
|
int |
getVersion()
Returns the RRD file version
|
boolean |
hasArchives()
hasArchives.
|
boolean |
hasDatasources()
hasDatasources.
|
int |
hashCode() |
(package private) void |
removeArchive(ConsolFun consolFun,
int steps) |
void |
removeArchives()
Removes all RRA archive definitions.
|
(package private) void |
removeDatasource(String dsName) |
void |
removeDatasources()
Removes all datasource definitions.
|
(package private) void |
saveSingleDatasource(String dsName) |
void |
setPath(String path)
Sets path to RRD.
|
void |
setPath(URI uri)
Sets URI to RRD.
|
void |
setStartTime(Calendar gc)
Sets RRD's starting timestamp.
|
void |
setStartTime(Date date)
Sets RRD's starting timestamp.
|
void |
setStartTime(long startTime)
Sets RRD's starting timestamp.
|
void |
setStep(long step)
Sets RRD's time step.
|
void |
setVersion(int version)
Sets RRD's file version.
|
public static final long DEFAULT_INITIAL_SHIFT
public static final long DEFAULT_STEP
public static final int DEFAULTVERSION
public RrdDef(String rrdpath)
RrdDb constructor, new RRD will be created using the specified path.
The will be transformed internally to an URI using the default backend factory.
rrdpath - Path to new RRD.public RrdDef(String path, long step)
The will be transformed internally to an URI using the default backend factory.
path - URI to new RRD.step - RRD step.public RrdDef(String path, long startTime, long step)
The will be transformed internally to an URI using the default backend factory.
path - Path to new RRD.startTime - RRD starting timestamp.step - RRD step.public RrdDef(String path, long startTime, long step, int version)
The will be transformed internally to an URI using the default backend factory.
path - Path to new RRD.startTime - RRD starting timestamp.step - RRD step.version - RRD's file version.public RrdDef(URI uri)
RrdDb constructor, new RRD will be created using the specified path.uri - URI to the new RRD.public RrdDef(URI uri, long step)
uri - URI to new RRD.step - RRD step.public RrdDef(URI uri, long startTime, long step)
uri - URI to new RRD.startTime - RRD starting timestamp.step - RRD step.public RrdDef(URI uri, long startTime, long step, int version)
uri - URI to new RRD.startTime - RRD starting timestamp.step - RRD step.version - RRD's file version.public void addArchive(ArcDef... arcDefs)
arcDefs - Array of archive definition objectsIllegalArgumentException - Thrown if RRD definition already contains archive
with the same consolidation function and the same number of steps.public void addArchive(ArcDef arcDef)
ArcDef.arcDef - Archive definition.IllegalArgumentException - Thrown if archive with the same consolidation
function and the same number of steps is already added.public void addArchive(ConsolFun consolFun, double xff, int steps, int rows)
consolFun - Consolidation function.xff - X-files factor. Valid values are between 0 and 1.steps - Number of archive stepsrows - Number of archive rowsIllegalArgumentException - Thrown if archive with the same consolidation
function and the same number of steps is already added.public void addArchive(String rrdToolArcDef)
RRA:consolidationFunction:XFilesFactor:steps:rows
For example:
RRA:AVERAGE:0.5:10:1000
For more information on archive definition parameters see rrdcreate man page.
rrdToolArcDef - Archive definition string with the syntax borrowed from RRDTool.IllegalArgumentException - Thrown if invalid string is supplied.public void addDatasource(DsDef... dsDefs)
dsDefs - Array of data source definition objects.public void addDatasource(DsDef dsDef)
DsDef.dsDef - Datasource definition.public void addDatasource(String rrdToolDsDef)
DS:name:type:heartbeat:minValue:maxValue
For example:
DS:input:COUNTER:600:0:U
For more information on datasource definition parameters see rrdcreate man
page.
rrdToolDsDef - Datasource definition string with the syntax borrowed from RRDTool.IllegalArgumentException - Thrown if invalid string is supplied.public void addDatasource(String dsName, DsType dsType, long heartbeat, double minValue, double maxValue)
IMPORTANT NOTE: If datasource name ends with '!', corresponding archives will never store NaNs as datasource values. In that case, NaN datasource values will be silently replaced with zeros by the framework.
dsName - Data source name.dsType - Data source type. Valid types are "COUNTER", "GAUGE", "DERIVE" and "ABSOLUTE"
(these string constants are conveniently defined in the DsType class).heartbeat - Data source heartbeat.minValue - Minimal acceptable value. Use Double.NaN if unknown.maxValue - Maximal acceptable value. Use Double.NaN if unknown.IllegalArgumentException - Thrown if new datasource definition uses already
used data source name.static long calculateSize(int dsCount,
int arcCount,
int rowsCount,
String[] dsNames)
public String dump()
create command.RrdDb object.public boolean equals(Object obj)
Compares the current RrdDef with another. RrdDefs are considered equal if:
public String exportXmlTemplate()
RrdDefTemplate class.
It use a format compatible with previous RRD4J's version, using a path, instead of an URI.
public String exportXmlTemplate(boolean compatible)
RrdDefTemplate class.
If compatible is set to true, it returns an XML compatible with previous
RRD4J's versions, using a path, instead of an URI.
compatible - Compatible with previous versions.public void exportXmlTemplate(OutputStream out)
RrdDefTemplate class.
It use a format compatible with previous RRD4J's version, using a path, instead of an URI.
out - Output streampublic void exportXmlTemplate(OutputStream out, boolean compatible)
RrdDefTemplate class.
If compatible is set to true, it returns an XML compatible with previous
RRD4J's versions, using a path, instead of an URI.
out - Output streamcompatible - Compatible with previous versions.public void exportXmlTemplate(String filePath) throws IOException
RrdDefTemplate class.
It use a format compatible with previous RRD4J's version, using a path, instead of an URI.
filePath - Path to the fileIOException - if any.public void exportXmlTemplate(String filePath, boolean compatible) throws IOException
RrdDefTemplate class.
If compatible is set to true, it returns an XML compatible with previous
RRD4J versions, using a path, instead of an URI.
filePath - Path to the filecompatible - Compatible with previous versions.IOException - if any.public void exportXmlTemplate(XmlWriter xml, boolean compatible)
RrdDefTemplate class.
If compatible is set to true, it returns an XML compatible with previous
RRD4J's versions, using a path, instead of an URI.
xml - XML writercompatible - Compatible with previous versions.public int getArcCount()
public ArcDef[] getArcDefs()
public int getDsCount()
public DsDef[] getDsDefs()
public long getEstimatedSize()
public String getPath()
Paths.get(def.getUri()) when the URI scheme is file.String getRrdToolCommand()
public long getStartTime()
public long getStep()
public URI getUri()
public int getVersion()
public boolean hasArchives()
public boolean hasDatasources()
void removeArchive(ConsolFun consolFun, int steps)
public void removeArchives()
void removeDatasource(String dsName)
public void removeDatasources()
void saveSingleDatasource(String dsName)
public void setPath(String path)
The will be transformed internally to an URI using the default backend factory.
path - path to new RRD.public void setPath(URI uri)
uri - URI to new RRD.public void setStartTime(Calendar gc)
gc - starting datepublic void setStartTime(Date date)
date - starting datepublic void setStartTime(long startTime)
startTime - Starting timestamp.public void setStep(long step)
step - RRD time step.public void setVersion(int version)
version - the version to set