Package org.opennms.netmgt.rrd.rrdtool
Class MultithreadedJniRrdStrategy
- java.lang.Object
-
- org.opennms.netmgt.rrd.rrdtool.AbstractJniRrdStrategy<MultithreadedJniRrdStrategy.CreateCommand,MultithreadedJniRrdStrategy.UpdateCommand>
-
- org.opennms.netmgt.rrd.rrdtool.MultithreadedJniRrdStrategy
-
- All Implemented Interfaces:
RrdStrategy<MultithreadedJniRrdStrategy.CreateCommand,MultithreadedJniRrdStrategy.UpdateCommand>
public class MultithreadedJniRrdStrategy extends AbstractJniRrdStrategy<MultithreadedJniRrdStrategy.CreateCommand,MultithreadedJniRrdStrategy.UpdateCommand>
A multi-threaded JNI-based RRD strategy using jrrd2.- Author:
- jwhite
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MultithreadedJniRrdStrategy.CreateCommand
static class
MultithreadedJniRrdStrategy.UpdateCommand
-
Constructor Summary
Constructors Constructor Description MultithreadedJniRrdStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
closeFile(MultithreadedJniRrdStrategy.UpdateCommand update)
The 'closes' the rrd file.MultithreadedJniRrdStrategy.CreateCommand
createDefinition(java.lang.String creator, java.lang.String directory, java.lang.String rrdName, int step, java.util.List<RrdDataSource> dataSources, java.util.List<java.lang.String> rraList)
Create a round robin database definition from the supplied parameters.void
createFile(MultithreadedJniRrdStrategy.CreateCommand createCommand)
Creates a the rrd file from the rrdDefinition.java.lang.Double
fetchLastValue(java.lang.String rrdFile, java.lang.String ds, int interval)
Fetches the last value from the round robin database with the given name.java.lang.Double
fetchLastValue(java.lang.String rrdFile, java.lang.String ds, java.lang.String consolidationFunction, int interval)
Fetches the last value from the round robin database with the given name.java.lang.Double
fetchLastValueInRange(java.lang.String rrdFile, java.lang.String ds, int interval, int range)
Fetches the last value from the round robin database with the given name within a time range.java.util.Properties
getConfigurationProperties()
getConfigurationPropertiesMultithreadedJniRrdStrategy.UpdateCommand
openFile(java.lang.String fileName)
Opens the round robin database with the supplied name.void
setConfigurationProperties(java.util.Properties configurationParameters)
setConfigurationPropertiesvoid
updateFile(MultithreadedJniRrdStrategy.UpdateCommand update, java.lang.String owner, java.lang.String data)
Updates the supplied round robin database with the given timestamp:value point-
Methods inherited from class org.opennms.netmgt.rrd.rrdtool.AbstractJniRrdStrategy
createGraph, createGraphReturnDetails, getDefaultFileExtension, getGraphLeftOffset, getGraphRightOffset, getGraphTopOffsetWithText, getStats, promoteEnqueuedFiles
-
-
-
-
Method Detail
-
getConfigurationProperties
public java.util.Properties getConfigurationProperties()
getConfigurationProperties
- Returns:
- a
Properties
object.
-
setConfigurationProperties
public void setConfigurationProperties(java.util.Properties configurationParameters)
setConfigurationProperties
- Parameters:
configurationParameters
- aProperties
object.
-
closeFile
public void closeFile(MultithreadedJniRrdStrategy.UpdateCommand update) 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.- Parameters:
update
- an rrd object created using openFile- Throws:
java.lang.Exception
- if any.
-
createDefinition
public MultithreadedJniRrdStrategy.CreateCommand createDefinition(java.lang.String creator, java.lang.String directory, java.lang.String rrdName, int step, java.util.List<RrdDataSource> dataSources, java.util.List<java.lang.String> rraList) throws java.lang.Exception
Create a round robin database definition from the supplied parameters. This definition is used in the createFile call to create the actual file.- Parameters:
creator
- - A string representing who is creating this file for use in log msgsdirectory
- - The directory to create the file inrrdName
- - The name to use for the round robin databasestep
- - the step for the databasedataSources
- - the data sources to use for round robin databaserraList
- - a List of the round robin archives to create in the database. defines after which time the data is condensed to a defined lower step- Returns:
- an object representing the definition of an round robin database. Can be null if the database exists already.
- Throws:
java.lang.Exception
- If an error occurs while creating the definition
-
createFile
public void createFile(MultithreadedJniRrdStrategy.CreateCommand createCommand) 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.- Parameters:
createCommand
- aString
object.- Throws:
java.lang.Exception
- if any.
-
openFile
public MultithreadedJniRrdStrategy.UpdateCommand openFile(java.lang.String fileName) throws java.lang.Exception
Opens the round robin database with the supplied name. It is assumed the name refers to a round robin database appropriate for this strategy implementation 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.- 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(MultithreadedJniRrdStrategy.UpdateCommand update, java.lang.String owner, java.lang.String data) throws java.lang.Exception
Updates the supplied round robin database with the given timestamp:value point 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.- Parameters:
update
- an rrd object created using openFileowner
- the owner of the rrddata
- a string of the form: - Throws:
java.lang.Exception
- if an error occurs updating the file
-
fetchLastValue
public java.lang.Double fetchLastValue(java.lang.String rrdFile, java.lang.String ds, int interval) throws java.lang.NumberFormatException, RrdException
Fetches the last value from the round robin database with the given name. The interval passed in should be the interval associated with the round robin database. Fetches the last value directly from the rrd file using the JNI Interface.- Parameters:
rrdFile
- a name the represents a round robin databaseds
- a name the represents a data source to be usedinterval
- 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
- if any.RrdException
- if any.
-
fetchLastValue
public java.lang.Double fetchLastValue(java.lang.String rrdFile, java.lang.String ds, java.lang.String consolidationFunction, int interval)
Fetches the last value from the round robin database with the given name. The interval passed in should be the interval associated with the round robin database.- Parameters:
rrdFile
- a name the represents a round robin databaseds
- a name the represents a data source to be usedconsolidationFunction
- aString
object.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)
-
fetchLastValueInRange
public java.lang.Double fetchLastValueInRange(java.lang.String rrdFile, java.lang.String ds, int interval, int range) throws java.lang.NumberFormatException, RrdException
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.- Parameters:
rrdFile
- a name the represents a round robin databaseds
- a name the represents a data source to be usedinterval
- a step interval of the round robin databaserange
- 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:
java.lang.NumberFormatException
- if any.RrdException
- if any.
-
-