|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.sape.carbon.services.instrumentation.statistics.DefaultStatisticsInterceptor
This Component Interceptor can be utilized to track the execution of Carbon components. It can be configured in a component template as shown here:
<!-- The statistics Assistant --> <DecoratorConfiguration> <Factory>org.sape.carbon.services.component.assistants.StatisticsInterceptorFactory</Factory> </DecoratorConfiguration>
WARNING: This does not guarantee accurate statistics... it simply keeps there from being innacurrate information in each MethodStat object and from threads stepping on eachother while writing. When reading, it is possible to read some of the data inconsistently. This is accepted as this is designed to be "pretty" accurate, with little to no contention on basic method calls, and only.
Copyright 2002 Sapient
Nested Class Summary | |
static class |
DefaultStatisticsInterceptor.MethodStats
This inner class is used to track information about an individual method on a specific component. |
Field Summary | |
private Component |
componentReference
The reference to the component object |
private long |
componentStartTime
The general start time of the component |
private FunctionalInterface |
functionalImplementation
The reference to the implementation object of the component |
private ThreadLocal |
localMethodStats
This threadlocal will hold a local map of methods to MethodStats objects, allowing each thread to accurately accumulate statistics information with no locking or contention. |
private org.apache.commons.logging.Log |
log
The handle to Apache-commons logger |
private Map |
methodStats
The map of component methods to Lists of MethodStat objects. |
protected Interceptor |
nextInterceptor
The reference to the next interceptor in the chain |
private long |
statisticsStartTime
The time at which statistics tracking began. |
Constructor Summary | |
private |
DefaultStatisticsInterceptor()
This object should not be insantiated manually, but only by the Component construction subsystem. |
|
DefaultStatisticsInterceptor(FunctionalInterface functionalImplementation)
The constructor used by the component interceptor factory to build this interceptor. |
Method Summary | |
private void |
appendClassInfo(StringBuffer buf,
ClassTree.ClassTreeNode node,
int depth)
Recursively appends class information to the buffer for the given node and all child nodes. |
long |
getCallCounts()
The count of calls to the component. |
Class[] |
getExposedInterfaces()
This should return the list of interfaces that a decorator wishes to expose through the component proxy. |
Collection |
getMethodStats()
A collection of the MethodStats for each method in the instrumented component. |
Date |
getStartDate()
The start date of the assisted component. |
long |
getStartTime()
Returns the start time of this component |
String |
getStatsReport()
Builds an HTML report of information about the assisted component. |
Object |
invoke(Invocation invocation)
This method must implement the invocation of any necessary actions and the chaining the next interceptor. |
void |
logStats()
Logs the statistics for the tracked component to the default logging component. |
void |
resetStats()
Resets the statistics being tracked on the component to zero. |
void |
setComponentReference(Component component)
Called after creation to pass a reference to the component to each of its decorators. |
void |
setNextInterceptor(Interceptor interceptor)
This method sets the next interceptor as the next in the chain from the current interceptor. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private org.apache.commons.logging.Log log
private Map methodStats
private ThreadLocal localMethodStats
private long componentStartTime
private long statisticsStartTime
private Component componentReference
private FunctionalInterface functionalImplementation
protected Interceptor nextInterceptor
Constructor Detail |
private DefaultStatisticsInterceptor()
public DefaultStatisticsInterceptor(FunctionalInterface functionalImplementation)
functionalImplementation
- a reference to the implementation
object behind
the component.Method Detail |
public long getStartTime()
getStartTime
in interface StatisticsInterceptor
public Date getStartDate()
getStartDate
in interface StatisticsInterceptor
public long getCallCounts()
getCallCounts
in interface StatisticsInterceptor
public Collection getMethodStats()
getMethodStats
in interface StatisticsInterceptor
DefaultStatisticsInterceptor
public void logStats()
logStats
in interface StatisticsInterceptor
public void setNextInterceptor(Interceptor interceptor)
setNextInterceptor
in interface Interceptor
interceptor
- the next interceptor in the chainpublic Class[] getExposedInterfaces()
getExposedInterfaces
in interface Decorator
public Object invoke(Invocation invocation) throws Throwable
invoke
in interface Interceptor
invocation
- the invocation to execute
Throwable
- indicates an error in the interceptor chainpublic void setComponentReference(Component component)
Decorator
setComponentReference
in interface Decorator
component
- a reference to the component that this interceptor is
assistingDecorator.setComponentReference(org.sape.carbon.core.component.Component)
public String getStatsReport()
Builds an HTML report of information about the assisted component. This report contains general information about the component as well as statistics on the total method calls and information about each method of the component.
Note: It should be noted that the failure counts are only updated apon the next call to a method that has failed. If a component is failing, there well may be uncounted failures, up to a count of the total threads that have had failures on the component.
getStatsReport
in interface StatisticsInterceptor
private void appendClassInfo(StringBuffer buf, ClassTree.ClassTreeNode node, int depth)
buf
- the buffer to append tonode
- the node to appenddepth
- the depth of recursion of the child nodes.public void resetStats()
resetStats
in interface StatisticsInterceptor
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |