org.jlf.vitals
Class VitalsManager

java.lang.Object
  |
  +--org.jlf.vitals.VitalsManager

public class VitalsManager
extends java.lang.Object

VitalsManager is a singleton class that tries to keep track of all the vital signs collected in the virtual machine, yet not blow out the memory of the virtual machine with all of this information. It keeps track of two primary types of vital signs, the first is a set of vitals that needs to be collected on an automated, periodic basis, by the vitals sampler thread. The next is a set of vitals that is collected ad-hoc, that is, your code notifies the vitals manager of a newly collected vital sign measurement at the moment your code takes it (and it isn't regular/periodic). The vitals manager knows the difference based on the measurement frequency setting in the vital sign.

See Also:
VitalSign

Field Summary
protected  java.util.Map adhocVitals
          Holds a collection of vital signs that are sampled on an ad-hoc basis.
protected  java.util.Map periodicVitals
          Holds a collection of vital signs that need to be sampled periodically over time.
protected static VitalsManager singleton
          Holds the singleton instance of the vitals manager in the JVM.
 
Constructor Summary
protected VitalsManager()
          Protect the singleton by scoping the constructor to protected and also initialize it with any vital signs to collect periodically.
 
Method Summary
protected  java.util.Collection collectAllVitals(java.util.Map vitalMap)
          Helper method to retrieve all vitals, parent and child, from a vital map.
protected  VitalSign findParentOrChildVital(java.lang.String vitalKey, java.util.Collection vitals)
          Helper method to iterate through a collection and find a vital that matches the vital key.
 VitalSign findRegisteredVitalSign(java.lang.String vitalKey)
          Tries to find a registered vital sign.
 VitalSign getAdhocVital(java.lang.String vitalKey)
          Helper method to find a vital sign in the adhocVitals collection.
 java.util.Collection getAdhocVitals()
          Returns a collection of adhoc vitals that are registered.
 java.util.Collection getAllAdhocVitals()
          Returns a collection of adhoc vitals that are registered, including parents and child instances.
 java.util.Collection getAllPeriodicVitals()
          Returns a collection of periodic vitals that are registered, including parents and child instances.
 java.util.Collection getCollectableAdhocVitals()
          Returns a collection of adhoc vitals that are registered and collectable.
 java.util.Collection getCollectablePeriodicVitals()
          Returns a collection of periodic vitals that are registered and collectable.
static VitalsManager getInstance()
          Class accessor which answers the singleton instance of the VitalsManager for this virtual machine.
 VitalSign getParentOrChildAdhocVital(java.lang.String vitalKey)
          Helper method to find a vital sign in the adhoc Vitals collection, whether the vital is a parent or child instance.
 VitalSign getParentOrChildPeriodicVital(java.lang.String vitalKey)
          Helper method to find a vital sign in the periodic Vitals collection, whether a parent or a child vital.
 VitalSign getPeriodicVital(java.lang.String vitalKey)
          Helper method to find a vital sign in the periodicVitals collection.
 java.util.Collection getPeriodicVitals()
          Returns a collection of periodic vitals that are registered.
protected  void loadPeriodicVital(java.lang.String vitalKey)
          Helper method that loads a periodic vital with the key given, wrapping any exceptions thrown, logging them but not throwing them back so loading any others will continue.
protected  void loadPeriodicVitals()
          Helper method that looks through property file settings and load vitals designated to be captured.
static void main(java.lang.String[] args)
          Method that simply allows the vitals manager to start up using something like a WebLogic startup class.
protected  void putAdhocVital(VitalSign vitalSign)
          Helper method to put a vital sign in the adhocVitals collection.
protected  void putPeriodicVital(VitalSign vitalSign)
          Helper method to put a vital sign in the periodicVitals collection.
 VitalSign registerMeasurement(java.lang.String vitalKey, AbstractVitalMeasurement newMeasurement)
          Registers a measurement with a vital sign.
 VitalSign registerVitalSign(VitalSign inputVitalSign)
          Adds a vital sign to the list of vitals that is being tracked.
protected  java.util.Collection siftCollectableVitals(java.util.Collection vitals)
          Helper method to retrieve collectable vitals from a collection of vitals that may contain uncollectable parent vitals.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

singleton

protected static VitalsManager singleton
Holds the singleton instance of the vitals manager in the JVM.


periodicVitals

protected java.util.Map periodicVitals
Holds a collection of vital signs that need to be sampled periodically over time.


adhocVitals

protected java.util.Map adhocVitals
Holds a collection of vital signs that are sampled on an ad-hoc basis.

Constructor Detail

VitalsManager

protected VitalsManager()
Protect the singleton by scoping the constructor to protected and also initialize it with any vital signs to collect periodically.

Method Detail

getInstance

public static VitalsManager getInstance()
Class accessor which answers the singleton instance of the VitalsManager for this virtual machine.


loadPeriodicVital

protected void loadPeriodicVital(java.lang.String vitalKey)
Helper method that loads a periodic vital with the key given, wrapping any exceptions thrown, logging them but not throwing them back so loading any others will continue.


loadPeriodicVitals

protected void loadPeriodicVitals()
Helper method that looks through property file settings and load vitals designated to be captured.


putAdhocVital

protected void putAdhocVital(VitalSign vitalSign)
Helper method to put a vital sign in the adhocVitals collection.

Throws:
AppError - if the vital sign is already registered

getAdhocVital

public VitalSign getAdhocVital(java.lang.String vitalKey)
Helper method to find a vital sign in the adhocVitals collection.

Returns:
the VitalSign that matches the vitalKey if found, null if not.

getParentOrChildAdhocVital

public VitalSign getParentOrChildAdhocVital(java.lang.String vitalKey)
Helper method to find a vital sign in the adhoc Vitals collection, whether the vital is a parent or child instance.

Returns:
the VitalSign that matches the vitalKey if found, null if not.

findParentOrChildVital

protected VitalSign findParentOrChildVital(java.lang.String vitalKey,
                                           java.util.Collection vitals)
Helper method to iterate through a collection and find a vital that matches the vital key.


getAdhocVitals

public java.util.Collection getAdhocVitals()
Returns a collection of adhoc vitals that are registered. Note that if you want to see the vitals that are measured (which has child instances instead of uncollectable parents), use getCollectableAdhocVitals() method.


getAllAdhocVitals

public java.util.Collection getAllAdhocVitals()
Returns a collection of adhoc vitals that are registered, including parents and child instances.


siftCollectableVitals

protected java.util.Collection siftCollectableVitals(java.util.Collection vitals)
Helper method to retrieve collectable vitals from a collection of vitals that may contain uncollectable parent vitals.


collectAllVitals

protected java.util.Collection collectAllVitals(java.util.Map vitalMap)
Helper method to retrieve all vitals, parent and child, from a vital map.


getCollectableAdhocVitals

public java.util.Collection getCollectableAdhocVitals()
Returns a collection of adhoc vitals that are registered and collectable. It discards parent vitals that have child instances and returns all non-parent vitals.


putPeriodicVital

protected void putPeriodicVital(VitalSign vitalSign)
Helper method to put a vital sign in the periodicVitals collection.

Throws:
AppError - if the vital sign is already registered

getPeriodicVital

public VitalSign getPeriodicVital(java.lang.String vitalKey)
Helper method to find a vital sign in the periodicVitals collection.

Returns:
the VitalSign that matches the vitalKey if found, null if not.

getParentOrChildPeriodicVital

public VitalSign getParentOrChildPeriodicVital(java.lang.String vitalKey)
Helper method to find a vital sign in the periodic Vitals collection, whether a parent or a child vital.

Returns:
the VitalSign that matches the vitalKey if found, null if not.

getPeriodicVitals

public java.util.Collection getPeriodicVitals()
Returns a collection of periodic vitals that are registered. Note that if you want to see the vitals that are measured (which has child instances instead of uncollectable parents), use getCollectablePeriodicVitals() method.


getAllPeriodicVitals

public java.util.Collection getAllPeriodicVitals()
Returns a collection of periodic vitals that are registered, including parents and child instances.


getCollectablePeriodicVitals

public java.util.Collection getCollectablePeriodicVitals()
Returns a collection of periodic vitals that are registered and collectable. It discards parent vitals that have child instances and returns all non-parent vitals.


findRegisteredVitalSign

public VitalSign findRegisteredVitalSign(java.lang.String vitalKey)
Tries to find a registered vital sign.

Returns:
the VitalSign that matches the vitalKey if found, null if not.

registerVitalSign

public VitalSign registerVitalSign(VitalSign inputVitalSign)
Adds a vital sign to the list of vitals that is being tracked. If the input vital sign is already registered, it will return the registered vital sign that matches the input key.


registerMeasurement

public VitalSign registerMeasurement(java.lang.String vitalKey,
                                     AbstractVitalMeasurement newMeasurement)
Registers a measurement with a vital sign. If the vital sign does not exist in the set of vitals managed here, it creates one with properties as defined in the property file and then registers the measurement with the vital sign. If the vital sign is already created/managed, it finds the vital sign and registers the measurement.

Returns:
The vital sign the measurement was registered with

main

public static void main(java.lang.String[] args)
Method that simply allows the vitals manager to start up using something like a WebLogic startup class.