org.jrobin.graph
Class RrdExport

java.lang.Object
  extended by org.jrobin.graph.RrdExport

public class RrdExport
extends java.lang.Object

RrdExport can be used to export graph-like datasources to XML format, by means of the ExportData object. More information about Export can be found in the RRDtool XPORT man page.

RrdExport needs a RrdExportDef that holds the configuration.


Field Summary
protected  long endTime
           
protected  int numRows
           
protected  long reducedEndTime
           
protected  int reducedNumRows
           
protected  long reducedStartTime
           
protected  long reducedStep
           
protected  java.util.HashMap sourceIndex
           
protected  org.jrobin.graph.Source[] sources
           
protected  long startTime
           
protected  long[] timestamps
           
 
Constructor Summary
RrdExport(RrdExportDef def)
          Constructs a new RrdExport object based on a RrdExportDef containing the configuration.
RrdExport(RrdExportDef def, int maxRows)
          Constructs a new RrdExport object based on a RrdExportDef containing the configuration and a ballpark figure of maximum number of rows in the reduced dataset.
RrdExport(RrdExportDef def, RrdOpener rrdOpener)
          Constructs a new RrdExport object based on a RrdExportDef containing the configuration and a RrdOpener for opening the RRD datasources.
RrdExport(RrdExportDef def, RrdOpener rrdOpener, int maxRows)
          Constructs a new RrdExport object based on a RrdExportDef containing the configuration, RrdOpener for opening the RRD datasources and a ballpark figure of maximum number of rows in the reduced dataset.
 
Method Summary
protected  void calculateSeries(int maxRows)
          Fetches and calculates all datasources requested.
protected  ExportData createExportData()
          Creates an ExportData object corresponding to the reduced dataset contained in the RrdExporter.
 ExportData fetch()
          Fetches the reduced dataset based on provided RrdExportDef as a ExportData object.
 ExportData fetch(int maxRows)
          Fetches the reduced dataset based on provided RrdExportDef as a ExportData object.
 RrdExportDef getExportDef()
           
 int getMaxRows()
           
 RrdOpener getRrdOpener()
           
 void setExportDef(RrdExportDef def)
          Sets the RrdExportDef that holds the export configuration.
 void setMaxRows(int maxRows)
          Sets the maximum number of rows that the reduced dataset should contain.
 void setRrdOpener(RrdOpener rrdOpener)
          Sets the rrd opener reference to use for data retrieval.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

numRows

protected int numRows

reducedNumRows

protected int reducedNumRows

startTime

protected long startTime

endTime

protected long endTime

reducedStartTime

protected long reducedStartTime

reducedEndTime

protected long reducedEndTime

reducedStep

protected long reducedStep

timestamps

protected long[] timestamps

sources

protected org.jrobin.graph.Source[] sources

sourceIndex

protected java.util.HashMap sourceIndex
Constructor Detail

RrdExport

public RrdExport(RrdExportDef def)
Constructs a new RrdExport object based on a RrdExportDef containing the configuration.

Parameters:
def - Reference to a RrdExportDef object.

RrdExport

public RrdExport(RrdExportDef def,
                 RrdOpener rrdOpener)
Constructs a new RrdExport object based on a RrdExportDef containing the configuration and a RrdOpener for opening the RRD datasources.

Parameters:
def - Reference to a RrdExportDef object.
rrdOpener - Reference to a RrdOpener object.

RrdExport

public RrdExport(RrdExportDef def,
                 int maxRows)
Constructs a new RrdExport object based on a RrdExportDef containing the configuration and a ballpark figure of maximum number of rows in the reduced dataset.

Parameters:
def - Reference to a RrdExportDef object.
maxRows - Maximum number of rows in the reduced dataset.

RrdExport

public RrdExport(RrdExportDef def,
                 RrdOpener rrdOpener,
                 int maxRows)
Constructs a new RrdExport object based on a RrdExportDef containing the configuration, RrdOpener for opening the RRD datasources and a ballpark figure of maximum number of rows in the reduced dataset.

Parameters:
def - Reference to a RrdExportDef object.
rrdOpener - Reference to a RrdOpener object.
maxRows - Maximum number of rows in the reduced dataset.
Method Detail

setExportDef

public void setExportDef(RrdExportDef def)
Sets the RrdExportDef that holds the export configuration.

Parameters:
def - Reference to a RrdExportDef object.

setRrdOpener

public void setRrdOpener(RrdOpener rrdOpener)
Sets the rrd opener reference to use for data retrieval.

Parameters:
rrdOpener - Reference to a RrdOpener object.

setMaxRows

public void setMaxRows(int maxRows)
Sets the maximum number of rows that the reduced dataset should contain. Note: this number is not absolute and can be overruled in some cases.

Parameters:
maxRows - Maximum number of rows in the reduced dataset.

fetch

public ExportData fetch(int maxRows)
                 throws RrdException,
                        java.io.IOException
Fetches the reduced dataset based on provided RrdExportDef as a ExportData object.

Parameters:
maxRows - Maximum number of rows in the returned set.
Returns:
ExportData object.
Throws:
RrdException - Thrown in case of JRobin specific error.
java.io.IOException - Thrown in case of I/O related error.

fetch

public ExportData fetch()
                 throws RrdException,
                        java.io.IOException
Fetches the reduced dataset based on provided RrdExportDef as a ExportData object.

Returns:
ExportData object.
Throws:
RrdException - Thrown in case of JRobin specific error.
java.io.IOException - Thrown in case of I/O related error.

getMaxRows

public int getMaxRows()

calculateSeries

protected void calculateSeries(int maxRows)
                        throws RrdException,
                               java.io.IOException
Fetches and calculates all datasources requested. This method is NOT synchronized, but it is important that access to it is controlled manually. This should only be an issue if you are using it for package access, since the public interface of RrdExport only uses the synchronized fetch method.

Throws:
RrdException - Thrown in case of a JRobin specific error.
java.io.IOException - Thrown in case of a I/O related error.

createExportData

protected ExportData createExportData()
                               throws RrdException
Creates an ExportData object corresponding to the reduced dataset contained in the RrdExporter. This assumes that the reduced dataset has been calculated already!

Returns:
ExportData object created.
Throws:
RrdException - Thrown in case of JRobin specific error.

getExportDef

public RrdExportDef getExportDef()

getRrdOpener

public RrdOpener getRrdOpener()