org.jrobin.graph
Class RrdExportDef

java.lang.Object
  extended by org.jrobin.graph.RrdExportDef
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
RrdGraphDef

public class RrdExportDef
extends java.lang.Object
implements java.io.Serializable

Class used to collect information for a JRobin export.

JRobin export works the same way as Rrdtool XPORT does, to learn more about the XPORT functionality, see RRDTool's rrdxport man page.

See Also:
Serialized Form

Field Summary
protected  java.util.ArrayList cdefList
           
protected  java.util.ArrayList edefList
           
protected  java.util.ArrayList exportList
           
protected  FetchSourceList fetchSources
           
protected  java.util.ArrayList pdefList
           
static int STRICT_EXPLICIT_OFF
           
static int STRICT_EXPLICIT_ON
           
static int STRICT_IMPLICIT_OFF
           
static int STRICT_IMPLICIT_ON
           
 
Constructor Summary
RrdExportDef()
           
RrdExportDef(java.util.Date start, java.util.Date end)
          Constructs a new JRobin graph object, with a specified time span to be presented on the graph.
RrdExportDef(java.util.GregorianCalendar start, java.util.GregorianCalendar end)
          Constructs a new JRobin graph object, with a specified time span to be presented on the graph.
RrdExportDef(long startTime, long endTime)
          Constructs a new JRobin graph object, with a specified time span to be presented on the graph.
 
Method Summary
 void addExportData(ExportData edata)
          Adds a set of ExportData to the datasource list.
 void datasource(java.lang.String name, Plottable plottable)
          Adds a custom graph source with the given name to the graph definition.
 void datasource(java.lang.String name, Plottable plottable, int index)
          Adds a custom graph source with the given name to the graph definition.
 void datasource(java.lang.String name, Plottable plottable, java.lang.String sourceName)
          Adds a custom graph source with the given name to the graph definition.
 void datasource(java.lang.String name, java.lang.String rpn)
          Adds complex graph source with the given name to the graph definition.
 void datasource(java.lang.String name, java.lang.String defName, java.lang.String consolFunc)
          Adds static graph source with the given name to the graph definition.
 void datasource(java.lang.String name, java.lang.String file, java.lang.String dsName, java.lang.String consolFunc)
          Adds simple graph source to graph definition.
 void datasource(java.lang.String name, java.lang.String file, java.lang.String dsName, java.lang.String consolFunc, java.lang.String backend)
          Adds simple graph source to graph definition.
 void export(java.lang.String name)
          Sets a specific datasource to be exported (if export is strict).
 void export(java.lang.String name, java.lang.String legend)
          Sets a specific datasource to be exported (if export is strict).
 java.lang.String exportXmlTemplate()
          Exports RrdExportDef (export definition) object in XML format to string.
 void exportXmlTemplate(java.io.OutputStream stream)
          Exports RrdExportDef (export definition) object in XML format to output stream.
 void exportXmlTemplate(java.lang.String filePath)
          Exports RrdExportDef (export definition) object in XML format to file.
protected  org.jrobin.graph.Cdef[] getCdefs()
           
protected  long getEndTime()
           
protected  ExportData[] getExportData()
           
protected  java.lang.String[][] getExportDatasources()
           
protected  FetchSourceList getFetchSources()
           
protected  int getNumDefs()
           
protected  int getNumSdefs()
           
protected  org.jrobin.graph.Pdef[] getPdefs()
           
protected  long getResolution()
           
protected  long getStartTime()
           
 java.lang.String getXmlTemplate()
          Exports RrdExportDef (export definition) object in XML format to string.
protected  boolean isStrict()
           
 void setDatasources(FetchSourceList datasourceList)
          Clears the list of RRD datasources for this GraphDef and sets it to the FetchSourceList passed as aparameter.
 void setResolution(long resolution)
          Sets the resolution with which data will be fetched from the RRD sources.
 void setStrictExport(boolean strict)
          Sets the strict flag for the export functionality.
 void setTimePeriod(java.util.Date start, java.util.Date end)
          Sets time span to be presented on the graph using java.util.Date objects.
 void setTimePeriod(java.util.GregorianCalendar start, java.util.GregorianCalendar end)
          Sets time span to be presented on the graph using java.util.GregorianCalendar objects.
 void setTimePeriod(long startTime, long endTime)
          Sets time span to be presented on the graph using timestamps in number of seconds.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STRICT_IMPLICIT_OFF

public static final int STRICT_IMPLICIT_OFF
See Also:
Constant Field Values

STRICT_IMPLICIT_ON

public static final int STRICT_IMPLICIT_ON
See Also:
Constant Field Values

STRICT_EXPLICIT_OFF

public static final int STRICT_EXPLICIT_OFF
See Also:
Constant Field Values

STRICT_EXPLICIT_ON

public static final int STRICT_EXPLICIT_ON
See Also:
Constant Field Values

fetchSources

protected FetchSourceList fetchSources

pdefList

protected java.util.ArrayList pdefList

cdefList

protected java.util.ArrayList cdefList

exportList

protected java.util.ArrayList exportList

edefList

protected java.util.ArrayList edefList
Constructor Detail

RrdExportDef

public RrdExportDef()

RrdExportDef

public RrdExportDef(long startTime,
                    long endTime)
             throws RrdException
Constructs a new JRobin graph object, with a specified time span to be presented on the graph. Using timestamps defined as number of seconds since the epoch.

Parameters:
startTime - Starting timestamp in seconds.
endTime - Ending timestamp in seconds.
Throws:
RrdException - Thrown if invalid parameters are supplied.

RrdExportDef

public RrdExportDef(java.util.Date start,
                    java.util.Date end)
             throws RrdException
Constructs a new JRobin graph object, with a specified time span to be presented on the graph. Time spam defined using java.util.Date objects.

Parameters:
start - Starting time.
end - Ending time.
Throws:
RrdException - Thrown in case of invalid parameters.

RrdExportDef

public RrdExportDef(java.util.GregorianCalendar start,
                    java.util.GregorianCalendar end)
             throws RrdException
Constructs a new JRobin graph object, with a specified time span to be presented on the graph. Time spam defined using java.util.GregorianCalendar objects.

Parameters:
start - Starting time.
end - Ending time.
Throws:
RrdException - Thrown in case of invalid parameters.
Method Detail

setTimePeriod

public void setTimePeriod(long startTime,
                          long endTime)
                   throws RrdException
Sets time span to be presented on the graph using timestamps in number of seconds. An end time of 0 means JRobin will try to use the last available update time.

Parameters:
startTime - Starting timestamp in seconds.
endTime - Ending timestamp in secons.
Throws:
RrdException - Thrown if invalid parameters are supplied.

setTimePeriod

public void setTimePeriod(java.util.Date start,
                          java.util.Date end)
                   throws RrdException
Sets time span to be presented on the graph using java.util.Date objects.

Parameters:
start - Starting time.
end - Ending time.
Throws:
RrdException - Thrown in case of invalid parameters.

setTimePeriod

public void setTimePeriod(java.util.GregorianCalendar start,
                          java.util.GregorianCalendar end)
                   throws RrdException
Sets time span to be presented on the graph using java.util.GregorianCalendar objects.

Parameters:
start - Starting time.
end - Ending time
Throws:
RrdException - Thrown if invalid parameters are supplied.

setResolution

public void setResolution(long resolution)
Sets the resolution with which data will be fetched from the RRD sources. JRobin will try to match the requested resolution as closely as possible.

Parameters:
resolution - Resolution (data step) in seconds.

datasource

public void datasource(java.lang.String name,
                       java.lang.String file,
                       java.lang.String dsName,
                       java.lang.String consolFunc)
                throws RrdException

Adds simple graph source to graph definition. Graph source name can be used:

Parameters:
name - Graph 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").
Throws:
RrdException

datasource

public void datasource(java.lang.String name,
                       java.lang.String file,
                       java.lang.String dsName,
                       java.lang.String consolFunc,
                       java.lang.String backend)
                throws RrdException

Adds simple graph source to graph definition. Graph source name can be used:

Parameters:
name - Graph 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").
backend - Name of the RrdBackendFactory that should be used for this RrdDb.
Throws:
RrdException

setDatasources

public void setDatasources(FetchSourceList datasourceList)

Clears the list of RRD datasources for this GraphDef and sets it to the FetchSourceList passed as aparameter. This does not alter any Cdef, Sdef or Pdef definitions. The datasources should be passed on as a FetchSourceList FetchSourceList.

Parameters:
datasourceList - FetchSourceList of the datasources to use.

datasource

public void datasource(java.lang.String name,
                       java.lang.String rpn)

Adds complex graph source with the given name to the graph definition. Complex graph sources are evaluated using the supplied rpn expression.

Complex graph source name can be used:

JRobin 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 and E. JRobin does not force you to specify at least one simple graph source name as RRDTool.

For more details on RPN see RRDTool's rrdgraph man page.

Parameters:
name - Graph source name.
rpn - RPN expression containig comma delmited simple and complex graph source names, RPN constants, functions and operators.

datasource

public void datasource(java.lang.String name,
                       java.lang.String defName,
                       java.lang.String consolFunc)
                throws RrdException

Adds static graph source with the given name to the graph definition. Static graph sources are the result of a consolidation function applied to *any* other graph source that has been defined previously.

Parameters:
name - Graph source name.
defName - Name of the datasource to calculate the value from.
consolFunc - Consolidation function to use for value calculation
Throws:
RrdException

datasource

public void datasource(java.lang.String name,
                       Plottable plottable)

Adds a custom graph source with the given name to the graph definition. The datapoints should be made available by a class extending Plottable.

Parameters:
name - Graph source name.
plottable - Class that extends Plottable class and is suited for graphing.

datasource

public void datasource(java.lang.String name,
                       Plottable plottable,
                       int index)

Adds a custom graph source with the given name to the graph definition. The datapoints should be made available by a class extending Plottable.

Parameters:
name - Graph source name.
plottable - Class that extends Plottable class and is suited for graphing.
index - Integer referring to the datasource in the Plottable class.

datasource

public void datasource(java.lang.String name,
                       Plottable plottable,
                       java.lang.String sourceName)

Adds a custom graph source with the given name to the graph definition. The datapoints should be made available by a class extending Plottable.

Parameters:
name - Graph source name.
plottable - Class that extends Plottable class and is suited for graphing.
sourceName - String name referring to the datasource in the Plottable class.

addExportData

public void addExportData(ExportData edata)
Adds a set of ExportData to the datasource list.

Parameters:
edata - ExportData to add.

export

public void export(java.lang.String name)
Sets a specific datasource to be exported (if export is strict). The expor legend for this datasource will be empty.

Parameters:
name - Name of the datasource

export

public void export(java.lang.String name,
                   java.lang.String legend)
Sets a specific datasource to be exported (if export is strict). And maps an export legend to this datasource.

Parameters:
name - Name of the datasource
legend - Legend text

setStrictExport

public void setStrictExport(boolean strict)

Sets the strict flag for the export functionality. By default, the export is in implicit not-strict, this means that by default, all datasources specified in the RrdExportDef will be exported into the ExportData.

If the strict flag is not specified explicitly by calling this method, the export will convert to implicitly strict as soon as a particular export() mapping is defined. Explicit settings will override implicit.

When explicit is off, the legend for datasources will by default be the same as the datasource name, the legend can be overridden by setting mappings using export() method.

Strict export is the same behaviour as RRDtool's XPORT.

Parameters:
strict - True if strict export should on, false if not.

exportXmlTemplate

public void exportXmlTemplate(java.io.OutputStream stream)
Exports RrdExportDef (export definition) object in XML format to output stream. Generated code can be parsed with RrdExportDefTemplate class.

Parameters:
stream - Output stream to send XML code to.

getXmlTemplate

public java.lang.String getXmlTemplate()
Exports RrdExportDef (export definition) object in XML format to string. Generated code can be parsed with RrdExportDefTemplate class, see exportXmlTemplate().

Returns:
String representing graph definition in XML format.

exportXmlTemplate

public java.lang.String exportXmlTemplate()
Exports RrdExportDef (export definition) object in XML format to string. Generated code can be parsed with RrdExportDefTemplate class.

Returns:
String representing graph definition in XML format.

exportXmlTemplate

public void exportXmlTemplate(java.lang.String filePath)
                       throws java.io.IOException
Exports RrdExportDef (export definition) object in XML format to file. Generated code can be parsed with RrdExportDefTemplate class.

Parameters:
filePath - destination file
Throws:
java.io.IOException

getStartTime

protected long getStartTime()

getEndTime

protected long getEndTime()

getResolution

protected long getResolution()

getNumDefs

protected int getNumDefs()

getCdefs

protected org.jrobin.graph.Cdef[] getCdefs()

getPdefs

protected org.jrobin.graph.Pdef[] getPdefs()

getExportData

protected ExportData[] getExportData()

getNumSdefs

protected int getNumSdefs()

getFetchSources

protected FetchSourceList getFetchSources()

isStrict

protected boolean isStrict()

getExportDatasources

protected java.lang.String[][] getExportDatasources()