org.jrobin.core
public class RrdDefTemplate extends XmlTemplate
Here is an example of a properly formatted XML template with all available options in it (unwanted options can be removed):
<rrd_def> <path>test.rrd</path> <!-- not mandatory --> <start>1000123456</start> <!-- not mandatory --> <step>300</step> <!-- at least one datasource must be supplied --> <datasource> <name>input</name> <type>COUNTER</type> <heartbeat>300</heartbeat> <min>0</min> <max>U</max> </datasource> <datasource> <name>temperature</name> <type>GAUGE</type> <heartbeat>400</heartbeat> <min>U</min> <max>1000</max> </datasource> <!-- at least one archive must be supplied --> <archive> <cf>AVERAGE</cf> <xff>0.5</xff> <steps>1</steps> <rows>600</rows> </archive> <archive> <cf>MAX</cf> <xff>0.6</xff> <steps>6</steps> <rows>7000</rows> </archive> </rrd_def>Notes on the template syntax:
<some_tag>
and
</some_tag>
) can be replaced with
a variable of the following form: ${variable_name}
. Use
setVariable()
methods from the base class to replace template variables with real values
at runtime.Typical usage scenario:
<rrd_def> <path>${path}</path> <step>300</step> ...
RrdDefTemplate t = new RrdDefTemplate(new File(template.xml));
t.setVariable("path", "demo/test.rrd");
RrdDef def = t.getRrdDef(); RrdDb rrd = new RrdDb(def); rrd.close();
Constructor Summary | |
---|---|
RrdDefTemplate(InputSource xmlInputSource)
Creates RrdDefTemplate object from any parsable XML input source. | |
RrdDefTemplate(String xmlString)
Creates RrdDefTemplate object from the string containing XML template.
| |
RrdDefTemplate(File xmlFile)
Creates RrdDefTemplate object from the file containing XML template.
|
Method Summary | |
---|---|
RrdDef | getRrdDef()
Returns RrdDef object constructed from the underlying XML template. |
Parameters: xmlInputSource Xml input source
Throws: IOException Thrown in case of I/O error RrdException Thrown in case of XML related error (parsing error, for example)
Parameters: xmlString String containing XML template
Throws: IOException Thrown in case of I/O error RrdException Thrown in case of XML related error (parsing error, for example)
Parameters: xmlFile File object representing file with XML template
Throws: IOException Thrown in case of I/O error RrdException Thrown in case of XML related error (parsing error, for example)
setVariable()
methods. Once this method
returns, all placeholder values are preserved. To remove them all, call inhereted
clearValues()
method explicitly.
Returns: RrdDef object constructed from the underlying XML template, with all placeholders replaced with real values. This object can be passed to the constructor of the new RrdDb object.
Throws: RrdException Thrown (in most cases) if the value for some placeholder
was not supplied through setVariable()
method call