|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.excalibur.instrument.manager.impl.DefaultInstrumentManagerImpl
public class DefaultInstrumentManagerImpl
Field Summary | |
---|---|
private org.apache.excalibur.instrument.ValueInstrument |
m_activeThreadCountInstrument
Instrument used to profile the active thread count of the JVM. |
private java.util.List |
m_connectors
List of configured connectors. |
private java.lang.String |
m_description
The description of this InstrumentManager. |
private org.apache.excalibur.instrument.ValueInstrument |
m_freeMemoryInstrument
Instrument used to profile the free memory. |
private int |
m_instrumentableCount
The Instrumentable count. |
private org.apache.excalibur.instrument.manager.InstrumentableDescriptor[] |
m_instrumentableDescriptorArray
Optimized array of the InstrumentableDescriptors. |
private java.lang.String |
m_instrumentableName
Instrumentable Name assigned to this Instrumentable |
private java.util.Map |
m_instrumentableProxies
HashMap of all of the registered InstrumentableProxies by their keys. |
private InstrumentableProxy[] |
m_instrumentableProxyArray
Optimized array of the InstrumentableProxies. |
private org.apache.excalibur.instrument.ValueInstrument |
m_instrumentablesInstrument
Instrument used to track the number of Instrumentables in the system. |
private int |
m_instrumentCount
The Instrument count. |
private org.apache.excalibur.instrument.ValueInstrument |
m_instrumentsInstrument
Instrument used to track the number of Instruments in the system. |
private long |
m_lastStateSave
Last time that the state was saved. |
private InstrumentSample[] |
m_leasedInstrumentSampleArray
Optimized array of the leased InstrumentSamples. |
private java.util.List |
m_leasedInstrumentSamples
List of leased InstrumentSamples. |
private int |
m_leasedSampleCount
The Leased Instrument Sample count. |
private org.apache.excalibur.instrument.ValueInstrument |
m_leasedSamplesInstrument
Instrument used to track the number of Leased Instrument samples in the system. |
private org.apache.excalibur.instrument.CounterInstrument |
m_leaseRequestsInstrument
Instrument used to track the number of lease requests. |
private long |
m_maxLeasedSampleLease
The maximum amount of time that a lease will be granted for. |
private int |
m_maxLeasedSamples
The maximum number of leased samples which will be allowed. |
private int |
m_maxLeasedSampleSize
The maximum size of a leased sample. |
private org.apache.excalibur.instrument.ValueInstrument |
m_memoryInstrument
Instrument used to profile the in use memory. |
private java.lang.String |
m_name
The name used to identify this InstrumentManager. |
private java.lang.String[][] |
m_nameTranslationArray
Optimized array of the registered translations. |
private java.util.Map |
m_nameTranslations
Map of all registered translations. |
private int |
m_permanentSampleCount
The Permanent Instrument Sample count. |
private org.apache.excalibur.instrument.CounterInstrument |
m_registrationsInstrument
Instrument to track the number of times registerInstrumentable is called. |
private java.lang.Thread |
m_runner
Thread used to keep the instruments published by the InstrumentManager up to date. |
private org.apache.excalibur.instrument.ValueInstrument |
m_samplesInstrument
Instrument used to track the number of Instrument samples in the system. |
private java.lang.Object |
m_semaphore
Semaphore for actions which must be synchronized |
private java.io.File |
m_stateFile
State file. |
private long |
m_stateInterval
Save state interval. |
private org.apache.excalibur.instrument.CounterInstrument |
m_stateSavesInstrument
Instrument used to track the number of state saves performed. |
private org.apache.excalibur.instrument.ValueInstrument |
m_stateSaveTimeInstrument
Instrument used to track the time it takes to save the state. |
private int |
m_stateVersion
State Version. |
private org.apache.excalibur.instrument.ValueInstrument |
m_totalMemoryInstrument
Instrument used to profile the total memory. |
private org.apache.avalon.framework.logger.Logger |
m_translationLogger
Logger dedicated to logging translations. |
Fields inherited from interface org.apache.excalibur.instrument.manager.DefaultInstrumentManager |
---|
INSTRUMENT_SAMPLE_TYPE_COUNTER, INSTRUMENT_SAMPLE_TYPE_MAXIMUM, INSTRUMENT_SAMPLE_TYPE_MEAN, INSTRUMENT_SAMPLE_TYPE_MINIMUM, INSTRUMENT_TYPE_COUNTER, INSTRUMENT_TYPE_NONE, INSTRUMENT_TYPE_VALUE |
Fields inherited from interface org.apache.excalibur.instrument.InstrumentManager |
---|
ROLE |
Fields inherited from interface org.apache.excalibur.instrument.Instrumentable |
---|
EMPTY_INSTRUMENT_ARRAY, EMPTY_INSTRUMENTABLE_ARRAY |
Constructor Summary | |
---|---|
DefaultInstrumentManagerImpl()
Creates a new DefaultInstrumentManagerImpl. |
|
DefaultInstrumentManagerImpl(java.lang.String name)
Deprecated. Name should be set in the instrument configuration file. |
Method Summary | |
---|---|
void |
configure(org.apache.avalon.framework.configuration.Configuration configuration)
Initializes the configured instrumentables. |
(package private) void |
decrementLeasedSampleCount()
Called to decrement the number of Leased Instrument Samples registered. |
void |
dispose()
Disposes the InstrumentManager. |
org.apache.excalibur.instrument.Instrumentable[] |
getChildInstrumentables()
Any Object which implements Instrumentable can also make use of other Instrumentable child objects. |
java.lang.String |
getDescription()
Returns the description of this DefaultInstrumentManager. |
org.apache.excalibur.instrument.manager.InstrumentableDescriptor |
getInstrumentableDescriptor(java.lang.String instrumentableName)
Returns a InstrumentableDescriptor based on its name or the name of any of its children. |
org.apache.excalibur.instrument.manager.InstrumentableDescriptor[] |
getInstrumentableDescriptors()
Returns an array of Descriptors for the Instrumentables managed by this DefaultInstrumentManager. |
java.lang.String |
getInstrumentableName()
Gets the name of the Instrumentable. |
private InstrumentableProxy |
getInstrumentableProxy(java.lang.String instrumentableName)
Returns a InstrumentableDescriptor based on its name or the name of any of its children. |
private InstrumentableProxy |
getInstrumentableProxy(java.lang.String instrumentableName,
boolean create)
|
private InstrumentProxy |
getInstrumentProxy(java.lang.String instrumentName,
boolean create)
|
private InstrumentProxy |
getInstrumentProxyForSample(java.lang.String sampleName,
boolean create)
|
org.apache.excalibur.instrument.Instrument[] |
getInstruments()
Obtain a reference to all the Instruments that the Instrumentable object wishes to expose. |
int |
getLeaseSampleCount()
Returns the current number of leased samples. |
long |
getMaxLeasedSampleLease()
Returns the maximum number of milliseconds that a lease will be granted for. |
int |
getMaxLeasedSamples()
Returns the maximum number of leased samples that will be approved. |
int |
getMaxLeasedSampleSize()
Returns the maximum size of a leased sample. |
java.lang.String |
getName()
Returns the name used to identify this DefaultInstrumentManager. |
int |
getStateVersion()
Returns the stateVersion of the DefaultInstrumeManager. |
(package private) java.lang.String |
getTranslatedName(java.lang.String name)
Translates a item name depending on a set of configured translations. |
(package private) void |
incrementInstrumentableCount()
Called to increment the number of Instrumentables registered. |
(package private) void |
incrementInstrumentCount()
Called to increment the number of Instruments registered. |
(package private) void |
incrementLeasedSampleCount()
Called to increment the number of Leased Instrument Samples registered. |
(package private) void |
incrementLeaseRequests()
Increment the lease requests. |
(package private) void |
incrementPermanentSampleCount()
Called to increment the number of Permanent Instrument Samples registered. |
void |
initialize()
Initializes the InstrumentManager. |
void |
invokeGarbageCollection()
Invokes garbage collection. |
void |
loadStateFromConfiguration(org.apache.avalon.framework.configuration.Configuration state)
Loads the Instrument Manager state from the specified Configuration. |
private void |
loadStateFromConfiguration(org.apache.avalon.framework.configuration.Configuration state,
java.lang.String parentName)
|
void |
loadStateFromFile(java.io.File stateFile)
Loads the Instrument Manager state from the specified file. |
void |
loadStateFromStream(java.io.InputStream is)
Loads the Instrument Manager state from the specified stream. |
private void |
loadStateFromStream(java.io.InputStream is,
java.lang.String location)
Loads the Instrument Manager state from the specified stream. |
private InstrumentableProxy |
locateDeepestInstrumentableProxy(java.lang.String instrumentableName)
Given the name of an instrumentable proxy, locate the deepest child instrumentable given the name. |
org.apache.excalibur.instrument.manager.InstrumentableDescriptor |
locateInstrumentableDescriptor(java.lang.String instrumentableName)
Searches the entire instrument tree for an instrumentable with the given name. |
org.apache.excalibur.instrument.manager.InstrumentDescriptor |
locateInstrumentDescriptor(java.lang.String instrumentName)
Searches the entire instrument tree for an instrument with the given name. |
org.apache.excalibur.instrument.manager.InstrumentSampleDescriptor |
locateInstrumentSampleDescriptor(java.lang.String sampleName)
Searches the entire instrument tree for an instrument sample with the given name. |
private void |
memoryInstruments()
Updates the Memory based Profile Points published by the InstrumentManager. |
private void |
registerDummyInstrumentableInner(org.apache.excalibur.instrument.Instrumentable instrumentable,
InstrumentableProxy instrumentableProxy,
java.lang.String instrumentableName,
java.lang.String childName)
Called as a place holder to handle the registration of instrumentables that do not really exist. |
void |
registerInstrumentable(org.apache.excalibur.instrument.Instrumentable instrumentable,
java.lang.String instrumentableName)
Instrumentable to be registered with the instrument manager. |
private void |
registerInstrumentableInner(org.apache.excalibur.instrument.Instrumentable instrumentable,
InstrumentableProxy instrumentableProxy,
java.lang.String instrumentableName)
Examines a instrumentable and Registers all of its child Instrumentables and Instruments. |
(package private) void |
registerLeasedInstrumentSample(InstrumentSample instrumentSample)
Registers an InstrumentSample which has been leased so that the Instrument Manager can efficiently purge it when it has expired. |
void |
registerNameTranslation(java.lang.String source,
java.lang.String target)
Registers a name translation that will be applied to all named based lookups of instrumentables, instruments, and samples. |
private void |
registerNameTranslationInner(java.lang.String source,
java.lang.String target)
Registers a name translation that will be applied to all named based lookups of instrumentables, instruments, and samples. |
void |
run()
|
private void |
saveState()
Saves the state to the current state file if configured. |
void |
saveStateToFile(java.io.File stateFile)
Saves the Instrument Manager's state to the specified file. |
void |
saveStateToStream(java.io.OutputStream os)
Saves the Instrument Manager's state to the specified output stream. |
void |
setInstrumentableName(java.lang.String name)
Sets the name for the Instrumentable. |
(package private) void |
stateChanged()
Called whenever the state of the instrument manager is changed. |
private void |
testInstrumentSampleLeases()
Handles the maintenance of all Instrument Samples which have been leased by a client. |
private void |
threadInstruments()
Updates the Thread based Profile Points published by the InstrumentManager. |
private org.apache.excalibur.instrument.manager.InstrumentableDescriptor[] |
updateInstrumentableDescriptorArray()
Updates the cached array of InstrumentableDescriptors taking synchronization into account. |
private InstrumentableProxy[] |
updateInstrumentableProxyArray()
Updates the cached array of InstrumentableProxies taking synchronization into account. |
private java.lang.String[][] |
updateNameTranslationArray()
Updates the cached array of registered name translations taking synchronization into account. |
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled |
---|
enableLogging, getLogger, setupLogger, setupLogger, setupLogger |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.lang.String m_name
private java.lang.String m_description
private int m_maxLeasedSamples
private int m_maxLeasedSampleSize
private long m_maxLeasedSampleLease
private java.util.List m_connectors
private java.io.File m_stateFile
private long m_stateInterval
private long m_lastStateSave
private java.lang.Object m_semaphore
private java.util.Map m_instrumentableProxies
private InstrumentableProxy[] m_instrumentableProxyArray
private org.apache.excalibur.instrument.manager.InstrumentableDescriptor[] m_instrumentableDescriptorArray
private java.util.List m_leasedInstrumentSamples
private InstrumentSample[] m_leasedInstrumentSampleArray
private org.apache.avalon.framework.logger.Logger m_translationLogger
private java.util.Map m_nameTranslations
private java.lang.String[][] m_nameTranslationArray
private java.lang.Thread m_runner
private java.lang.String m_instrumentableName
private org.apache.excalibur.instrument.ValueInstrument m_totalMemoryInstrument
private org.apache.excalibur.instrument.ValueInstrument m_freeMemoryInstrument
private org.apache.excalibur.instrument.ValueInstrument m_memoryInstrument
private org.apache.excalibur.instrument.ValueInstrument m_activeThreadCountInstrument
private org.apache.excalibur.instrument.CounterInstrument m_registrationsInstrument
private int m_instrumentableCount
private org.apache.excalibur.instrument.ValueInstrument m_instrumentablesInstrument
private int m_instrumentCount
private org.apache.excalibur.instrument.ValueInstrument m_instrumentsInstrument
private int m_permanentSampleCount
private int m_leasedSampleCount
private org.apache.excalibur.instrument.ValueInstrument m_samplesInstrument
private org.apache.excalibur.instrument.ValueInstrument m_leasedSamplesInstrument
private org.apache.excalibur.instrument.CounterInstrument m_leaseRequestsInstrument
private org.apache.excalibur.instrument.CounterInstrument m_stateSavesInstrument
private org.apache.excalibur.instrument.ValueInstrument m_stateSaveTimeInstrument
private int m_stateVersion
Constructor Detail |
---|
public DefaultInstrumentManagerImpl(java.lang.String name)
name
- The name used to identify this InstrumentManager. Should not
contain any spaces or periods.public DefaultInstrumentManagerImpl()
Method Detail |
---|
public void configure(org.apache.avalon.framework.configuration.Configuration configuration) throws org.apache.avalon.framework.configuration.ConfigurationException
configure
in interface org.apache.avalon.framework.configuration.Configurable
configuration
- InstrumentManager configuration.
org.apache.avalon.framework.configuration.ConfigurationException
- If there are any configuration problems.public void initialize() throws java.lang.Exception
initialize
in interface org.apache.avalon.framework.activity.Initializable
java.lang.Exception
- If there were any problems initializing the object.public void dispose()
dispose
in interface org.apache.avalon.framework.activity.Disposable
public void registerInstrumentable(org.apache.excalibur.instrument.Instrumentable instrumentable, java.lang.String instrumentableName) throws java.lang.Exception
registerInstrumentable
in interface org.apache.excalibur.instrument.InstrumentManager
instrumentable
- Instrumentable to register with the InstrumentManager.instrumentableName
- The name to use when registering the Instrumentable.
java.lang.Exception
- If there were any problems registering the Instrumentable.public java.lang.String getName()
getName
in interface org.apache.excalibur.instrument.manager.DefaultInstrumentManager
public java.lang.String getDescription()
getDescription
in interface org.apache.excalibur.instrument.manager.DefaultInstrumentManager
public void registerNameTranslation(java.lang.String source, java.lang.String target) throws java.lang.IllegalArgumentException
General operation of the instrument manager will not be affected as collection on sample data is always done using direct object references.
Translations can be registered for exact name matches, or for the bases of names. Any translation which ends in a '.' will imply a translation to any name beginning with that name base. If the source ends with a '.' then the target must as well.
source
- The source name or name base of the translation.target
- The target name or name base of the translation.
java.lang.IllegalArgumentException
- If the one but not both of the source
and target parameters end in '.'.public org.apache.excalibur.instrument.manager.InstrumentableDescriptor getInstrumentableDescriptor(java.lang.String instrumentableName) throws org.apache.excalibur.instrument.manager.NoSuchInstrumentableException
getInstrumentableDescriptor
in interface org.apache.excalibur.instrument.manager.DefaultInstrumentManager
instrumentableName
- Name of the Instrumentable being requested.
org.apache.excalibur.instrument.manager.NoSuchInstrumentableException
- If the specified Instrumentable
does not exist.public org.apache.excalibur.instrument.manager.InstrumentableDescriptor[] getInstrumentableDescriptors()
getInstrumentableDescriptors
in interface org.apache.excalibur.instrument.manager.DefaultInstrumentManager
public org.apache.excalibur.instrument.manager.InstrumentableDescriptor locateInstrumentableDescriptor(java.lang.String instrumentableName) throws org.apache.excalibur.instrument.manager.NoSuchInstrumentableException
locateInstrumentableDescriptor
in interface org.apache.excalibur.instrument.manager.DefaultInstrumentManager
instrumentableName
- Name of the Instrumentable being requested.
org.apache.excalibur.instrument.manager.NoSuchInstrumentableException
- If the specified Instrumentable
does not exist.public org.apache.excalibur.instrument.manager.InstrumentDescriptor locateInstrumentDescriptor(java.lang.String instrumentName) throws org.apache.excalibur.instrument.manager.NoSuchInstrumentException
locateInstrumentDescriptor
in interface org.apache.excalibur.instrument.manager.DefaultInstrumentManager
instrumentName
- Name of the Instrument being requested.
org.apache.excalibur.instrument.manager.NoSuchInstrumentException
- If the specified Instrument does
not exist.public org.apache.excalibur.instrument.manager.InstrumentSampleDescriptor locateInstrumentSampleDescriptor(java.lang.String sampleName) throws org.apache.excalibur.instrument.manager.NoSuchInstrumentSampleException
locateInstrumentSampleDescriptor
in interface org.apache.excalibur.instrument.manager.DefaultInstrumentManager
sampleName
- Name of the Instrument Sample being requested.
org.apache.excalibur.instrument.manager.NoSuchInstrumentSampleException
- If the specified Instrument
Sample does not exist.public int getStateVersion()
Clients can use this value to tell whether or not anything has changed without having to do an exhaustive comparison.
getStateVersion
in interface org.apache.excalibur.instrument.manager.DefaultInstrumentManager
public void invokeGarbageCollection()
invokeGarbageCollection
in interface org.apache.excalibur.instrument.manager.DefaultInstrumentManager
public int getLeaseSampleCount()
getLeaseSampleCount
in interface org.apache.excalibur.instrument.manager.DefaultInstrumentManager
public int getMaxLeasedSamples()
getMaxLeasedSamples
in interface org.apache.excalibur.instrument.manager.DefaultInstrumentManager
public int getMaxLeasedSampleSize()
getMaxLeasedSampleSize
in interface org.apache.excalibur.instrument.manager.DefaultInstrumentManager
public long getMaxLeasedSampleLease()
getMaxLeasedSampleLease
in interface org.apache.excalibur.instrument.manager.DefaultInstrumentManager
public void setInstrumentableName(java.lang.String name)
This value may be set by a parent Instrumentable, or by the InstrumentManager using the value of the 'instrumentable' attribute in the configuration of the component.
setInstrumentableName
in interface org.apache.excalibur.instrument.Instrumentable
name
- The name used to identify a Instrumentable.public java.lang.String getInstrumentableName()
getInstrumentableName
in interface org.apache.excalibur.instrument.Instrumentable
public org.apache.excalibur.instrument.Instrument[] getInstruments()
getInstruments
in interface org.apache.excalibur.instrument.Instrumentable
public org.apache.excalibur.instrument.Instrumentable[] getChildInstrumentables()
getChildInstrumentables
in interface org.apache.excalibur.instrument.Instrumentable
public void run()
run
in interface java.lang.Runnable
public void loadStateFromFile(java.io.File stateFile) throws java.lang.Exception
stateFile
- File to read the instrument manager's state from.
java.lang.Exception
- if there are any problems loading the state.public void loadStateFromStream(java.io.InputStream is) throws java.lang.Exception
is
- Stream to read the instrument manager's state from.
java.lang.Exception
- if there are any problems loading the state.private void loadStateFromStream(java.io.InputStream is, java.lang.String location) throws java.lang.Exception
is
- Stream to read the instrument manager's state from.location
- The location of the stream. Used to improve the
usefulness of any exceptions thrown.
java.lang.Exception
- if there are any problems loading the state.public void loadStateFromConfiguration(org.apache.avalon.framework.configuration.Configuration state) throws org.apache.avalon.framework.configuration.ConfigurationException
state
- Configuration object to load the state from.
org.apache.avalon.framework.configuration.ConfigurationException
- If there were any problems loading the
state.private void loadStateFromConfiguration(org.apache.avalon.framework.configuration.Configuration state, java.lang.String parentName) throws org.apache.avalon.framework.configuration.ConfigurationException
org.apache.avalon.framework.configuration.ConfigurationException
public void saveStateToFile(java.io.File stateFile) throws java.lang.Exception
stateFile
- File to write the Instrument Manager's state to.
java.lang.Exception
- if there are any problems saving the state.public void saveStateToStream(java.io.OutputStream os) throws java.lang.Exception
os
- Stream to write the Instrument Manager's state to.
java.lang.Exception
- if there are any problems saving the state.void registerLeasedInstrumentSample(InstrumentSample instrumentSample)
instrumentSample
- Leased InstrumentSample to register.void stateChanged()
void incrementInstrumentableCount()
void incrementInstrumentCount()
void incrementPermanentSampleCount()
void incrementLeasedSampleCount()
void decrementLeasedSampleCount()
void incrementLeaseRequests()
private void saveState()
private java.lang.String[][] updateNameTranslationArray()
java.lang.String getTranslatedName(java.lang.String name)
name
- Requested name.
private InstrumentableProxy getInstrumentableProxy(java.lang.String instrumentableName, boolean create)
private InstrumentProxy getInstrumentProxy(java.lang.String instrumentName, boolean create) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- If the specified instrumentName is invalid.private InstrumentProxy getInstrumentProxyForSample(java.lang.String sampleName, boolean create) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- If the specified sampleName is invalid.private InstrumentableProxy getInstrumentableProxy(java.lang.String instrumentableName)
instrumentableName
- Name of the Instrumentable being requested.
private InstrumentableProxy locateDeepestInstrumentableProxy(java.lang.String instrumentableName)
instrumentableName
- Fully qualified name of the instrumentable
being requested, or of any of its children.
private void memoryInstruments()
private void threadInstruments()
private void testInstrumentSampleLeases()
private InstrumentableProxy[] updateInstrumentableProxyArray()
private org.apache.excalibur.instrument.manager.InstrumentableDescriptor[] updateInstrumentableDescriptorArray()
private void registerNameTranslationInner(java.lang.String source, java.lang.String target) throws java.lang.IllegalArgumentException
General operation of the instrument manager will not be affected as collection on sample data is always done using direct object references.
Translations can be registered for translations of sample names up to and including the name of the instrument. This means that all source and target names must end in a '.'.
This method should only be called when m_semaphore is synchronized.
source
- The source name or name base of the translation.target
- The target name or name base of the translation.
java.lang.IllegalArgumentException
- If either the source or target does
not end in a '.' or is invalid.private void registerDummyInstrumentableInner(org.apache.excalibur.instrument.Instrumentable instrumentable, InstrumentableProxy instrumentableProxy, java.lang.String instrumentableName, java.lang.String childName) throws java.lang.Exception
instrumentable
- The instrumentable that was registered below a dummy
parent.instrumentableProxy
- The proxy assigned to the current placeholder
instrumentable.instrumentableName
- The name of the current placeholder
instrumentable.childName
- The name of the child instrumentable to register. May
contain further '.' characters.
java.lang.Exception
private void registerInstrumentableInner(org.apache.excalibur.instrument.Instrumentable instrumentable, InstrumentableProxy instrumentableProxy, java.lang.String instrumentableName) throws java.lang.Exception
Only called when m_semaphore is locked.
java.lang.Exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |