org.opennms.netmgt.rrd.jrobin
Class JRobinRrdStrategy

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

public class JRobinRrdStrategy
extends 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)


Constructor Summary
JRobinRrdStrategy()
           
 
Method Summary
 void closeFile(Object rrdFile)
          Closes the JRobin RrdDb.
 Object createDefinition(String creator, String directory, String rrdName, int step, List<RrdDataSource> dataSources, List<String> rraList)
           
 void createFile(Object rrdDef)
          Creates the JRobin RrdDb from the def by opening the file and then closing.
 InputStream createGraph(String command, File workDir)
           
protected  org.jrobin.graph.RrdGraphDef createGraphDef(File workDir, String[] commandArray)
           
 RrdGraphDetails createGraphReturnDetails(String command, File workDir)
          This constructs a graphDef by parsing the rrdtool style command and using the values to create the JRobin graphDef.
static char[] escapeIfNotPathSepInDEF(char encountered, char escaped, StringBuffer currToken)
           
 Double fetchLastValue(String fileName, String ds, int interval)
          Fetch the last value from the JRobin RrdDb file.
 Double fetchLastValue(String fileName, String ds, String consolidationFunction, int interval)
           
 Double fetchLastValueInRange(String fileName, String ds, int interval, int range)
           
 String getDefaultFileExtension()
           
 int getGraphLeftOffset()
           
 int getGraphRightOffset()
           
 int getGraphTopOffsetWithText()
           
 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.
 Object openFile(String fileName)
          Opens the JRobin RrdDb by name and returns it.
 void promoteEnqueuedFiles(Collection<String> rrdFiles)
           
static String[] tokenizeWithQuotingAndEscapes(String line, String delims, boolean processQuoted)
           
static String[] tokenizeWithQuotingAndEscapes(String line, String delims, boolean processQuoted, String tokens)
          Tokenize a String into an array of Strings.
 void updateFile(Object rrdFile, String owner, 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(Object rrdFile)
               throws Exception
Closes the JRobin RrdDb.

Specified by:
closeFile in interface RrdStrategy
Throws:
Exception

createDefinition

public Object createDefinition(String creator,
                               String directory,
                               String rrdName,
                               int step,
                               List<RrdDataSource> dataSources,
                               List<String> rraList)
                        throws Exception
Specified by:
createDefinition in interface RrdStrategy
Throws:
Exception

createFile

public void createFile(Object rrdDef)
                throws 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
Throws:
Exception

openFile

public Object openFile(String fileName)
                throws Exception
Opens the JRobin RrdDb by name and returns it.

Specified by:
openFile in interface RrdStrategy
Throws:
Exception

updateFile

public void updateFile(Object rrdFile,
                       String owner,
                       String data)
                throws Exception
Creates a sample from the JRobin RrdDb and passes in the data provided.

Specified by:
updateFile in interface RrdStrategy
Throws:
Exception

initialize

public void initialize()
                throws 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:
Exception

graphicsInitialize

public void graphicsInitialize()
                        throws Exception
Specified by:
graphicsInitialize in interface RrdStrategy
Throws:
Exception

fetchLastValue

public Double fetchLastValue(String fileName,
                             String ds,
                             int interval)
                      throws NumberFormatException,
                             RrdException
Fetch the last value from the JRobin RrdDb file.

Specified by:
fetchLastValue in interface RrdStrategy
Throws:
NumberFormatException
RrdException

fetchLastValue

public Double fetchLastValue(String fileName,
                             String ds,
                             String consolidationFunction,
                             int interval)
                      throws RrdException
Specified by:
fetchLastValue in interface RrdStrategy
Throws:
RrdException

fetchLastValueInRange

public Double fetchLastValueInRange(String fileName,
                                    String ds,
                                    int interval,
                                    int range)
                             throws NumberFormatException,
                                    RrdException
Specified by:
fetchLastValueInRange in interface RrdStrategy
Throws:
NumberFormatException
RrdException

createGraph

public InputStream createGraph(String command,
                               File workDir)
                        throws IOException,
                               RrdException
Specified by:
createGraph in interface RrdStrategy
Throws:
IOException
RrdException

createGraphReturnDetails

public RrdGraphDetails createGraphReturnDetails(String command,
                                                File workDir)
                                         throws 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:
createGraphReturnDetails in interface RrdStrategy
Throws:
IOException
RrdException

promoteEnqueuedFiles

public void promoteEnqueuedFiles(Collection<String> rrdFiles)
Specified by:
promoteEnqueuedFiles in interface RrdStrategy

createGraphDef

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

getStats

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

Specified by:
getStats in interface RrdStrategy

getGraphLeftOffset

public int getGraphLeftOffset()
Specified by:
getGraphLeftOffset in interface RrdStrategy

getGraphRightOffset

public int getGraphRightOffset()
Specified by:
getGraphRightOffset in interface RrdStrategy

getGraphTopOffsetWithText

public int getGraphTopOffsetWithText()
Specified by:
getGraphTopOffsetWithText in interface RrdStrategy

getDefaultFileExtension

public String getDefaultFileExtension()
Specified by:
getDefaultFileExtension in interface RrdStrategy

tokenizeWithQuotingAndEscapes

public static String[] tokenizeWithQuotingAndEscapes(String line,
                                                     String delims,
                                                     boolean processQuoted)

tokenizeWithQuotingAndEscapes

public static String[] tokenizeWithQuotingAndEscapes(String line,
                                                     String delims,
                                                     boolean processQuoted,
                                                     String tokens)
Tokenize a String into an array of Strings.

Parameters:
line - the string to tokenize
delims - a string containing zero or more characters to treat as a delimiter
processQuoted - whether or not to process escaped values inside quotes
tokens - custom escaped tokens to pass through, escaped. For example, if tokens contains "lsg", then \l, \s, and \g will be passed through unescaped.
Returns:

escapeIfNotPathSepInDEF

public static char[] escapeIfNotPathSepInDEF(char encountered,
                                             char escaped,
                                             StringBuffer currToken)


Copyright © 2008. All Rights Reserved.