org.opennms.netmgt.rrd.jrobin
Class JRobinRrdStrategy

java.lang.Object
  extended by org.opennms.netmgt.rrd.jrobin.JRobinRrdStrategy
All Implemented Interfaces:
org.opennms.netmgt.rrd.RrdStrategy

public class JRobinRrdStrategy
extends java.lang.Object
implements org.opennms.netmgt.rrd.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)


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 rrdName, int step, java.util.List<org.opennms.netmgt.rrd.RrdDataSource> dataSources, java.util.List<java.lang.String> rraList)
           
 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)
           
protected  org.jrobin.graph.RrdGraphDef createGraphDef(java.io.File workDir, java.lang.String[] commandArray)
           
 org.opennms.netmgt.rrd.RrdGraphDetails createGraphReturnDetails(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, java.lang.String ds, int interval)
          Fetch the last value from the JRobin RrdDb file.
 java.lang.Double fetchLastValueInRange(java.lang.String fileName, java.lang.String ds, int interval, int range)
           
 java.lang.String getDefaultFileExtension()
           
 int getGraphRightOffset()
           
 int getGraphTopOffsetWithText()
           
 java.lang.String getStats()
          This implementation does not track any stats.
 void graphicsInitialize()
           
 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.
 void updateFile(java.lang.Object rrdFile, java.lang.String owner, 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
 

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 org.opennms.netmgt.rrd.RrdStrategy
Throws:
java.lang.Exception

createDefinition

public java.lang.Object createDefinition(java.lang.String creator,
                                         java.lang.String directory,
                                         java.lang.String rrdName,
                                         int step,
                                         java.util.List<org.opennms.netmgt.rrd.RrdDataSource> dataSources,
                                         java.util.List<java.lang.String> rraList)
                                  throws java.lang.Exception
Specified by:
createDefinition in interface org.opennms.netmgt.rrd.RrdStrategy
Throws:
java.lang.Exception

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 org.opennms.netmgt.rrd.RrdStrategy
Throws:
java.lang.Exception

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 org.opennms.netmgt.rrd.RrdStrategy
Throws:
java.lang.Exception

updateFile

public void updateFile(java.lang.Object rrdFile,
                       java.lang.String owner,
                       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 org.opennms.netmgt.rrd.RrdStrategy
Throws:
java.lang.Exception

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 org.opennms.netmgt.rrd.RrdStrategy
Throws:
java.lang.Exception

graphicsInitialize

public void graphicsInitialize()
                        throws java.lang.Exception
Specified by:
graphicsInitialize in interface org.opennms.netmgt.rrd.RrdStrategy
Throws:
java.lang.Exception

fetchLastValue

public java.lang.Double fetchLastValue(java.lang.String fileName,
                                       java.lang.String ds,
                                       int interval)
                                throws java.lang.NumberFormatException,
                                       org.opennms.netmgt.rrd.RrdException
Fetch the last value from the JRobin RrdDb file.

Specified by:
fetchLastValue in interface org.opennms.netmgt.rrd.RrdStrategy
Throws:
java.lang.NumberFormatException
org.opennms.netmgt.rrd.RrdException

fetchLastValueInRange

public java.lang.Double fetchLastValueInRange(java.lang.String fileName,
                                              java.lang.String ds,
                                              int interval,
                                              int range)
                                       throws java.lang.NumberFormatException,
                                              org.opennms.netmgt.rrd.RrdException
Specified by:
fetchLastValueInRange in interface org.opennms.netmgt.rrd.RrdStrategy
Throws:
java.lang.NumberFormatException
org.opennms.netmgt.rrd.RrdException

createGraph

public java.io.InputStream createGraph(java.lang.String command,
                                       java.io.File workDir)
                                throws java.io.IOException,
                                       org.opennms.netmgt.rrd.RrdException
Specified by:
createGraph in interface org.opennms.netmgt.rrd.RrdStrategy
Throws:
java.io.IOException
org.opennms.netmgt.rrd.RrdException

createGraphReturnDetails

public org.opennms.netmgt.rrd.RrdGraphDetails createGraphReturnDetails(java.lang.String command,
                                                                       java.io.File workDir)
                                                                throws java.io.IOException,
                                                                       org.opennms.netmgt.rrd.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:
createGraphReturnDetails in interface org.opennms.netmgt.rrd.RrdStrategy
Throws:
java.io.IOException
org.opennms.netmgt.rrd.RrdException

createGraphDef

protected org.jrobin.graph.RrdGraphDef createGraphDef(java.io.File workDir,
                                                      java.lang.String[] commandArray)
                                               throws org.jrobin.core.RrdException
Throws:
org.jrobin.core.RrdException

getStats

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

Specified by:
getStats in interface org.opennms.netmgt.rrd.RrdStrategy

getGraphRightOffset

public int getGraphRightOffset()
Specified by:
getGraphRightOffset in interface org.opennms.netmgt.rrd.RrdStrategy

getGraphTopOffsetWithText

public int getGraphTopOffsetWithText()
Specified by:
getGraphTopOffsetWithText in interface org.opennms.netmgt.rrd.RrdStrategy

getDefaultFileExtension

public java.lang.String getDefaultFileExtension()
Specified by:
getDefaultFileExtension in interface org.opennms.netmgt.rrd.RrdStrategy


Copyright © 2007. All Rights Reserved.