|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface StopwatchStorage
Interface describes the basic functionality a Stopwatch storage should support.
A storage is a place where collected measurements are stored. By implementig
this interface one can provide an "in-memory", "database", "file" or any other
type of storage.
All classes implementing this interface are considered Stopwatch engines.
By default Stopwatch uses DefaultHSQLInMemoryStorage
to
store data in "in-memory" HSQL database.
Stopwatch can be configured to use another storage by :
-Dcom.commsen.stopwatch.storage=<fully_qualified_class_name>
JVM parameterstorage=<fully_qualified_class_name>
storage
should be compatible with used engine
.
For example using MemoryStopwatchEngine
with DefaultHSQLInMemoryStorage
will work
(because MemoryStopwatchEngine
extends
DefaultStopwatchEngine
) but the reports
will not contain memory usage information.
Method Summary | |
---|---|
void |
close()
Called when engine is about to be stopped or for some other reason will no more use this storage. |
boolean |
completeRecord(long id,
java.lang.Object[] parameters)
Instructs the storage to complete (at least remember the time) the record identified by given parameters. |
void |
freeze()
Called when engine is about to be paused or for some other reason will temporary not use this storage. |
Report[] |
getAllByGroupReports()
Implementing methods should generate and return an array of reports. |
Report[] |
getAllByLabelReports()
Implementing methods should generate and return an array of reports. |
Report[] |
getGroupReports(java.lang.String group)
Implementing methods should generate and return an array of reports. |
Report[] |
getLabelReports(java.lang.String label)
Implementing methods should generate and return an array of reports. |
long[] |
getLoad(java.lang.String group,
java.lang.String label,
int periodField,
int numberOfPeriods)
Implementing methods should generate and return information of how many instances of the code specified by group and label ware running for the last numberOfPeriods periods. |
java.util.Properties |
getProperties()
Returns storage properties. |
Report |
getReport(java.lang.String group,
java.lang.String label)
Implementing methods should generate and return a single report for provided group and label If there is no enough data to produce the report, method should return null |
Report[] |
getReports()
Implementing methods should generate and return an array of reports. |
long |
newCompleteRecord(java.lang.Object[] startParameters,
java.lang.Object[] endParameters)
Instructs the storage to create new complete record and store passed parameters. |
long |
newRecord(java.lang.Object[] parameters)
Instructs the storage to create new record and store passed parameters. |
void |
open()
Called when engine is about to use the storage for the first time. |
boolean |
removeRecord(long id)
Instructs the storage to remove the record identified by given parameters. |
void |
setDebugEnabled(boolean debugEnabled)
Instructs the storage to disable/enable debug information. |
void |
setProperties(java.util.Properties properties)
Called by Stopwatch to set storage properties . |
void |
unfreeze()
Called when engine is about to be resumed. |
Method Detail |
---|
void open() throws StopwatchStorageException
StopwatchStorageException
- if there is problem preparing the storage.void freeze() throws StopwatchStorageException
StopwatchStorageException
- if there is a problem with freezing the storage.void unfreeze() throws StopwatchStorageException
StopwatchStorageException
- if there is a problem with unfreezing the storage.void close() throws StopwatchStorageException
StopwatchStorageException
- if there is a problem closing the storagelong newRecord(java.lang.Object[] parameters) throws StopwatchStorageException
parameters
-
StopwatchStorageException
boolean removeRecord(long id) throws StopwatchStorageException
id
- of the database record to be removedparameters
- used to find the record
true
if record was removed successfuly, false
otherwise
StopwatchStorageException
- on errorboolean completeRecord(long id, java.lang.Object[] parameters) throws StopwatchStorageException
id
- of the database record to be updatedparameters
- used to find the record
true
if record was completed successfuly, false
otherwise
StopwatchStorageException
- on errorlong newCompleteRecord(java.lang.Object[] startParameters, java.lang.Object[] endParameters) throws StopwatchStorageException
startParameters
- parameters describing start conditionendParameters
- parameters describing end condition
true
if record was completed successfuly, false
otherwise
StopwatchStorageException
- on errorReport[] getReports()
null
Report[] getAllByGroupReports()
null
Report[] getAllByLabelReports()
null
Report getReport(java.lang.String group, java.lang.String label)
null
group
- the group for which report should be generatedlabel
- the label for which report should be generated
Report[] getGroupReports(java.lang.String group)
null
group
- the name of group for which report should be generated
Report[] getLabelReports(java.lang.String label)
null
label
- the label for which report should be generated
long[] getLoad(java.lang.String group, java.lang.String label, int periodField, int numberOfPeriods)
group
and label
ware running for the last numberOfPeriods
periods.
Period length is defined by periodField
which can be one of Calendar.FIELD_NAME
For example to see how many instances of code labeled "l1" in group "g1" were running per minute for the last 30 minutes, one could use:
long[] load = Stopwatch.getLoad("g1, "l1", Calendar.MINUTE
, 30);
which will forward the call to the appropriate storage implementation. In this case load[0]
will contain the
number of code instances running 30 minutes ago and load[29]
number of code instances running in the last minute.
If group
is null
- summary load of all masurments labeled label
should be returned.
If label
is null
- summary load of all masurments in group gtroup
should be returned.
If both group
and label
are null
- summary load of all masurments should be returned.
group
- the group for which load report should be generatedlabel
- the label for which load report should be generatedperiodField
- can be one of Calendar.FIELD_NAME
numberOfPeriods
- number of periods
numberOfPeriods
where every element represents the load for given pariod.void setDebugEnabled(boolean debugEnabled)
debugEnabled
- should debug information be generatedvoid setProperties(java.util.Properties properties)
properties
- the propertiesjava.util.Properties getProperties()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |