You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by mw...@apache.org on 2007/07/16 13:13:00 UTC
svn commit: r556585 -
/mina/trunk/core/src/main/java/org/apache/mina/filter/ProfilerTimerFilter.java
Author: mwebb
Date: Mon Jul 16 04:12:56 2007
New Revision: 556585
URL: http://svn.apache.org/viewvc?view=rev&rev=556585
Log:
added some error checking in the getter methods, and populated the timerManager with the actual IoEventTypes that are passed in to the constructor.
Modified:
mina/trunk/core/src/main/java/org/apache/mina/filter/ProfilerTimerFilter.java
Modified: mina/trunk/core/src/main/java/org/apache/mina/filter/ProfilerTimerFilter.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/filter/ProfilerTimerFilter.java?view=diff&rev=556585&r1=556584&r2=556585
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/filter/ProfilerTimerFilter.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/filter/ProfilerTimerFilter.java Mon Jul 16 04:12:56 2007
@@ -99,14 +99,13 @@
}
timerManager = new HashMap<IoEventType,TimerWorker>();
- timerManager.put( IoEventType.MESSAGE_RECEIVED, new TimerWorker() );
- timerManager.put( IoEventType.MESSAGE_SENT, new TimerWorker() );
- timerManager.put( IoEventType.SESSION_CREATED, new TimerWorker() );
- timerManager.put( IoEventType.SESSION_OPENED, new TimerWorker() );
- timerManager.put( IoEventType.SESSION_IDLE, new TimerWorker() );
- timerManager.put( IoEventType.SESSION_CLOSED, new TimerWorker() );
+
+ for( IoEventType type : eventsToProfile ){
+ timerManager.put( type, new TimerWorker() );
+ }
}
+
/**
* Returns the {@link ProfilerTimerUnit} being used.
*
@@ -130,7 +129,28 @@
this.timeUnit = timeUnit;
}
-
+ /**
+ * Add an {@link IoEventType} to profile
+ *
+ * @param type
+ * The {@link IoEventType} to profile
+ */
+ public void addEventToProfile( IoEventType type ){
+ if( !timerManager.containsKey( type )){
+ timerManager.put( type, new TimerWorker() );
+ }
+ }
+
+ /**
+ * Remove an {@link IoEventType} to profile
+ *
+ * @param type
+ * The {@link IoEventType} to profile
+ */
+ public void removeEventToProfile( IoEventType type ){
+ timerManager.remove( type );
+ }
+
/**
* Return the bitmask that is being used to display
* timing information for this filter.
@@ -237,6 +257,10 @@
* The average time it took to execute the method represented by the {@link IoEventType}
*/
public double getAverageTime( IoEventType type ){
+ if( !timerManager.containsKey( type )){
+ throw new IllegalArgumentException("You are not monitoring this event. Please add this event first.");
+ }
+
return timerManager.get( type ).getAverage();
}
@@ -250,6 +274,10 @@
* The total number of method calls for the method represented by the {@link IoEventType}
*/
public long getTotalCalls( IoEventType type ){
+ if( !timerManager.containsKey( type )){
+ throw new IllegalArgumentException("You are not monitoring this event. Please add this event first.");
+ }
+
return timerManager.get( type ).getCalls();
}
@@ -263,6 +291,10 @@
* The total time for the method represented by the {@link IoEventType}
*/
public long getTotalTime( IoEventType type ){
+ if( !timerManager.containsKey( type )){
+ throw new IllegalArgumentException("You are not monitoring this event. Please add this event first.");
+ }
+
return timerManager.get( type ).getTotal();
}
@@ -276,6 +308,10 @@
* The minimum time this method has executed represented by the {@link IoEventType}
*/
public long getMinValue( IoEventType type ){
+ if( !timerManager.containsKey( type )){
+ throw new IllegalArgumentException("You are not monitoring this event. Please add this event first.");
+ }
+
return timerManager.get( type ).getMin();
}
@@ -289,6 +325,10 @@
* The maximum time this method has executed represented by the {@link IoEventType}
*/
public long getMaxValue( IoEventType type ){
+ if( !timerManager.containsKey( type )){
+ throw new IllegalArgumentException("You are not monitoring this event. Please add this event first.");
+ }
+
return timerManager.get( type ).getMax();
}