com.jamonapi
Class FactoryEnabled

java.lang.Object
  extended by com.jamonapi.FactoryEnabled
All Implemented Interfaces:
MonitorFactoryInterface

public class FactoryEnabled
extends java.lang.Object
implements MonitorFactoryInterface

Factory that creates Monitors. Main workhorse for creating monitors. This can be created directly. MonitorFactory is simply a wrapper that makes calling this class simpler. MonitorFactory contains a static reference to a FactoryEnabled class.

Author:
steve souza

Field Summary
 
Fields inherited from interface com.jamonapi.MonitorFactoryInterface
VERSION
 
Constructor Summary
FactoryEnabled()
          Creates a new instance of MonFactoryEnabled.
 
Method Summary
 Monitor add(MonKey key, double value)
          Used when you want to create your own key for the monitor.
 Monitor add(java.lang.String label, java.lang.String units, double value)
          Return a monitor with the given label and units.
 void disableTotalKeySizeTracking()
           
 void enableActivityTracking(boolean enable)
          This determines if activity tracking in ranges is enabled.
 void enableGlobalActive(boolean enable)
           
 void enableTotalKeySizeTracking()
          This will keep track of the total size of of the keys used to store the monitors which can be useful in keeping track of memory used by JAMon.
 boolean exists(MonKey key)
          Return true if the monitor associated with the passed in key exists
 boolean exists(java.lang.String label, java.lang.String units)
          Return true if the monitor associated with the passed in label and units exists
 MonitorComposite getComposite(java.lang.String units)
          Pass in the units (or range type) and return all monitors of that type.
 java.util.Map getMap()
          Get the backing map that holds the the Monitors.
 int getMaxNumMonitors()
          Return the max number of configured of monitors.
 int getMaxSqlSize()
          Return the size that sql statements can be before truncating them.
 Monitor getMonitor()
          Returns a non-TimeMonitor that won't update the jamon factory.
 Monitor getMonitor(MonKey key)
          Get the monitor associated with the passed in key.
 Monitor getMonitor(java.lang.String label, java.lang.String units)
          Get the monitor with the passed in label, and units.
 int getNumRows()
          Get the number of monitors in this factory
 java.lang.String[] getRangeHeader()
          Return the header associated with range names
 java.lang.Object[][] getRangeNames()
          Return an array of range names.
 MonitorComposite getRootMonitor()
          getComposite("AllMonitors") is the same as getRootMonitor()
 Monitor getTimeMonitor(MonKey key)
          Get the time monitor associated with the passed in key.
 Monitor getTimeMonitor(java.lang.String label)
          Get the time monitor associated with the passed in label.
 long getTotalKeySize()
          Returns the total of all keys in the monitor map.
 java.lang.String getVersion()
          Get JAMon's version.
 boolean isActivityTrackingEnabled()
           
 boolean isGlobalActiveEnabled()
           
 boolean isTotalKeySizeTrackingEnabled()
           
 java.util.Iterator iterator()
          Deprecated.  
 void remove(MonKey key)
          Remove the monitor associated with the passed in key
 void remove(java.lang.String label, java.lang.String units)
          Remove the monitor associated with the passed in label and units
 void reset()
          Wipe out existing jamon data.
 void setMap(java.util.Map map)
          allows for using a faster/open source map.
 void setMaxNumMonitors(int maxMonitors)
          Set the max number of monitors that can be tracked.
 void setMaxSqlSize(int size)
          Set the maximum size for a sql statement.
 void setRangeDefault(java.lang.String key, RangeHolder rangeHolder)
          Note if a null is passed in it will have the same effect as an empty RangeHolder (i.e.
 Monitor start()
          Returns a TimeMonitor that won't update the jamon factory.
 Monitor start(MonKey key)
          Start using the passed in key.
 Monitor start(java.lang.String label)
          Return a time monitor (the units are implied and are ms.
 Monitor startNano(MonKey key)
          Provide your own key to a nanosecond timer
 Monitor startNano(java.lang.String label)
          Create a timing monitor that uses nanosecond granularity (1,000,000 ns.=1 ms.)
 Monitor startPrimary(MonKey key)
          Start a monitor with the specified key and mark it as primary
 Monitor startPrimary(java.lang.String label)
          Start a time monitor and mark it as primary
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FactoryEnabled

public FactoryEnabled()
Creates a new instance of MonFactoryEnabled. Also initializes the standard JAMon time monitor range (ms.)

Method Detail

add

public Monitor add(MonKey key,
                   double value)
Description copied from interface: MonitorFactoryInterface
Used when you want to create your own key for the monitor. This works similarly to a group by clause where the key is any columns used after the group by clause.

Specified by:
add in interface MonitorFactoryInterface

add

public Monitor add(java.lang.String label,
                   java.lang.String units,
                   double value)
Description copied from interface: MonitorFactoryInterface
Return a monitor with the given label and units. Note label has an effect on what range is used. If no range is associated with units then it will use the null range (i.e. no range)

Sample Call: factory.add("com.fdsapi.MyException", "error", 1);

Specified by:
add in interface MonitorFactoryInterface

start

public Monitor start(MonKey key)
Description copied from interface: MonitorFactoryInterface
Start using the passed in key. Note activity stats are incremented

Specified by:
start in interface MonitorFactoryInterface

start

public Monitor start(java.lang.String label)
Description copied from interface: MonitorFactoryInterface
Return a time monitor (the units are implied and are ms. Note activity stats are incremented

Specified by:
start in interface MonitorFactoryInterface

startNano

public Monitor startNano(java.lang.String label)
Description copied from interface: MonitorFactoryInterface
Create a timing monitor that uses nanosecond granularity (1,000,000 ns.=1 ms.)

Specified by:
startNano in interface MonitorFactoryInterface

startNano

public Monitor startNano(MonKey key)
Description copied from interface: MonitorFactoryInterface
Provide your own key to a nanosecond timer

Specified by:
startNano in interface MonitorFactoryInterface

startPrimary

public Monitor startPrimary(MonKey key)
Description copied from interface: MonitorFactoryInterface
Start a monitor with the specified key and mark it as primary

Specified by:
startPrimary in interface MonitorFactoryInterface

startPrimary

public Monitor startPrimary(java.lang.String label)
Description copied from interface: MonitorFactoryInterface
Start a time monitor and mark it as primary

Specified by:
startPrimary in interface MonitorFactoryInterface

start

public Monitor start()
Description copied from interface: MonitorFactoryInterface
Returns a TimeMonitor that won't update the jamon factory.

Specified by:
start in interface MonitorFactoryInterface

getMonitor

public Monitor getMonitor()
Description copied from interface: MonitorFactoryInterface
Returns a non-TimeMonitor that won't update the jamon factory.

Specified by:
getMonitor in interface MonitorFactoryInterface

setMap

public void setMap(java.util.Map map)
allows for using a faster/open source map.

Specified by:
setMap in interface MonitorFactoryInterface

getMonitor

public Monitor getMonitor(MonKey key)
Description copied from interface: MonitorFactoryInterface
Get the monitor associated with the passed in key. It will be created if it doesn't exist

Specified by:
getMonitor in interface MonitorFactoryInterface

getMonitor

public Monitor getMonitor(java.lang.String label,
                          java.lang.String units)
Description copied from interface: MonitorFactoryInterface
Get the monitor with the passed in label, and units. It will be created if it doesn't exist

Specified by:
getMonitor in interface MonitorFactoryInterface

getTimeMonitor

public Monitor getTimeMonitor(MonKey key)
Description copied from interface: MonitorFactoryInterface
Get the time monitor associated with the passed in key. It will be created if it doesn't exist. The units are in ms.

Specified by:
getTimeMonitor in interface MonitorFactoryInterface

getTimeMonitor

public Monitor getTimeMonitor(java.lang.String label)
Description copied from interface: MonitorFactoryInterface
Get the time monitor associated with the passed in label. It will be created if it doesn't exist. The units are in ms.

Specified by:
getTimeMonitor in interface MonitorFactoryInterface

setRangeDefault

public void setRangeDefault(java.lang.String key,
                            RangeHolder rangeHolder)
Note if a null is passed in it will have the same effect as an empty RangeHolder (i.e. it will perform null operations)

Specified by:
setRangeDefault in interface MonitorFactoryInterface

getRangeHeader

public java.lang.String[] getRangeHeader()
Description copied from interface: MonitorFactoryInterface
Return the header associated with range names

Specified by:
getRangeHeader in interface MonitorFactoryInterface

getRangeNames

public java.lang.Object[][] getRangeNames()
Description copied from interface: MonitorFactoryInterface
Return an array of range names. This is dynamic based on what was passed to setRangeDefault

Specified by:
getRangeNames in interface MonitorFactoryInterface

remove

public void remove(MonKey key)
Description copied from interface: MonitorFactoryInterface
Remove the monitor associated with the passed in key

Specified by:
remove in interface MonitorFactoryInterface

remove

public void remove(java.lang.String label,
                   java.lang.String units)
Description copied from interface: MonitorFactoryInterface
Remove the monitor associated with the passed in label and units

Specified by:
remove in interface MonitorFactoryInterface

exists

public boolean exists(MonKey key)
Description copied from interface: MonitorFactoryInterface
Return true if the monitor associated with the passed in key exists

Specified by:
exists in interface MonitorFactoryInterface

exists

public boolean exists(java.lang.String label,
                      java.lang.String units)
Description copied from interface: MonitorFactoryInterface
Return true if the monitor associated with the passed in label and units exists

Specified by:
exists in interface MonitorFactoryInterface

getNumRows

public int getNumRows()
Description copied from interface: MonitorFactoryInterface
Get the number of monitors in this factory

Specified by:
getNumRows in interface MonitorFactoryInterface

getRootMonitor

public MonitorComposite getRootMonitor()
getComposite("AllMonitors") is the same as getRootMonitor()

Specified by:
getRootMonitor in interface MonitorFactoryInterface

getComposite

public MonitorComposite getComposite(java.lang.String units)
Pass in the units (or range type) and return all monitors of that type. 'AllMonitors' is a special argument returns a composite of surprise surprise all monitors getComposite("AllMonitors") is the same as getRootMonitor() ;

Specified by:
getComposite in interface MonitorFactoryInterface

getVersion

public java.lang.String getVersion()
Description copied from interface: MonitorFactoryInterface
Get JAMon's version. Example: 2.0

Specified by:
getVersion in interface MonitorFactoryInterface

getTotalKeySize

public long getTotalKeySize()
Returns the total of all keys in the monitor map. If there are no entries or if tracking is disabled then 0 is returned

Specified by:
getTotalKeySize in interface MonitorFactoryInterface

reset

public void reset()
Wipe out existing jamon data. Same as instantiating a new FactoryEnabled object.

Specified by:
reset in interface MonitorFactoryInterface

enableGlobalActive

public void enableGlobalActive(boolean enable)
Specified by:
enableGlobalActive in interface MonitorFactoryInterface

isGlobalActiveEnabled

public boolean isGlobalActiveEnabled()
Specified by:
isGlobalActiveEnabled in interface MonitorFactoryInterface

iterator

@Deprecated
public java.util.Iterator iterator()
Deprecated. 

The iterator returns Monitor objects only. However, the MonKey can also be retrieved by calling mon.getMonKey(). Alternatively the backing map can be retrieved and either the MonKey or Monitor can be iterated separately.

Specified by:
iterator in interface MonitorFactoryInterface

getMap

public java.util.Map getMap()
Description copied from interface: MonitorFactoryInterface
Get the backing map that holds the the Monitors. Keys=MonKeys, values=Monitor

Specified by:
getMap in interface MonitorFactoryInterface

enableActivityTracking

public void enableActivityTracking(boolean enable)
Description copied from interface: MonitorFactoryInterface
This determines if activity tracking in ranges is enabled. Activity tracking allows you to see how performance tracks to the number of activities (monitors) that are running. For example it can let you see how your web site scales by seeing how performance correlates when 10 simultaneous pages are being invoked, or 20, 30, 40, 50 etc. Disabling or enabling will affect current monitors as well as any others that are subsequently created. One problem at this point is that any in flight monitors can be disabled/enabled while they are in flight leading to results that may be off. For this reason it is best to enable/disable before any monitors have been created or when you know none are running. A future enhancement may be to delay this capability until no monitors are running. Note disabling global active turns off a subset of this capability.

Specified by:
enableActivityTracking in interface MonitorFactoryInterface

isActivityTrackingEnabled

public boolean isActivityTrackingEnabled()
Specified by:
isActivityTrackingEnabled in interface MonitorFactoryInterface

getMaxNumMonitors

public int getMaxNumMonitors()
Description copied from interface: MonitorFactoryInterface
Return the max number of configured of monitors.

Specified by:
getMaxNumMonitors in interface MonitorFactoryInterface

setMaxNumMonitors

public void setMaxNumMonitors(int maxMonitors)
Description copied from interface: MonitorFactoryInterface
Set the max number of monitors that can be tracked. The default is unlimited. When this value is set the number of jamon monitors is capped at this number and does not grow unbounded. Once this threshold has been reached any additional are not stored in the Map and no warning is given. If the threshold is set, but the monitors currently exceed this number the current monitors remain, however no new ones will be added.

Specified by:
setMaxNumMonitors in interface MonitorFactoryInterface
Parameters:
maxMonitors - If positive then this is the max number of monitors that can be stored. 0 or negative means monitors can grow unbounded.

enableTotalKeySizeTracking

public void enableTotalKeySizeTracking()
Description copied from interface: MonitorFactoryInterface
This will keep track of the total size of of the keys used to store the monitors which can be useful in keeping track of memory used by JAMon. To have accureate measurements enableTotalKeySizeTracking() must be called before any monitors are stored.

Specified by:
enableTotalKeySizeTracking in interface MonitorFactoryInterface

disableTotalKeySizeTracking

public void disableTotalKeySizeTracking()
Specified by:
disableTotalKeySizeTracking in interface MonitorFactoryInterface

isTotalKeySizeTrackingEnabled

public boolean isTotalKeySizeTrackingEnabled()
Specified by:
isTotalKeySizeTrackingEnabled in interface MonitorFactoryInterface

getMaxSqlSize

public int getMaxSqlSize()
Description copied from interface: MonitorFactoryInterface
Return the size that sql statements can be before truncating them. This will limit the size of JAMon labels for sql statements

Specified by:
getMaxSqlSize in interface MonitorFactoryInterface
Returns:
the max size that the sql is allowed to be before being truncated.

setMaxSqlSize

public void setMaxSqlSize(int size)
Description copied from interface: MonitorFactoryInterface
Set the maximum size for a sql statement. Sql bigger than this will be truncated before a JAMon label is created via the JAMon JDBC proxy driver. This is useful to limit the size in memory that jamon occupies due to really long sql statements. For backwards compatibility The default is to not limit the statement size.

Specified by:
setMaxSqlSize in interface MonitorFactoryInterface