org.javasimon
Interface Simon

All Superinterfaces:
HasAttributes
All Known Subinterfaces:
Counter, Stopwatch
All Known Implementing Classes:
AbstractSimon, CounterImpl, NullCounter, NullSimon, NullStopwatch, StopwatchImpl, UnknownSimon

public interface Simon
extends HasAttributes

Simon interface contains common functions related to Simon management - enable/disable and hierarchy. It does not contain any real action method - these are in specific interfaces that describes purpose of the particular type of monitor.

Author:
Richard "Virgo" Richter
See Also:
Manager, for Simon counting some events, for Simon measuring time spans

Method Summary
 long getFirstUsage()
          Returns ms timestamp of the first usage of this Simon.
 List<Simon> getChildren()
          Returns list of children - direct sub-simons.
 long getLastReset()
          Returns ms timestamp of the last recent usage of the reset() method on the Simon.
 long getLastUsage()
          Returns ms timestamp of the last usage of this Simon.
 String getName()
          Returns Simon name.
 String getNote()
          Returns note for the Simon.
 Simon getParent()
          Returns parent Simon.
 SimonState getState()
          Returns state of the Simon that can be enabled, disabled or ihnerited.
 boolean isEnabled()
          Returns true, if the Simon is enabled or if the enabled state is inherited.
 Simon reset()
          Resets the Simon values related to the measuring, timestamps and so on - usage timestamps, state, attributes are not affected.
 Sample sample()
          Samples Simon values and returns them in a Java Bean derived from Sample interface.
 Sample sampleAndReset()
          Samples Simon values and returns them in a Java Bean derived from Sample interface and resets the Simon.
 void setNote(String note)
          Sets note for the Simon.
 void setState(SimonState state, boolean overrule)
          Sets the state of the Simon.
 
Methods inherited from interface org.javasimon.HasAttributes
getAttribute, getAttribute, getAttributeNames, getCopyAsSortedMap, removeAttribute, setAttribute
 

Method Detail

getName

String getName()
Returns Simon name. Simon name is always fully qualified and determines also position of the Simon in the monitor hierarchy. Simon name can be null for anonymous Simons.

Returns:
name of the Simon

getParent

Simon getParent()
Returns parent Simon.

Returns:
parent Simon

getChildren

List<Simon> getChildren()
Returns list of children - direct sub-simons.

Returns:
list of children

getState

SimonState getState()
Returns state of the Simon that can be enabled, disabled or ihnerited.

Returns:
state of the Simon

setState

void setState(SimonState state,
              boolean overrule)
Sets the state of the Simon. It must be specified whether to propagate the change and overrule states of all sub-simons which effectively sets the same state to the whole subtree. If subtree is not overruled, some Simons (with their subtrees) may not be affected by this change.

Parameters:
state - a new state.
overrule - specifies whether this change is forced to the whole subtree.

isEnabled

boolean isEnabled()
Returns true, if the Simon is enabled or if the enabled state is inherited.

Returns:
true, if the Simon is effectively enabled

reset

Simon reset()
Resets the Simon values related to the measuring, timestamps and so on - usage timestamps, state, attributes are not affected. Timestamp of the last reset can be obtained by the method getLastReset(). Reset is perfomed even for disabled Simons.

Returns:
returns this

getLastReset

long getLastReset()
Returns ms timestamp of the last recent usage of the reset() method on the Simon. Returns 0 if reset was not called yet. This timestamp is useful for rate measuring when reset is called on a regular basis - likely via sampleAndReset(). While client code could store the timestamp too it is not necessary with this method.

Returns:
ms timestamp of the last reset or 0 if reset was not called yet

getNote

String getNote()
Returns note for the Simon. Note enables Simon with an additional information in human readable form.

Returns:
note for the Simon.

setNote

void setNote(String note)
Sets note for the Simon. Note enables Simon with an additional information in human readable form.

Parameters:
note - note for the Simon.

getFirstUsage

long getFirstUsage()
Returns ms timestamp of the first usage of this Simon. First and last usage are updated when monitor performs the measuring (start/stop/count/etc). They are not updated when values are obtained from the monitor.

Returns:
ms timestamp of the first usage

getLastUsage

long getLastUsage()
Returns ms timestamp of the last usage of this Simon. First and last usage are updated when monitor performs the measuring (start/stop/count/etc). They are not updated when values are obtained from the monitor.

Returns:
ms timestamp of the last usage

sample

Sample sample()
Samples Simon values and returns them in a Java Bean derived from Sample interface.

Returns:
sample containing all Simon values

sampleAndReset

Sample sampleAndReset()
Samples Simon values and returns them in a Java Bean derived from Sample interface and resets the Simon. Operation is synchronized to assure atomicity.

Returns:
sample containing all Simon values


Copyright © 2013. All Rights Reserved.