directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r388086 - in /directory/trunks/mina/core/src: main/java/org/apache/mina/common/ main/java/org/apache/mina/transport/socket/nio/support/ main/java/org/apache/mina/transport/vmpipe/support/ main/java/org/apache/mina/util/ test/java/org/apache...
Date Thu, 23 Mar 2006 07:39:28 GMT
Author: trustin
Date: Wed Mar 22 23:39:27 2006
New Revision: 388086

URL: http://svn.apache.org/viewcvs?rev=388086&view=rev
Log:
Resolved issue: DIRMINA-191 (IoSession.getScheduledWriteBytes)
* Added Queue.byteSize()
* Added getScheduledWriteBytes() to all IoSession implementations.

Modified:
    directory/trunks/mina/core/src/main/java/org/apache/mina/common/IoSession.java
    directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java
    directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/SocketSessionImpl.java
    directory/trunks/mina/core/src/main/java/org/apache/mina/transport/vmpipe/support/VmPipeSessionImpl.java
    directory/trunks/mina/core/src/main/java/org/apache/mina/util/Queue.java
    directory/trunks/mina/core/src/test/java/org/apache/mina/common/FutureTest.java
    directory/trunks/mina/core/src/test/java/org/apache/mina/common/IoFilterChainTest.java
    directory/trunks/mina/core/src/test/java/org/apache/mina/filter/ThreadPoolFilterRegressionTest.java
    directory/trunks/mina/core/src/test/java/org/apache/mina/filter/codec/CumulativeProtocolDecoderTest.java
    directory/trunks/mina/core/src/test/java/org/apache/mina/filter/codec/textline/TextLineDecoderTest.java
    directory/trunks/mina/core/src/test/java/org/apache/mina/filter/codec/textline/TextLineEncoderTest.java
    directory/trunks/mina/core/src/test/java/org/apache/mina/handler/chain/ChainedIoHandlerTest.java

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/common/IoSession.java
URL: http://svn.apache.org/viewcvs/directory/trunks/mina/core/src/main/java/org/apache/mina/common/IoSession.java?rev=388086&r1=388085&r2=388086&view=diff
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/common/IoSession.java (original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/common/IoSession.java Wed Mar
22 23:39:27 2006
@@ -275,6 +275,12 @@
     int getScheduledWriteRequests();
 
     /**
+     * Returns the number of bytes which are scheduled to be written to this
+     * session.
+     */
+    int getScheduledWriteBytes();
+
+    /**
      * Returns the time in millis when this session is created.
      */
     long getCreationTime();

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java
URL: http://svn.apache.org/viewcvs/directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java?rev=388086&r1=388085&r2=388086&view=diff
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java
(original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java
Wed Mar 22 23:39:27 2006
@@ -155,7 +155,15 @@
             return writeRequestQueue.size();
         }
     }
-
+    
+    public int getScheduledWriteBytes()
+    {
+        synchronized( writeRequestQueue )
+        {
+            return writeRequestQueue.byteSize();
+        }
+    }
+    
     public TransportType getTransportType()
     {
         return TransportType.DATAGRAM;

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/SocketSessionImpl.java
URL: http://svn.apache.org/viewcvs/directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/SocketSessionImpl.java?rev=388086&r1=388085&r2=388086&view=diff
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/SocketSessionImpl.java
(original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/SocketSessionImpl.java
Wed Mar 22 23:39:27 2006
@@ -162,6 +162,14 @@
         }
     }
 
+    public int getScheduledWriteBytes()
+    {
+        synchronized( writeRequestQueue )
+        {
+            return writeRequestQueue.byteSize();
+        }
+    }
+    
     protected void write0( WriteRequest writeRequest )
     {
         filterChain.filterWrite( this, writeRequest );

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/transport/vmpipe/support/VmPipeSessionImpl.java
URL: http://svn.apache.org/viewcvs/directory/trunks/mina/core/src/main/java/org/apache/mina/transport/vmpipe/support/VmPipeSessionImpl.java?rev=388086&r1=388085&r2=388086&view=diff
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/transport/vmpipe/support/VmPipeSessionImpl.java
(original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/transport/vmpipe/support/VmPipeSessionImpl.java
Wed Mar 22 23:39:27 2006
@@ -156,6 +156,11 @@
         return 0;
     }
 
+    public int getScheduledWriteBytes()
+    {
+        return 0;
+    }
+    
     public TransportType getTransportType()
     {
         return TransportType.VM_PIPE;

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/util/Queue.java
URL: http://svn.apache.org/viewcvs/directory/trunks/mina/core/src/main/java/org/apache/mina/util/Queue.java?rev=388086&r1=388085&r2=388086&view=diff
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/util/Queue.java (original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/util/Queue.java Wed Mar 22 23:39:27
2006
@@ -24,6 +24,8 @@
 import java.util.List;
 import java.util.NoSuchElementException;
 
+import org.apache.mina.common.ByteBuffer;
+
 /**
  * A unbounded circular queue.
  * 
@@ -162,6 +164,43 @@
     public int size()
     {
         return size;
+    }
+    
+    /**
+     * Returns the sum of the '<tt>remaining</tt>' of all {@link ByteBuffer}s
+     * in this queue.
+     * 
+     * @throws ClassCastException if an element is not a {@link ByteBuffer}
+     */
+    public int byteSize()
+    {
+        if( isEmpty() )
+        {
+            return 0;
+        }
+        
+        int byteSize = 0;
+        
+        if( first < last )
+        {
+            for( int i = first; i < last; i++ )
+            {
+                byteSize += ( ( ByteBuffer ) items[ i ] ).remaining();
+            }
+        }
+        else
+        {
+            for( int i = first; i < items.length; i++ )
+            {
+                byteSize += ( ( ByteBuffer ) items[ i ] ).remaining();
+            }
+            for( int i = last - 1; i >= 0; i-- )
+            {
+                byteSize += ( ( ByteBuffer ) items[ i ] ).remaining();
+            }
+        }
+        
+        return byteSize;
     }
     
     public String toString()

Modified: directory/trunks/mina/core/src/test/java/org/apache/mina/common/FutureTest.java
URL: http://svn.apache.org/viewcvs/directory/trunks/mina/core/src/test/java/org/apache/mina/common/FutureTest.java?rev=388086&r1=388085&r2=388086&view=diff
==============================================================================
--- directory/trunks/mina/core/src/test/java/org/apache/mina/common/FutureTest.java (original)
+++ directory/trunks/mina/core/src/test/java/org/apache/mina/common/FutureTest.java Wed Mar
22 23:39:27 2006
@@ -112,8 +112,14 @@
                 return null;
             }
 
-            public SocketAddress getServiceAddress() {
+            public SocketAddress getServiceAddress()
+            {
                 return null;
+            }
+
+            public int getScheduledWriteBytes()
+            {
+                return 0;
             }
         };
         

Modified: directory/trunks/mina/core/src/test/java/org/apache/mina/common/IoFilterChainTest.java
URL: http://svn.apache.org/viewcvs/directory/trunks/mina/core/src/test/java/org/apache/mina/common/IoFilterChainTest.java?rev=388086&r1=388085&r2=388086&view=diff
==============================================================================
--- directory/trunks/mina/core/src/test/java/org/apache/mina/common/IoFilterChainTest.java
(original)
+++ directory/trunks/mina/core/src/test/java/org/apache/mina/common/IoFilterChainTest.java
Wed Mar 22 23:39:27 2006
@@ -308,6 +308,10 @@
         public SocketAddress getServiceAddress() {
             return null;
         }
+
+        public int getScheduledWriteBytes() {
+            return 0;
+        }
     }
 
     private class EventOrderTestFilter extends IoFilterAdapter
@@ -430,8 +434,14 @@
                     return null;
                 }
 
-                public SocketAddress getServiceAddress() {
+                public SocketAddress getServiceAddress()
+                {
                     return null;
+                }
+
+                public int getScheduledWriteBytes()
+                {
+                    return 0;
                 }
             } );
         }

Modified: directory/trunks/mina/core/src/test/java/org/apache/mina/filter/ThreadPoolFilterRegressionTest.java
URL: http://svn.apache.org/viewcvs/directory/trunks/mina/core/src/test/java/org/apache/mina/filter/ThreadPoolFilterRegressionTest.java?rev=388086&r1=388085&r2=388086&view=diff
==============================================================================
--- directory/trunks/mina/core/src/test/java/org/apache/mina/filter/ThreadPoolFilterRegressionTest.java
(original)
+++ directory/trunks/mina/core/src/test/java/org/apache/mina/filter/ThreadPoolFilterRegressionTest.java
Wed Mar 22 23:39:27 2006
@@ -197,9 +197,15 @@
             return null;
         }
 
-        public SocketAddress getServiceAddress() {
+        public SocketAddress getServiceAddress()
+        {
             return null;
         }
+
+        public int getScheduledWriteBytes()
+        {
+            return 0;
+        }
     }
     
     private static class EventOrderChecker implements NextFilter
@@ -310,8 +316,14 @@
             return null;
         }
 
-        public SocketAddress getServiceAddress() {
+        public SocketAddress getServiceAddress()
+        {
             return null;
+        }
+
+        public int getScheduledWriteBytes()
+        {
+            return 0;
         }
     }
     

Modified: directory/trunks/mina/core/src/test/java/org/apache/mina/filter/codec/CumulativeProtocolDecoderTest.java
URL: http://svn.apache.org/viewcvs/directory/trunks/mina/core/src/test/java/org/apache/mina/filter/codec/CumulativeProtocolDecoderTest.java?rev=388086&r1=388085&r2=388086&view=diff
==============================================================================
--- directory/trunks/mina/core/src/test/java/org/apache/mina/filter/codec/CumulativeProtocolDecoderTest.java
(original)
+++ directory/trunks/mina/core/src/test/java/org/apache/mina/filter/codec/CumulativeProtocolDecoderTest.java
Wed Mar 22 23:39:27 2006
@@ -239,8 +239,14 @@
             return null;
         }
 
-        public SocketAddress getServiceAddress() {
+        public SocketAddress getServiceAddress()
+        {
             return null;
+        }
+
+        public int getScheduledWriteBytes()
+        {
+            return 0;
         }
     }
 }

Modified: directory/trunks/mina/core/src/test/java/org/apache/mina/filter/codec/textline/TextLineDecoderTest.java
URL: http://svn.apache.org/viewcvs/directory/trunks/mina/core/src/test/java/org/apache/mina/filter/codec/textline/TextLineDecoderTest.java?rev=388086&r1=388085&r2=388086&view=diff
==============================================================================
--- directory/trunks/mina/core/src/test/java/org/apache/mina/filter/codec/textline/TextLineDecoderTest.java
(original)
+++ directory/trunks/mina/core/src/test/java/org/apache/mina/filter/codec/textline/TextLineDecoderTest.java
Wed Mar 22 23:39:27 2006
@@ -225,8 +225,14 @@
             return null;
         }
 
-        public SocketAddress getServiceAddress() {
+        public SocketAddress getServiceAddress()
+        {
             return null;
+        }
+
+        public int getScheduledWriteBytes()
+        {
+            return 0;
         }
     }
 }

Modified: directory/trunks/mina/core/src/test/java/org/apache/mina/filter/codec/textline/TextLineEncoderTest.java
URL: http://svn.apache.org/viewcvs/directory/trunks/mina/core/src/test/java/org/apache/mina/filter/codec/textline/TextLineEncoderTest.java?rev=388086&r1=388085&r2=388086&view=diff
==============================================================================
--- directory/trunks/mina/core/src/test/java/org/apache/mina/filter/codec/textline/TextLineEncoderTest.java
(original)
+++ directory/trunks/mina/core/src/test/java/org/apache/mina/filter/codec/textline/TextLineEncoderTest.java
Wed Mar 22 23:39:27 2006
@@ -119,8 +119,14 @@
             return null;
         }
 
-        public SocketAddress getServiceAddress() {
+        public SocketAddress getServiceAddress()
+        {
             return null;
+        }
+
+        public int getScheduledWriteBytes()
+        {
+            return 0;
         }
     }
 }

Modified: directory/trunks/mina/core/src/test/java/org/apache/mina/handler/chain/ChainedIoHandlerTest.java
URL: http://svn.apache.org/viewcvs/directory/trunks/mina/core/src/test/java/org/apache/mina/handler/chain/ChainedIoHandlerTest.java?rev=388086&r1=388085&r2=388086&view=diff
==============================================================================
--- directory/trunks/mina/core/src/test/java/org/apache/mina/handler/chain/ChainedIoHandlerTest.java
(original)
+++ directory/trunks/mina/core/src/test/java/org/apache/mina/handler/chain/ChainedIoHandlerTest.java
Wed Mar 22 23:39:27 2006
@@ -99,8 +99,14 @@
                         return null;
                     }
 
-                    public SocketAddress getServiceAddress() {
+                    public SocketAddress getServiceAddress()
+                    {
                         return null;
+                    }
+
+                    public int getScheduledWriteBytes()
+                    {
+                        return 0;
                     }
                 }, null );
         



Mime
View raw message