OpenNMS API 1.2.3

org.opennms.netmgt.rrd
Class JRobinRrdStrategy

java.lang.Object
  extended byorg.opennms.netmgt.rrd.JRobinRrdStrategy
All Implemented Interfaces:
RrdStrategy

public class JRobinRrdStrategy
extends java.lang.Object
implements RrdStrategy

Provides a JRobin based implementation of RrdStrategy. It uses JRobin 1.4 in FILE mode (NIO is too memory consuming for the large number of files that we open)


Field Summary
private  boolean m_initialized
           
 
Constructor Summary
JRobinRrdStrategy()
           
 
Method Summary
 void closeFile(java.lang.Object rrdFile)
          Closes the JRobin RrdDb.
 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)
          Creates and returns a RrdDef represented by the parameters.
 void createFile(java.lang.Object rrdDef)
          Creates the JRobin RrdDb from the def by opening the file and then closing.
 java.io.InputStream createGraph(java.lang.String command, java.io.File workDir)
          This constructs a graphDef by parsing the rrdtool style command and using the values to create the JRobin graphDef.
 java.lang.Double fetchLastValue(java.lang.String fileName, int interval)
          Fetch the last value from the JRobin RrdDb file.
private  java.awt.Color getColor(java.lang.String colorValue)
           
 java.lang.String getStats()
          This implementation does not track and stats.
 void graphicsInitialize()
          This Initializes the graphics subsystem only.
 void initialize()
          Initialized the RrdDb to use the FILE factory because the NIO factory uses too much memory for our implementation.
 java.lang.Object openFile(java.lang.String fileName)
          Opens the JRobin RrdDb by name and returns it.
private  void parseGraphColor(org.jrobin.graph.RrdGraphDef graphDef, java.lang.String colorArg)
           
private  java.lang.String[] tokenize(java.lang.String line, java.lang.String delims, boolean processQuoted)
           
 void updateFile(java.lang.Object rrdFile, java.lang.String data)
          Creates a sample from the JRobin RrdDb and passes in the data provided.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_initialized

private boolean m_initialized
Constructor Detail

JRobinRrdStrategy

public JRobinRrdStrategy()
Method Detail

closeFile

public void closeFile(java.lang.Object rrdFile)
               throws java.lang.Exception
Closes the JRobin RrdDb.

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

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
Creates and returns a RrdDef represented by the parameters.

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 the JRobin RrdDb from the def by opening the file and then closing. TODO: Change the interface here to create the file and return it opened.

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
Opens the JRobin RrdDb by name and returns it.

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 rrdFile,
                       java.lang.String data)
                throws java.lang.Exception
Creates a sample from the JRobin RrdDb and passes in the data provided.

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

initialize

public void initialize()
                throws java.lang.Exception
Initialized the RrdDb to use the FILE factory because the NIO factory uses too much memory for our implementation.

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 fileName,
                                       int interval)
                                throws java.lang.NumberFormatException,
                                       RrdException
Fetch the last value from the JRobin RrdDb file.

Specified by:
fetchLastValue in interface RrdStrategy
Parameters:
fileName - 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:
java.lang.NumberFormatException
RrdException

getColor

private java.awt.Color getColor(java.lang.String colorValue)

tokenize

private java.lang.String[] tokenize(java.lang.String line,
                                    java.lang.String delims,
                                    boolean processQuoted)

createGraph

public java.io.InputStream createGraph(java.lang.String command,
                                       java.io.File workDir)
                                throws java.io.IOException,
                                       RrdException
This constructs a graphDef by parsing the rrdtool style command and using the values to create the JRobin graphDef. It does not understand the 'AT style' time arguments however. Also there may be some rrdtool parameters that it does not understand. These will be ignored. The graphDef will be used to construct an RrdGraph and a PNG image will be created. An input stream returning the bytes of the PNG image is returned.

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:
RrdException - if an RRD error occurs
java.io.IOException - if an IOError occurs

parseGraphColor

private void parseGraphColor(org.jrobin.graph.RrdGraphDef graphDef,
                             java.lang.String colorArg)
                      throws java.lang.IllegalArgumentException
Parameters:
colorArg - Should have the form COLORTAG#RRGGBB
Throws:
java.lang.IllegalArgumentException
See Also:
http://www.jrobin.org/support/man/rrdgraph.html

getStats

public java.lang.String getStats()
This implementation does not track and stats.

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

OpenNMS API 1.2.3

Generated by eevans on May 29 2005 2015.