activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1331470 - /activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompCodec.scala
Date Fri, 27 Apr 2012 15:32:00 GMT
Author: chirino
Date: Fri Apr 27 15:32:00 2012
New Revision: 1331470

URL: http://svn.apache.org/viewvc?rev=1331470&view=rev
Log:
Use the new transport aware interface of hawtdispatch to more reliably figure out the read/write
buffer sizes for the stomp codec.

Modified:
    activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompCodec.scala

Modified: activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompCodec.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompCodec.scala?rev=1331470&r1=1331469&r2=1331470&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompCodec.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompCodec.scala
Fri Apr 27 15:32:00 2012
@@ -134,7 +134,7 @@ object StompCodec extends Log {
 
 }
 
-class StompCodec extends ProtocolCodec {
+class StompCodec extends ProtocolCodec with TransportAware {
 
   import StompCodec._
   var max_header_length = 1024*10
@@ -172,11 +172,33 @@ class StompCodec extends ProtocolCodec {
   def full = next_write_direct!=null || next_write_buffer.size >= (write_buffer_size >>
1)
   def is_empty = write_buffer.remaining == 0 && write_direct==null
 
+  def setTransport(transport:Transport) {
+    transport match {
+      case tcp:TcpTransport=>
+        write_buffer_size = tcp.getSendBufferSize();
+        read_buffer_size = tcp.getReceiveBufferSize();
+      case udp:UdpTransport=>
+        write_buffer_size = udp.getSendBufferSize();
+        read_buffer_size = udp.getReceiveBufferSize();
+      case _ =>
+        try {
+          write_channel match {
+            case channel:SocketChannel =>
+              write_buffer_size = channel.socket.getSendBufferSize();
+              read_buffer_size = channel.socket.getReceiveBufferSize()
+            case channel:SslTransport#SSLChannel =>
+              write_buffer_size = channel.socket.getSendBufferSize();
+              read_buffer_size = channel.socket.getReceiveBufferSize()
+          }
+        } catch {
+          case _ =>
+        }
+
+    }
+  }
+
   def setWritableByteChannel(channel: WritableByteChannel) = {
     this.write_channel = channel
-    if( this.write_channel.isInstanceOf[SocketChannel] ) {
-      write_buffer_size = this.write_channel.asInstanceOf[SocketChannel].socket().getSendBufferSize
-    }
   }
 
   def getWriteCounter = write_counter
@@ -319,9 +341,6 @@ class StompCodec extends ProtocolCodec {
 
   def setReadableByteChannel(channel: ReadableByteChannel) = {
     this.read_channel = channel
-    if( this.read_channel.isInstanceOf[SocketChannel] ) {
-      read_buffer_size = this.read_channel.asInstanceOf[SocketChannel].socket().getReceiveBufferSize
-    }
   }
 
   def unread(buffer: Array[Byte]) = {



Mime
View raw message