|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.mina.core.filterchain.IoFilterAdapter
org.apache.mina.filter.statistic.ProfilerTimerFilter
public class ProfilerTimerFilter
This class will measure the time it takes for a
method in the IoFilterAdapter class to execute. The basic
premise of the logic in this class is to get the current time
at the beginning of the method, call method on nextFilter, and
then get the current time again. An example of how to use
the filter is:
ProfilerTimerFilter profiler = new ProfilerTimerFilter(
TimeUnit.MILLISECOND, IoEventType.MESSAGE_RECEIVED);
chain.addFirst("Profiler", profiler);
The profiled IoEventType are :
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface org.apache.mina.core.filterchain.IoFilter |
|---|
IoFilter.NextFilter |
| Constructor Summary | |
|---|---|
ProfilerTimerFilter()
Creates a new instance of ProfilerFilter. |
|
ProfilerTimerFilter(TimeUnit timeUnit)
Creates a new instance of ProfilerFilter. |
|
ProfilerTimerFilter(TimeUnit timeUnit,
IoEventType... eventTypes)
Creates a new instance of ProfilerFilter. |
|
| Method Summary | |
|---|---|
double |
getAverageTime(IoEventType type)
Get the average time for the specified method represented by the IoEventType |
Set<IoEventType> |
getEventsToProfile()
Return the set of IoEventType which are profiled. |
long |
getMaximumTime(IoEventType type)
The maximum time the method represented by IoEventType has executed |
long |
getMinimumTime(IoEventType type)
The minimum time the method represented by IoEventType has executed |
long |
getTotalCalls(IoEventType type)
Gets the total number of times the method has been called that is represented by the IoEventType |
long |
getTotalTime(IoEventType type)
The total time this method has been executing |
void |
messageReceived(IoFilter.NextFilter nextFilter,
IoSession session,
Object message)
Profile a MessageReceived event. |
void |
messageSent(IoFilter.NextFilter nextFilter,
IoSession session,
WriteRequest writeRequest)
Profile a MessageSent event. |
void |
profile(IoEventType type)
Set the IoEventType to be profiled |
void |
sessionClosed(IoFilter.NextFilter nextFilter,
IoSession session)
Profile a SessionClosed event. |
void |
sessionCreated(IoFilter.NextFilter nextFilter,
IoSession session)
Profile a SessionCreated event. |
void |
sessionIdle(IoFilter.NextFilter nextFilter,
IoSession session,
IdleStatus status)
Profile a SessionIdle event. |
void |
sessionOpened(IoFilter.NextFilter nextFilter,
IoSession session)
Profile a SessionOpened event. |
void |
setEventsToProfile(IoEventType... eventTypes)
Set the profilers for a list of IoEventType |
void |
setTimeUnit(TimeUnit timeUnit)
Sets the TimeUnit being used. |
void |
stopProfile(IoEventType type)
Stop profiling an IoEventType |
| Methods inherited from class org.apache.mina.core.filterchain.IoFilterAdapter |
|---|
destroy, exceptionCaught, filterClose, filterWrite, init, onPostAdd, onPostRemove, onPreAdd, onPreRemove, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public ProfilerTimerFilter()
public ProfilerTimerFilter(TimeUnit timeUnit)
timeUnit - the time increment to set
public ProfilerTimerFilter(TimeUnit timeUnit,
IoEventType... eventTypes)
new ProfilerTimerFilter(
TimeUnit.MILLISECONDS,
IoEventType.MESSAGE_RECEIVED, IoEventType.MESSAGE_SENT);
Note : you can add as many IoEventType as you want. The method accepts
a variable number of arguments.
timeUnit - Used to determine the level of precision you need in your timing.eventTypes - A list of IoEventType representation of the methods to profile| Method Detail |
|---|
public void setTimeUnit(TimeUnit timeUnit)
TimeUnit being used.
timeUnit - the new TimeUnit to be used.public void profile(IoEventType type)
IoEventType to be profiled
type - The IoEventType to profilepublic void stopProfile(IoEventType type)
IoEventType
type - The IoEventType to stop profilingpublic Set<IoEventType> getEventsToProfile()
IoEventType which are profiled.
IoEventTypepublic void setEventsToProfile(IoEventType... eventTypes)
IoEventType
eventTypes - the list of IoEventType to profile
public void messageReceived(IoFilter.NextFilter nextFilter,
IoSession session,
Object message)
throws Exception
messageReceived in interface IoFiltermessageReceived in class IoFilterAdapternextFilter - The filter to call nextsession - The associated sessionmessage - the received message
Exception
public void messageSent(IoFilter.NextFilter nextFilter,
IoSession session,
WriteRequest writeRequest)
throws Exception
messageSent in interface IoFiltermessageSent in class IoFilterAdapternextFilter - The filter to call nextsession - The associated sessionwriteRequest - the sent message
Exception
public void sessionCreated(IoFilter.NextFilter nextFilter,
IoSession session)
throws Exception
sessionCreated in interface IoFiltersessionCreated in class IoFilterAdapternextFilter - The filter to call nextsession - The associated session
Exception
public void sessionOpened(IoFilter.NextFilter nextFilter,
IoSession session)
throws Exception
sessionOpened in interface IoFiltersessionOpened in class IoFilterAdapternextFilter - The filter to call nextsession - The associated session
Exception
public void sessionIdle(IoFilter.NextFilter nextFilter,
IoSession session,
IdleStatus status)
throws Exception
sessionIdle in interface IoFiltersessionIdle in class IoFilterAdapternextFilter - The filter to call nextsession - The associated sessionstatus - The session's status
Exception
public void sessionClosed(IoFilter.NextFilter nextFilter,
IoSession session)
throws Exception
sessionClosed in interface IoFiltersessionClosed in class IoFilterAdapternextFilter - The filter to call nextsession - The associated session
Exceptionpublic double getAverageTime(IoEventType type)
IoEventType
type - The IoEventType that the user wants to get the average method call time
IoEventTypepublic long getTotalCalls(IoEventType type)
IoEventType
type - The IoEventType that the user wants to get the total number of method calls
IoEventTypepublic long getTotalTime(IoEventType type)
type - The IoEventType that the user wants to get the total time this method has
been executing
IoEventTypepublic long getMinimumTime(IoEventType type)
IoEventType has executed
type - The IoEventType that the user wants to get the minimum time this method has
executed
IoEventTypepublic long getMaximumTime(IoEventType type)
IoEventType has executed
type - The IoEventType that the user wants to get the maximum time this method has
executed
IoEventType
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||