org.codehaus.activemq.journal
Class JournalStatsFilter

java.lang.Object
  extended byorg.codehaus.activemq.journal.JournalStatsFilter
All Implemented Interfaces:
Journal

public class JournalStatsFilter
extends Object
implements Journal

A Journal filter that captures performance statistics of the filtered Journal.

Version:
$Revision: 1.2 $

Constructor Summary
JournalStatsFilter(Journal next)
          Creates a JournalStatsFilter that captures performance information of next.
 
Method Summary
 void close()
          Close the Journal.
 void dump(IndentPrinter out)
          Writes the gathered statistics to the out object.
 JournalStatsFilter enableDetailedStats(boolean detailedStats)
           
 double getAvgSyncedLatencyMs()
          Gets the average sync write latency in ms.
 double getAvgUnSyncedLatencyMs()
          Gets the average non sync write latency in ms.
 RecordLocation getMark()
          Obtains the mark that was set in the Journal.
 RecordLocation getNextRecordLocation(RecordLocation lastLocation)
          Allows you to get the next RecordLocation after the location that is in the journal.
 double getThroughputKps()
          Gets the average throughput in k/s.
 double getThroughputRps()
          Gets the average throughput in records/s.
 double getWritesPerSecond()
          Gets the average number of writes done per second
 byte[] read(RecordLocation location)
          Reads a previously written record from the journal.
 void reset()
          Resets the stats sample.
 void setJournalEventListener(JournalEventListener eventListener)
          Registers a JournalEventListener that will receive notifications from the Journal.
 void setMark(RecordLocation recordLocator, boolean force)
          Informs the journal that all the journal space up to the location is no longer needed and can be reclaimed for reuse.
 String toString()
          Dumps the stats to a String.
 RecordLocation write(byte[] data, boolean sync)
          Writes a byte array record to the journal.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JournalStatsFilter

public JournalStatsFilter(Journal next)
Creates a JournalStatsFilter that captures performance information of next.

Parameters:
next -
Method Detail

write

public RecordLocation write(byte[] data,
                            boolean sync)
                     throws IOException
Description copied from interface: Journal
Writes a byte array record to the journal. If sync is true, then this call blocks until the data has landed on the physical disk. Otherwise, this call returns imeadiatly.

Specified by:
write in interface Journal
Parameters:
data - - the data to be written to disk.
sync - - If this call should block until the data lands on disk.
Returns:
RecordLocation the location where the data will be written to on disk.
Throws:
IOException - if the write failed.
See Also:
Journal.write(byte[], boolean)

read

public byte[] read(RecordLocation location)
            throws InvalidRecordLocationException,
                   IOException
Description copied from interface: Journal
Reads a previously written record from the journal.

Specified by:
read in interface Journal
Parameters:
location - is where to read the record from.
Returns:
the data previously written at the location.
Throws:
IOException - if the record could not be read.
InvalidRecordLocationException - if location parameter is out of range. It cannot be a location that is before the current mark.
See Also:
Journal.read(org.codehaus.activemq.journal.RecordLocation)

setMark

public void setMark(RecordLocation recordLocator,
                    boolean force)
             throws InvalidRecordLocationException,
                    IOException
Description copied from interface: Journal
Informs the journal that all the journal space up to the location is no longer needed and can be reclaimed for reuse.

Specified by:
setMark in interface Journal
Parameters:
recordLocator - the location of the record to mark. All record locations before the marked location will no longger be vaild.
force - if this call should block until the mark is set on the journal.
Throws:
InvalidRecordLocationException - if location parameter is out of range. It cannot be a location that is before the current mark.
IOException - if the record could not be read.
See Also:
Journal.setMark(org.codehaus.activemq.journal.RecordLocation, boolean)

getMark

public RecordLocation getMark()
Description copied from interface: Journal
Obtains the mark that was set in the Journal.

Specified by:
getMark in interface Journal
Returns:
the mark that was set in the Journal.
See Also:
Journal.getMark()

close

public void close()
           throws IOException
Description copied from interface: Journal
Close the Journal. This is blocking operation that waits for any pending put opperations to be forced to disk. Once the Journal is closed, all other methods of the journal should throw IllegalStateException.

Specified by:
close in interface Journal
Throws:
IOException - if an error occurs while the journal is being closed.
See Also:
Journal.close()

setJournalEventListener

public void setJournalEventListener(JournalEventListener eventListener)
Description copied from interface: Journal
Registers a JournalEventListener that will receive notifications from the Journal.

Specified by:
setJournalEventListener in interface Journal
Parameters:
eventListener - object that will receive journal events.
See Also:
Journal.setJournalEventListener(org.codehaus.activemq.journal.JournalEventListener)

getNextRecordLocation

public RecordLocation getNextRecordLocation(RecordLocation lastLocation)
                                     throws IOException,
                                            InvalidRecordLocationException
Description copied from interface: Journal
Allows you to get the next RecordLocation after the location that is in the journal.

Specified by:
getNextRecordLocation in interface Journal
Parameters:
lastLocation - the reference location the is used to find the next location. To get the oldest location available in the journal, location should be set to null.
Returns:
the next record location
Throws:
InvalidRecordLocationException - if location parameter is out of range. It cannot be a location that is before the current mark.
IOException
See Also:
Journal.getNextRecordLocation(org.codehaus.activemq.journal.RecordLocation)

dump

public void dump(IndentPrinter out)
Writes the gathered statistics to the out object.

Parameters:
out -

toString

public String toString()
Dumps the stats to a String.

See Also:
Object.toString()

enableDetailedStats

public JournalStatsFilter enableDetailedStats(boolean detailedStats)
Parameters:
detailedStats - true if details stats should be displayed by toString() and dump
Returns:

getThroughputKps

public double getThroughputKps()
Gets the average throughput in k/s.

Returns:
the average throughput in k/s.

getThroughputRps

public double getThroughputRps()
Gets the average throughput in records/s.

Returns:
the average throughput in records/s.

getWritesPerSecond

public double getWritesPerSecond()
Gets the average number of writes done per second

Returns:
the average number of writes in w/s.

getAvgSyncedLatencyMs

public double getAvgSyncedLatencyMs()
Gets the average sync write latency in ms.

Returns:
the average sync write latency in ms.

getAvgUnSyncedLatencyMs

public double getAvgUnSyncedLatencyMs()
Gets the average non sync write latency in ms.

Returns:
the average non sync write latency in ms.

reset

public void reset()
Resets the stats sample.



Copyright © 2004 Protique, Ltd.. All Rights Reserved.