OpenNMS API 1.2.9

## org.opennms.netmgt.rrd
Class JniRrdStrategy

    java.lang.Object
      org.opennms.netmgt.rrd.JniRrdStrategy

All Implemented Interfaces:
  RrdStrategy

class JniRrdStrategy
extends java.lang.Object
implements RrdStrategy

Provides an rrdtool based implementation of RrdStrategy. It uses the existing JNI based single-threaded interface to write the rrdtool compatibile RRD files. The JNI interface takes command-like arguments and doesn't provide open files so the the Objects used to represent open files are really partial command strings See the individual methods for more details

Field Summary
`(package private) boolean` `graphicsInitialized`
`(package private) boolean` `initialized`

Constructor Summary
`(package private)` `JniRrdStrategy()`

Method Summary
`private void` `checkState(java.lang.String methodName)` Ensures that the initialize method has been called.
`void` `closeFile(java.lang.Object rrd)` The 'closes' the rrd file.
`java.lang.Object` `createDefinition(java.lang.String creator, java.lang.String directory, java.lang.String dsName, int step, java.lang.String dsType, int dsHeartbeat, java.lang.String dsMin, java.lang.String dsMax, java.util.List rraList)` Constructs an rrdtool create command string that can be used to create the rrd file and returns it as the rrdDefinition object.
`void` `createFile(java.lang.Object rrdDef)` Creates a the rrd file from the rrdDefinition.
`java.io.InputStream` `createGraph(java.lang.String command, java.io.File workDir)` Executes the given graph comnmand as process with workDir as the current directory.
`java.lang.Double` `fetchLastValue(java.lang.String rrdFile, int interval)` Fetches the last value directly from the rrd file using the JNI Interface.
`java.lang.Double` `fetchLastValueInRange(java.lang.String rrdFile, int interval, int range)` Fetches the last value from the round robin database with the given name within a time range.
`java.lang.String` `getStats()` No stats are kept for this implementation.
`void` `graphicsInitialize()` This Initializes the graphics subsystem only.
`void` `initialize()` Initialized the JNI Interface
`java.lang.Object` `openFile(java.lang.String fileName)` The 'opens' the given rrd file.
`void` `updateFile(java.lang.Object rrd, java.lang.String data)` This 'updates' the given rrd file by providing data.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### initialized

    boolean initialized

### graphicsInitialized

    boolean graphicsInitialized

Constructor Detail

### JniRrdStrategy

    JniRrdStrategy()

Method Detail

### closeFile

    public void closeFile(java.lang.Object rrd)
                   throws java.lang.Exception

  The 'closes' the rrd file. This is where the actual work of writing the RRD files takes place. The passed in rrd is actually an rrd command string containing updates. This method executes this command.

  Specified by:
    `closeFile` in interface `RrdStrategy`
  Parameters:
    `rrd` - an rrd object created using openFile
  Throws:
    `java.lang.Exception` - if an error occurs closing the file

### checkState

    private void checkState(java.lang.String methodName)

  Ensures that the initialize method has been called.

  Parameters:
    `methodName` - the name of the method we are called from
  Throws:
    `IllegalState` - exception of intialize has not been called.

### createDefinition

    public java.lang.Object createDefinition(java.lang.String creator,
                                             java.lang.String directory,
                                             java.lang.String dsName,
                                             int step,
                                             java.lang.String dsType,
                                             int dsHeartbeat,
                                             java.lang.String dsMin,
                                             java.lang.String dsMax,
                                             java.util.List rraList)
                                      throws java.lang.Exception

  Constructs an rrdtool create command string that can be used to create the rrd file and returns it as the rrdDefinition object.

  Specified by:
    `createDefinition` in interface `RrdStrategy`
  Parameters:
    `creator` - - A string representing who is creating this file for use in log msgs
    `directory` - - The directory to create the file in
    `dsName` - - The datasource name for use in the round robin database
    `step` - - the step for the database
    `dsType` - - the type for the datasource
    `dsHeartbeat` - - the heartbeat for the datasouce
    `dsMin` - - the minimum allowable value for the datasource
    `dsMax` - - the maximum allowable value for the datasouce
    `rraList` - - a List of the round robin archives to create in the database
  Returns:
    an object representing the definition of an round robin database
  Throws:
    `java.lang.Exception` - If an error occurs while creating the definition

### createFile

    public void createFile(java.lang.Object rrdDef)
                    throws java.lang.Exception

  Creates a the rrd file from the rrdDefinition. Since this definition is really just the create command string it just executes it.

  Specified by:
    `createFile` in interface `RrdStrategy`
  Parameters:
    `rrdDef` - an round robin database definition created using the createDefinition call.
  Throws:
    `java.lang.Exception` - if an error occurs create the file

### openFile

    public java.lang.Object openFile(java.lang.String fileName)
                              throws java.lang.Exception

  The 'opens' the given rrd file. In actuality since the JNI interface does not provide files that may be open, this constructs the beginning portion of the rrd command to update the file.

  Specified by:
    `openFile` in interface `RrdStrategy`
  Parameters:
    `fileName` - the name of the associated rrd file
  Returns:
    an open rrd reference that can by used in calls to updateFile and closeFile
  Throws:
    `java.lang.Exception` - if an error occurs opening the file

### updateFile

    public void updateFile(java.lang.Object rrd,
                           java.lang.String data)
                    throws java.lang.Exception

  This 'updates' the given rrd file by providing data. Since the JNI interface does not provide files that can be open, this just appends the data to the command string constructed so far. The data is not immediately written to the file since this would eliminate the possibility of getting performance benefit by doing more than one write per open. The updates are all performed at once in the closeFile method.

  Specified by:
    `updateFile` in interface `RrdStrategy`
  Parameters:
    `rrd` - an rrd object created using openFile
    `data` - a string of the form <timestamp>: <datavalue>
  Throws:
    `java.lang.Exception` - if an error occurs updating the file

### initialize

    public void initialize()
                    throws java.lang.Exception

  Initialized the JNI Interface

  Specified by:
    `initialize` in interface `RrdStrategy`
  Throws:
    `java.lang.Exception` - if an Error occurs

### graphicsInitialize

    public void graphicsInitialize()
                            throws java.lang.Exception

  Description copied from interface: `RrdStrategy`
  This Initializes the graphics subsystem only. This is used by the web application to avoid the need for the JNI infrastructure in the webapp.

  Specified by:
    `graphicsInitialize` in interface `RrdStrategy`
  Throws:
    `java.lang.Exception`

### fetchLastValue

    public java.lang.Double fetchLastValue(java.lang.String rrdFile,
                                           int interval)
                                    throws java.lang.NumberFormatException,
                                           RrdException

  Fetches the last value directly from the rrd file using the JNI Interface.

  Specified by:
    `fetchLastValue` in interface `RrdStrategy`
  Parameters:
    `rrdFile` - a name the represents a round robin database
    `interval` - a step interval of the round robin database
  Returns:
    The last value as a Double (if the last value didn't exist returns a Double.NaN)
  Throws:
    `RrdException`
    `java.lang.NumberFormatException`

### fetchLastValueInRange

    public java.lang.Double fetchLastValueInRange(java.lang.String rrdFile,
                                                  int interval,
                                                  int range)
                                           throws java.lang.NumberFormatException,
                                                  RrdException

  Description copied from interface: `RrdStrategy`
  Fetches the last value from the round robin database with the given name within a time range. The interval passed in should be the interval associated with the round robin database. The range should be the amount of "lag" acceptable for an update to be considered valid. Range must be a multiple of the RRD interval.

  Specified by:
    `fetchLastValueInRange` in interface `RrdStrategy`
  Parameters:
    `rrdFile` - a name the represents a round robin database
    `interval` - a step interval of the round robin database
    `range` - an acceptable range for which the last value will be returned
  Returns:
    The last value as a Double (if the last value didn't exist returns a Double.NaN)
  Throws:
    `RrdException`
    `java.lang.NumberFormatException`

### createGraph

    public java.io.InputStream createGraph(java.lang.String command,
                                           java.io.File workDir)
                                    throws java.io.IOException,
                                           RrdException

  Executes the given graph comnmand as process with workDir as the current directory. The output stream of the command (a PNG image) is copied to a the InputStream returned from the method.

  Specified by:
    `createGraph` in interface `RrdStrategy`
  Parameters:
    `command` - the command needed to create the graph
    `workDir` - the directory that all referenced files are relative to
  Returns:
    an input stream representing the bytes of a graph image as a PNG file
  Throws:
    `java.io.IOException` - if an IOError occurs
    `RrdException` - if an RRD error occurs

### getStats

    public java.lang.String getStats()

  No stats are kept for this implementation.

  Specified by:
    `getStats` in interface `RrdStrategy`
  Returns:
    a non-null string representing any staticstics to be included in the logs

OpenNMS API 1.2.9

Generated by ranger on May 19 2007 2335.