|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.opennms.netmgt.rrd.QueuingRrdStrategy
public class QueuingRrdStrategy
Provides queueing implementation of RrdStrategy. In order to provide a more scalable collector. We created a queuing RrdStrategy that enabled the system to amortize the high cost of opening an round robin database across multiple updates. This RrdStrategy implementation enqueues the create and update operations on a per file basis and maintains a set of threads that process enqueued work file by file. If the I/O system can keep up with the collection threads while performing only a single update per file then eventually all the data is processed and the threads sleep until there is more work to do. If the I/O system is initially slower than than the collection threads then work will enqueue here and the write threads will get behind. As this happens each file will eventually have more than a single update enqueued and therefore the number of updates pushed thru the system will increase because more then one will be output per 'open' Eventually, the I/O system and the collection system will balance out. When this happens all data will be collected but will not be output to the rrd files until the next time the file is processed by the write threads. As another performance improving strategy. The queue distinguishes between files with signficant vs insignifact updates. Files with only insignificant updates are put at the lowest priority and are only written when the highest priority updates have been written This implementation delegates all the actual writing to another RrdStrategy implementation. System properites effecting the operation: org.opennms.rrd.queuing.writethreads: (default 2) The number of rrd write threads that process the queue org.opennms.rrd.queuing.queueCreates: (default true) indicates whether rrd file creates should be queued or processed synchronously org.opennms.rrd.queuing.maxInsigUpdateSeconds: (default 0) the number of seconds over which all files with significant updates only should be promoted onto the significant less. This is to ensure they don't stay unprocessed forever. Zero means not promotion. org.opennms.rrd.queuing.modulus: (default 10000) the number of updates the get enqueued between statistics output org.opennms.rrd.queuing.category: (default "UNCATEGORIZED") the log category to place the statistics output in TODO: Promote files when ZeroUpdate operations can't be merged. This may be a collection miss which we want to push thru. It should also help with memory. TODO: Set an upper bound on enqueued operations TODO: Provide an event that will write data for a particular file... Say right before we try to graph it.
| Nested Class Summary | |
|---|---|
class |
QueuingRrdStrategy.CreateOperation
This class represents an operation to create an rrd file |
class |
QueuingRrdStrategy.UpdateOperation
Represents an update to a rrd file. |
class |
QueuingRrdStrategy.ZeroUpdateOperation
Represents an update whose value is 0. |
| Constructor Summary | |
|---|---|
QueuingRrdStrategy(RrdStrategy delegate)
|
|
| Method Summary | |
|---|---|
void |
addOperation(org.opennms.netmgt.rrd.QueuingRrdStrategy.Operation op)
Add an operation to the queue. |
void |
closeFile(java.lang.Object rrd)
This closes the supplied round robin database |
java.lang.Object |
createDefinition(java.lang.String creator,
java.lang.String directory,
java.lang.String rrdName,
int step,
java.util.List dataSources,
java.util.List rraList)
Create a round robin database definition from the supplied parameters. |
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)
|
void |
createFile(java.lang.Object op)
Creates the round robin database defined by the supplied definition. |
java.io.InputStream |
createGraph(java.lang.String command,
java.io.File workDir)
Creates an InputStream representing the bytes of a graph created from round robin data. |
void |
ensureThreadsStarted()
Ensure that we have threads started to process the queue. |
java.lang.Double |
fetchLastValue(java.lang.String rrdFile,
int interval)
Fetches the last value from the round robin database with the given name. |
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 |
getDefaultFileExtension()
Get the file extension appropriate for files of this type |
RrdStrategy |
getDelegate()
|
int |
getGraphRightOffset()
Returns the number of pixels that the right-hand side of the graph is offset from the right side of the created image. |
int |
getGraphTopOffsetWithText()
Returns the number of pixels that the top of the graph is offset from the top of the created image if there is single line of header text. |
java.lang.String |
getLapTime()
|
java.util.LinkedList |
getNext()
Get the operations for the next file that should be worked on. |
java.lang.String |
getStats()
Print queue statistics. |
void |
graphicsInitialize()
This Initializes the graphics subsystem only. |
void |
initialize()
Initialize the appropriate round robin system |
void |
logStats()
|
org.opennms.netmgt.rrd.QueuingRrdStrategy.Operation |
makeCreateOperation(java.lang.String fileName,
java.lang.Object rrdDef)
|
org.opennms.netmgt.rrd.QueuingRrdStrategy.Operation |
makeUpdateOperation(java.lang.String fileName,
java.lang.String owner,
java.lang.String update)
|
java.lang.Object |
openFile(java.lang.String fileName)
Opens the round robin database with the supplied name. |
void |
run()
|
void |
updateFile(java.lang.Object rrdFile,
java.lang.String owner,
java.lang.String data)
Updates the supplied round robin database with the given timestamp:value point |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public QueuingRrdStrategy(RrdStrategy delegate)
| Method Detail |
|---|
public org.opennms.netmgt.rrd.QueuingRrdStrategy.Operation makeCreateOperation(java.lang.String fileName,
java.lang.Object rrdDef)
public org.opennms.netmgt.rrd.QueuingRrdStrategy.Operation makeUpdateOperation(java.lang.String fileName,
java.lang.String owner,
java.lang.String update)
public void addOperation(org.opennms.netmgt.rrd.QueuingRrdStrategy.Operation op)
public void ensureThreadsStarted()
public java.util.LinkedList getNext()
public RrdStrategy getDelegate()
public void closeFile(java.lang.Object rrd)
throws java.lang.Exception
RrdStrategy
closeFile in interface RrdStrategyrrd - an rrd object created using openFile
java.lang.Exception - if an error occurs closing the file
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
java.lang.Exception
public java.lang.Object createDefinition(java.lang.String creator,
java.lang.String directory,
java.lang.String rrdName,
int step,
java.util.List dataSources,
java.util.List rraList)
throws java.lang.Exception
RrdStrategy
createDefinition in interface RrdStrategycreator - -
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 datasources to use for round robin databaserraList - -
a List of the round robin archives to create in the database
java.lang.Exception - If an error occurs while creating the definition
public void createFile(java.lang.Object op)
throws java.lang.Exception
RrdStrategy
createFile in interface RrdStrategyop - an round robin database definition created using the
createDefinition call.
java.lang.Exception - if an error occurs create the file
public void initialize()
throws java.lang.Exception
RrdStrategy
initialize in interface RrdStrategyjava.lang.Exception - if an Error occurs
public void graphicsInitialize()
throws java.lang.Exception
RrdStrategy
graphicsInitialize in interface RrdStrategyjava.lang.Exception
public java.lang.Object openFile(java.lang.String fileName)
throws java.lang.Exception
RrdStrategy
openFile in interface RrdStrategyfileName - the name of the associated rrd file
java.lang.Exception - if an error occurs opening the file
public void updateFile(java.lang.Object rrdFile,
java.lang.String owner,
java.lang.String data)
throws java.lang.Exception
RrdStrategy
updateFile in interface RrdStrategyrrdFile - an rrd object created using openFileowner - the owner of the rrddata - a string of the form java.lang.Exception - if an error occurs updating the file
public java.lang.Double fetchLastValue(java.lang.String rrdFile,
int interval)
throws java.lang.NumberFormatException,
RrdException
RrdStrategy
fetchLastValue in interface RrdStrategyrrdFile - a name the represents a round robin databaseinterval - a step interval of the round robin database
java.lang.NumberFormatException
RrdException
public java.lang.Double fetchLastValueInRange(java.lang.String rrdFile,
int interval,
int range)
throws java.lang.NumberFormatException,
RrdException
RrdStrategy
fetchLastValueInRange in interface RrdStrategyrrdFile - a name the represents a round robin databaseinterval - a step interval of the round robin databaserange - an acceptable range for which the last value will be returned
java.lang.NumberFormatException
RrdException
public java.io.InputStream createGraph(java.lang.String command,
java.io.File workDir)
throws java.io.IOException,
RrdException
RrdStrategy
createGraph in interface RrdStrategycommand - the command needed to create the graphworkDir - the directory that all referenced files are relative to
java.io.IOException - if an IOError occurs
RrdException - if an RRD error occurspublic void run()
run in interface java.lang.Runnablepublic java.lang.String getStats()
getStats in interface RrdStrategypublic void logStats()
public java.lang.String getLapTime()
public int getGraphRightOffset()
RrdStrategy
getGraphRightOffset in interface RrdStrategypublic int getGraphTopOffsetWithText()
RrdStrategy
getGraphTopOffsetWithText in interface RrdStrategypublic java.lang.String getDefaultFileExtension()
RrdStrategy
getDefaultFileExtension in interface RrdStrategy
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||