You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by tr...@apache.org on 2007/11/04 13:31:46 UTC

svn commit: r591775 - /mina/trunk/core/src/main/java/org/apache/mina/filter/traffic/ReadThrottleFilter.java

Author: trustin
Date: Sun Nov  4 04:31:46 2007
New Revision: 591775

URL: http://svn.apache.org/viewvc?rev=591775&view=rev
Log:
Removed another restriction that should have been removed in the previous commit

Modified:
    mina/trunk/core/src/main/java/org/apache/mina/filter/traffic/ReadThrottleFilter.java

Modified: mina/trunk/core/src/main/java/org/apache/mina/filter/traffic/ReadThrottleFilter.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/filter/traffic/ReadThrottleFilter.java?rev=591775&r1=591774&r2=591775&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/filter/traffic/ReadThrottleFilter.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/filter/traffic/ReadThrottleFilter.java Sun Nov  4 04:31:46 2007
@@ -64,9 +64,6 @@
     private static final Map<IoService, AtomicInteger> serviceBufferSizes =
         new CopyOnWriteMap<IoService, AtomicInteger>();
     
-    private static final AttributeKey STATE =
-        new AttributeKey(ReadThrottleFilter.class, "state");
-
     /**
      * Returns the current amount of data in the buffer of the {@link ExecuorFilter}
      * for all {@link IoSession} whose {@link IoFilterChain} has been configured by
@@ -104,21 +101,9 @@
         serviceBufferSizes.remove(service);
     }
     
-    /**
-     * Returns the current amount of data in the buffer of the {@link ExecutorFilter}
-     * for the specified {@link IoSession}.
-     */
-    public static int getSessionBufferSize(IoSession session) {
-        State state = (State) session.getAttribute(STATE);
-        if (state == null) {
-            return 0;
-        }
-        
-        synchronized (state) {
-            return state.sessionBufferSize;
-        }
-    }
-    
+    private final AttributeKey STATE =
+        new AttributeKey(ReadThrottleFilter.class, "state");
+
     private final Object logLock = new Object();
     private long lastLogTime = 0;
     
@@ -260,14 +245,24 @@
         return messageSizeEstimator;
     }
     
+    /**
+     * Returns the current amount of data in the buffer of the {@link ExecutorFilter}
+     * for the specified {@link IoSession}.
+     */
+    public int getSessionBufferSize(IoSession session) {
+        State state = (State) session.getAttribute(STATE);
+        if (state == null) {
+            return 0;
+        }
+        
+        synchronized (state) {
+            return state.sessionBufferSize;
+        }
+    }
+    
     @Override
     public void onPreAdd(
             IoFilterChain parent, String name, NextFilter nextFilter) throws Exception {
-        if (parent.contains(ReadThrottleFilter.class)) {
-            throw new IllegalStateException(
-                    "Only one " + ReadThrottleFilter.class.getName() + " is allowed.");
-        }
-        
         if (!parent.contains(AbstractExecutorFilter.class)) {
             throw new IllegalStateException(
                     "At least one " + ExecutorFilter.class.getName() + " must exist in the chain.");