|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.jlf.vitals.VitalSign
VitalSign
is a class that holds a statistic
vital to the proper operation of your code. A VitalSign
is automatically registered with the JVM's singleton
instance of a VitalsManager, so all server vitals
can be accumulated, queried and reported from a centralized location.
Although VitalSigns can be dynamically created and configured, you usually want to configure them via property file settings. The settings and their defaults are listed below.
VitalSignProperties
Field Summary | |
protected java.util.Map |
childInstances
Holds a collection of child instances. |
protected java.lang.String |
childVitalKey
Unique name of the child vital sign. |
protected boolean |
isActiveFlag
Holds a flag to tell if the vital sign is active |
protected boolean |
isParentVital
Holds a flag to see if a child instance capable vital sign is the parent or the child. |
protected VitalSignProperties |
properties
Holds the properties of the vital sign, whether defined in a property file or given created dynamically. |
protected VitalStatistics |
statistics
Holds a collection of vital sign statistics accumulated over time. |
protected long |
timeLastChildInstancesCollected
Holds the date/time of the last time the vital collected any child instances. |
protected long |
timeLastVitalMeasurementRegistered
Holds the date/time of the last registered measurement for the vital sign. |
protected java.lang.String |
vitalKey
Unique name of the vital sign. |
Constructor Summary | |
VitalSign(java.lang.String vitalKey)
Creates a vital sign, looking to properties in the property file for information on how the vital should work. |
|
VitalSign(java.lang.String vitalKey,
VitalSignProperties properties)
Creates a vital sign with the properties dynamically constructed instead of read from a property file. |
Method Summary | |
protected VitalSign |
basicCreateChildInstance(java.lang.String inputChildVitalKey)
Helper method that creates a new child instance but does not register it. |
AbstractVitalMeasurement |
basicGetMaximumMeasurement()
Returns the maximum theoritical value of the vital sign. |
protected void |
collectChildInstanceMeasurements()
Helper method to iterate through any child instances and collect measurements. |
AbstractVitalMeasurement |
collectMeasurement()
Collects a current measurement of the vital sign and adds it into the vital sign's set of statistics. |
VitalSign |
findOrCreateChildInstance(java.lang.String inputChildVitalKey)
For vital signs enabled for children, this method takes a childVitalKey as an input parameter and either finds that child in the current children collection or creates a new child instances of the same class. |
VitalSign |
getChildInstance(java.lang.String inputChildVitalKey)
Finds a vital sign child instance in the collection. |
java.util.Collection |
getChildInstances()
Returns a list of child instances. |
java.lang.String |
getChildVitalKey()
Returns the childVitalKey. |
protected AbstractVitalMeasurement |
getCurrentMeasurement()
Takes a measurement of the vital sign at the current moment and returns it to the caller. |
static VitalSign |
getInstance(java.lang.String vitalKey)
Creates a vital sign of the correct sub-class, using properties defined in the main property file. |
static VitalSign |
getInstance(java.lang.String vitalKey,
VitalSignProperties properties)
Creates a vital sign of the correct sub-class, given its vital key and properties. |
AbstractVitalMeasurement |
getMaximumMeasurement()
Returns the maximum theoritical value of the vital sign. |
VitalSignProperties |
getProperties()
Returns the properties for the vital sign. |
VitalStatistics |
getStatistics()
Returns the statistics. |
java.lang.String |
getVitalKey()
Returns the vitalKey. |
boolean |
hasChildInstances()
Tells whether the vital sign has child instances or not. |
boolean |
isActive()
Returns if the vital is active or not |
boolean |
isParentVital()
For a child instance capable vital, returns if the vital sign instance is the parent or a child. |
boolean |
isVitalApplicable()
Checks to see if a vital sign is applicable for collection in the current JVM. |
protected void |
putChildInstance(VitalSign childInstance)
Helper method to put a child instance in the collection. |
void |
refreshChildInstances()
Refreshes the list of child instances for those vitals that have such. |
void |
registerMeasurement(AbstractVitalMeasurement newMeasurement)
Registers a measurement for this vital sign into the vital sign's set of statistics it keeps. |
void |
setChildVitalKey(java.lang.String childVitalKey)
Sets the childVitalKey. |
void |
setIsActiveFlag(boolean isActiveFlag)
Sets whether the vital is active. |
void |
setIsParentVital(boolean isParentVital)
For a child instance capable vital, sets the flag if the vital sign instance is the parent or a child. |
protected boolean |
shouldChildInstancesBeCollected()
Checks to see if a vital sign measurement should be collected, given its frequency defined in the property file. |
boolean |
shouldMeasurementBeCollected()
Checks to see if a vital sign measurement should be collected, given its frequency defined in the property file. |
protected java.lang.String |
vitalKeyForChildVitalKey(java.lang.String inputChildVitalKey)
Helper method to construct a child instance vital key. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.lang.String vitalKey
protected VitalSignProperties properties
protected VitalStatistics statistics
protected long timeLastVitalMeasurementRegistered
protected long timeLastChildInstancesCollected
protected java.lang.String childVitalKey
protected java.util.Map childInstances
protected boolean isParentVital
protected boolean isActiveFlag
Constructor Detail |
public VitalSign(java.lang.String vitalKey)
public VitalSign(java.lang.String vitalKey, VitalSignProperties properties)
Note: When you create a subclass of VitalSign, particularly for Vital Signs that are entered in your property file to be perioidically collected, you MUST pass this constructor through to this superclass or the automated collection process will not be able to instantiate the class.
Method Detail |
public static VitalSign getInstance(java.lang.String vitalKey)
public static VitalSign getInstance(java.lang.String vitalKey, VitalSignProperties properties)
public java.lang.String getVitalKey()
public VitalSignProperties getProperties()
public boolean isActive()
public void setIsActiveFlag(boolean isActiveFlag)
public boolean isVitalApplicable()
public VitalStatistics getStatistics()
public void registerMeasurement(AbstractVitalMeasurement newMeasurement)
protected AbstractVitalMeasurement getCurrentMeasurement()
public AbstractVitalMeasurement getMaximumMeasurement()
public AbstractVitalMeasurement basicGetMaximumMeasurement()
public boolean shouldMeasurementBeCollected()
protected void collectChildInstanceMeasurements()
public AbstractVitalMeasurement collectMeasurement()
This method is typically called by the vitals manager, which kicks in every second or and sees if a new measurement needs to be taken. It in turn calls the getCurrentMeasurement() method, which is implemented by subclasses to take a measurement appropriate to the subclass.
public boolean hasChildInstances()
The default for this is false, only one instance (itself) for the vital.
public java.lang.String getChildVitalKey()
public void setChildVitalKey(java.lang.String childVitalKey)
childVitalKey
- The childVitalKey to setpublic java.util.Collection getChildInstances()
protected java.lang.String vitalKeyForChildVitalKey(java.lang.String inputChildVitalKey)
public VitalSign getChildInstance(java.lang.String inputChildVitalKey)
protected VitalSign basicCreateChildInstance(java.lang.String inputChildVitalKey)
For this method to work, Vital Sign subclasses MUST implement a public constructor that takes a String vital key and a VitalSignProperties object as input parameters.
public VitalSign findOrCreateChildInstance(java.lang.String inputChildVitalKey)
For this method to work, Vital Sign subclasses MUST implement a public constructor that takes a String vital key and a VitalSignProperties object as input parameters.
protected void putChildInstance(VitalSign childInstance)
AppError
- if the child instance is already registeredprotected boolean shouldChildInstancesBeCollected()
public void refreshChildInstances()
public boolean isParentVital()
public void setIsParentVital(boolean isParentVital)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |