com.jamonapi
Class MonitorFactory

java.lang.Object
  extended by com.jamonapi.MonitorFactory

public class MonitorFactory
extends java.lang.Object


Field Summary
static java.lang.String EXCEPTIONS_LABEL
           
 
Constructor Summary
MonitorFactory()
           
 
Method Summary
static Monitor add(MonKey key, double value)
          Used when you want to create your own key for the monitor.
static Monitor add(java.lang.String label, java.lang.String units, double value)
          Aggregate the passed in value with the monitor associated with the label, and the units.
static void disable()
          Disable MonitorFactory.
static void enable()
          Enable MonitorFactory.
static void enableGlobalActive(boolean enable)
           
static boolean exists(MonKey key)
          Return true if the monitor associated with the passed in key exists
static boolean exists(java.lang.String label, java.lang.String units)
          Determine if the monitor associated with the label, and the units currently exists.
static MonitorComposite getComposite(java.lang.String units)
          Return the composite monitor (a collection of monitors) associated with the passed in units.
static java.lang.Object[][] getData()
          This returns the data for basic data with no range info.
static MonitorFactoryInterface getDebugFactory()
          Returns the factory for creating debug monitors.
static MonitorFactoryInterface getFactory()
          Get the current Factory (could be the enabled or disabled factory depending on what is enabled)
static java.lang.String[] getHeader()
          This returns the header for basic data with no range info in the header.
static Monitor getMonitor()
           
static Monitor getMonitor(MonKey key)
          Get the monitor associated with the passed in key.
static Monitor getMonitor(java.lang.String label, java.lang.String units)
          Return the monitor associated with the label, and units.
static int getNumRows()
          This returns the number of monitors in this factory.
static java.lang.String[] getRangeHeader()
          Return the header for displaying what ranges are available.
static java.lang.Object[][] getRangeNames()
          Return the ranges in this factory.
static java.lang.String getReport()
          This returns an HTML report for basic data with no range info in the header.
static java.lang.String getReport(java.lang.String units)
          This returns an HTML report for basic data with no range info in the header for the past in units.
static MonitorComposite getRootMonitor()
          Return the composite monitor of all monitors for this factory
static Monitor getTimeMonitor(MonKey key)
          Get the time monitor associated with the passed in key.
static Monitor getTimeMonitor(java.lang.String label)
          Return the time monitor associated with the label.
static java.lang.String getVersion()
          Return the version of JAMon
static boolean isDebugEnabled()
          Is the Debug Monitor Factory currently enabled?
static boolean isEnabled()
          Is the MonitorFactory currently enabled?
static boolean isGlobalActiveEnabled()
           
 java.util.Iterator iterator()
          Iterator that contains Monitor's that are in this factory
static void main(java.lang.String[] args)
           
static void remove(MonKey key)
          Remove the monitor associated with the passed in key
static void remove(java.lang.String label, java.lang.String units)
          Remove/delete the specified monitor
static void reset()
          Reset/remove all monitors.
static void setDebugEnabled(boolean enable)
          Enable or disable the debug factory.
static void setEnabled(boolean enable)
          Enable/Disable MonitorFactory.
static void setMap(java.util.Map map)
          Use the specified map to hold the monitors.
static void setRangeDefault(java.lang.String key, RangeHolder rangeHolder)
          Associate a range with a key/unit.
static Monitor start()
          Return a timing monitor with units in milliseconds, that is not aggregated into the jamon stats.
static Monitor start(MonKey key)
          Start using the passed in key.
static Monitor start(java.lang.String label)
          Return a timing monitor with units in milliseconds.
static Monitor startPrimary(MonKey key)
          Start a monitor with the specified key and mark it as primary
static Monitor startPrimary(java.lang.String label)
          Return a timing monitor with units in milliseconds, that is not aggregated into the jamon stats.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXCEPTIONS_LABEL

public static final java.lang.String EXCEPTIONS_LABEL
See Also:
Constant Field Values
Constructor Detail

MonitorFactory

public MonitorFactory()
Method Detail

getFactory

public static MonitorFactoryInterface getFactory()
Get the current Factory (could be the enabled or disabled factory depending on what is enabled)


getDebugFactory

public static MonitorFactoryInterface getDebugFactory()
Returns the factory for creating debug monitors. The debug factory can be disabled independently from the regular factory. Debug monitors are no different than monitors returned by the regular monitor factory. However the debug factory can be used to monitor items in a test environment and disable them in production. Sample Call: MonitorFactory.getDebugFactory().start();


add

public static Monitor add(java.lang.String label,
                          java.lang.String units,
                          double value)

Aggregate the passed in value with the monitor associated with the label, and the units. The aggregation tracks hits, avg, total, min, max and more. Note the monitor returned is threadsafe. However, it is best to get a monitor vi this method and not reuse the handle as TimeMonitors are not thread safe (see the getTimeMonitor method.

Sample call:
 Monitor mon=MonitorFactory.add("bytes.sent","MB", 1024);



add

public static Monitor add(MonKey key,
                          double value)
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.


start

public static Monitor start(java.lang.String label)

Return a timing monitor with units in milliseconds. stop() should be called on the returned monitor to indicate the time that the process took. Note time monitors keep the starttime as an instance variable and so every time you want to use a TimeMonitor you should get a new instance.

Sample call:
  Monitor mon=MonitorFactory.start("pageHits");
...code being timed...
mon.stop();



start

public static Monitor start()

Return a timing monitor with units in milliseconds, that is not aggregated into the jamon stats. stop() should be called on the returned monitor to indicate the time that the process took. Note time monitors keep the starttime as an instance variable and so every time you want to use a TimeMonitor you should get a new instance.

Sample call:
  Monitor mon=MonitorFactory.start();
...code being timed...
mon.stop();



getMonitor

public static Monitor getMonitor()

startPrimary

public static Monitor startPrimary(java.lang.String label)

Return a timing monitor with units in milliseconds, that is not aggregated into the jamon stats. The concept of primary allows you to correlate performance of all monitors with the most resource intensive things the app does which helps you determine scalability.

Sample call:
  Monitor mon=MonitorFactory.startPrimary("myPrimaryMonitor");
...code being timed...
mon.stop();



startPrimary

public static Monitor startPrimary(MonKey key)
Start a monitor with the specified key and mark it as primary


start

public static Monitor start(MonKey key)
Start using the passed in key. Note activity stats are incremented


getMonitor

public static Monitor getMonitor(java.lang.String label,
                                 java.lang.String units)

Return the monitor associated with the label, and units. All statistics associated with the monitor can then be accessed such as hits, total, avg, min, and max. If the monitor does not exist it will be created.

Sample call:
  Monitor mon=MonitorFactory.getMonitor("myPrimaryMonitor");



getMonitor

public static Monitor getMonitor(MonKey key)
Get the monitor associated with the passed in key. It will be created if it doesn't exist


getTimeMonitor

public static Monitor getTimeMonitor(java.lang.String label)

Return the time monitor associated with the label. All statistics associated with the monitor can then be accessed such as hits, total, avg, min, and max. If the monitor does not exist it will be created.

Sample call:
  Monitor mon=MonitorFactory.getTimeMonitor("myPrimaryMonitor");



getTimeMonitor

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


exists

public static boolean exists(java.lang.String label,
                             java.lang.String units)

Determine if the monitor associated with the label, and the units currently exists.

Sample call:
  Monitor mon=MonitorFactory.getTimeMonitor("myPrimaryMonitor");



exists

public static boolean exists(MonKey key)
Return true if the monitor associated with the passed in key exists


getComposite

public static MonitorComposite getComposite(java.lang.String units)

Return the composite monitor (a collection of monitors) associated with the passed in units. Note in JAMon 1.0 this method would take a lable and would return all monitors that matched that criterion. This ability is now better performed using ArraySQL from the FormattedDataSet API. See JAMonAdmin.jsp for an example.

Sample call:
  Monitor mon=MonitorFactory.getComposite("ms.");
mon=MonitorFactory.getComposite("allMonitors");



getNumRows

public static int getNumRows()
This returns the number of monitors in this factory.


getRangeHeader

public static java.lang.String[] getRangeHeader()
Return the header for displaying what ranges are available.


getRangeNames

public static java.lang.Object[][] getRangeNames()
Return the ranges in this factory.


getRootMonitor

public static MonitorComposite getRootMonitor()
Return the composite monitor of all monitors for this factory


getVersion

public static java.lang.String getVersion()
Return the version of JAMon


remove

public static void remove(java.lang.String label,
                          java.lang.String units)
Remove/delete the specified monitor


remove

public static void remove(MonKey key)
Remove the monitor associated with the passed in key


setMap

public static void setMap(java.util.Map map)
Use the specified map to hold the monitors. This map should be threadsafe. This allows for the use of a faster map than the default synchronzied HashMap()


setRangeDefault

public static void setRangeDefault(java.lang.String key,
                                   RangeHolder rangeHolder)
Associate a range with a key/unit. Any monitor with the given unit will have this range. Any monitor with no range associated with its unit will have no range.


setEnabled

public static void setEnabled(boolean enable)
Enable/Disable MonitorFactory. When enabled (true) the factory returns monitors that store aggregate stats. When disabled (false) null/noop monitors are returned. enable()/disable() can also be used to perform the same function


setDebugEnabled

public static void setDebugEnabled(boolean enable)
Enable or disable the debug factory. The debug factory can be enabled/disabled at runtime. Calling this method with a false also disables calls to MonitorFactory.getDebugFactory(int debugPriorityLevel) Sample Call: MonitorFactory.setDebugEnabled(false); MonitorFactory.getDebugFactory().start(); // no stats are gathered.


enable

public static void enable()
Enable MonitorFactory. When enabled the factory returns monitors that store aggregate stats. This method has the same effect as calling MonitorFactor.setEnabled(true).


disable

public static void disable()
Disable MonitorFactory. When disabled the factory returns null/noop monitors. This method has the same effect as calling MonitorFactor.setEnabled(true).


isEnabled

public static boolean isEnabled()
Is the MonitorFactory currently enabled?


isDebugEnabled

public static boolean isDebugEnabled()
Is the Debug Monitor Factory currently enabled?


isGlobalActiveEnabled

public static boolean isGlobalActiveEnabled()

enableGlobalActive

public static void enableGlobalActive(boolean enable)

reset

public static void reset()
Reset/remove all monitors. If the factory is disabled this method has no action.


getHeader

public static java.lang.String[] getHeader()
This returns the header for basic data with no range info in the header. This method is deprecated. use the methods associated with the CompositeMonitor. The various getXXXHeader() methods of CompositeMonitors can return this information and more.


getData

public static java.lang.Object[][] getData()
This returns the data for basic data with no range info. The various getXXXData() methods of CompositeMonitors can return this information and more.


getReport

public static java.lang.String getReport()
This returns an HTML report for basic data with no range info in the header.


getReport

public static java.lang.String getReport(java.lang.String units)
This returns an HTML report for basic data with no range info in the header for the past in units. This method will be removed in the next release.


iterator

public java.util.Iterator iterator()
Iterator that contains Monitor's that are in this factory


main

public static void main(java.lang.String[] args)