activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1241034 - in /activemq/activemq-apollo/trunk: apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/protocol/ apollo-dto/src/main/java/org/apache/activemq/apollo/dto/ apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/ a...
Date Mon, 06 Feb 2012 15:04:28 GMT
Author: chirino
Date: Mon Feb  6 15:04:28 2012
New Revision: 1241034

URL: http://svn.apache.org/viewvc?rev=1241034&view=rev
Log:
Fixes APLO-151 - Support configuring the protocol detection timeout and the STOMP die delay.

Added:
    activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/DetectDTO.java
      - copied, changed from r1240841, activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/Module.java
Modified:
    activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/protocol/AnyProtocol.scala
    activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/Module.java
    activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompProtocolHandler.scala
    activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/dto/StompDTO.java

Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/protocol/AnyProtocol.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/protocol/AnyProtocol.scala?rev=1241034&r1=1241033&r2=1241034&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/protocol/AnyProtocol.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/protocol/AnyProtocol.scala
Mon Feb  6 15:04:28 2012
@@ -16,17 +16,18 @@
  */
 package org.apache.activemq.apollo.broker.protocol
 
-import org.apache.activemq.apollo.broker.{Message, ProtocolException}
-import org.fusesource.hawtbuf.{AsciiBuffer, Buffer}
+import org.fusesource.hawtbuf.Buffer
 import org.apache.activemq.apollo.broker.store.MessageRecord
-import org.fusesource.hawtdispatch.transport.{ProtocolCodec}
+import org.fusesource.hawtdispatch.transport.ProtocolCodec
 import java.nio.channels.{WritableByteChannel, ReadableByteChannel}
 import java.nio.ByteBuffer
 import java.io.IOException
 import java.lang.String
 import java.util.concurrent.TimeUnit
 import org.fusesource.hawtdispatch._
-import org.fusesource.hawtdispatch.transport.ProtocolCodec.BufferState
+import org.apache.activemq.apollo.util.OptionSupport
+import org.apache.activemq.apollo.broker.{Message, ProtocolException}
+import org.apache.activemq.apollo.dto.{DetectDTO, AcceptingConnectorDTO}
 
 /**
  * <p>
@@ -156,6 +157,8 @@ class AnyProtocolHandler extends Protoco
 
   def session_id = None
 
+  var config:DetectDTO = _
+
   override def on_transport_command(command: AnyRef) = {
 
     if (!command.isInstanceOf[ProtocolDetected]) {
@@ -182,9 +185,19 @@ class AnyProtocolHandler extends Protoco
 
   override def on_transport_connected = {
     connection.transport.resumeRead
+    import OptionSupport._
+    import collection.JavaConversions._
+    
+    val connector_config = connection.connector.config.asInstanceOf[AcceptingConnectorDTO]
+    config = connector_config.protocols.flatMap{ _ match {
+      case x:DetectDTO => Some(x)
+      case _ => None
+    }}.headOption.getOrElse(new DetectDTO)
     
+    val timeout = config.timeout.getOrElse(5000L)
+  
     // Make sure client connects eventually...
-    connection.dispatch_queue.after(5, TimeUnit.SECONDS) {
+    connection.dispatch_queue.after(timeout, TimeUnit.MILLISECONDS) {
       assert_discriminated
     }
   }

Copied: activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/DetectDTO.java
(from r1240841, activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/Module.java)
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/DetectDTO.java?p2=activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/DetectDTO.java&p1=activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/Module.java&r1=1240841&r2=1241034&rev=1241034&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/Module.java
(original)
+++ activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/DetectDTO.java
Mon Feb  6 15:04:28 2012
@@ -16,26 +16,24 @@
  */
 package org.apache.activemq.apollo.dto;
 
-import org.apache.activemq.apollo.util.DtoModule;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
 
 /**
- * <p>
- * </p>
+ * Allow you to customize protocol detection handling.
  *
  * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
  */
-public class Module implements DtoModule {
-    public String dto_package() {
-        return "org.apache.activemq.apollo.dto";
-    }
-    public Class<?>[] extension_classes() {
-        return new Class<?>[]{
-                AcceptingConnectorDTO.class,
-                TopicDestinationDTO.class,
-                DurableSubscriptionDestinationDTO.class,
-                QueueDestinationDTO.class,
-                NullStoreDTO.class,
-                SimpleStoreStatusDTO.class
-        };
-    }
+@XmlRootElement(name="detect")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class DetectDTO extends ProtocolDTO {
+
+    /**
+     * The protocol detection timeout in milliseconds.  Defaults to 5000 if not set.
+     */
+    @XmlAttribute(name="timeout")
+    public Long timeout;
+
 }

Modified: activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/Module.java
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/Module.java?rev=1241034&r1=1241033&r2=1241034&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/Module.java
(original)
+++ activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/Module.java
Mon Feb  6 15:04:28 2012
@@ -35,7 +35,8 @@ public class Module implements DtoModule
                 DurableSubscriptionDestinationDTO.class,
                 QueueDestinationDTO.class,
                 NullStoreDTO.class,
-                SimpleStoreStatusDTO.class
+                SimpleStoreStatusDTO.class,
+                DetectDTO.class
         };
     }
 }

Modified: activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompProtocolHandler.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompProtocolHandler.scala?rev=1241034&r1=1241033&r2=1241034&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompProtocolHandler.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompProtocolHandler.scala
Mon Feb  6 15:04:28 2012
@@ -59,7 +59,6 @@ object StompProtocolHandler extends Log 
   // How long we hold a failed connection open so that the remote end
   // can get the resulting error message.
   val DEFAULT_DIE_DELAY = 5*1000L
-  var die_delay = DEFAULT_DIE_DELAY
 
     // How often we can send heartbeats of the connection is idle.
   val DEFAULT_OUTBOUND_HEARTBEAT = 100L
@@ -588,7 +587,10 @@ class StompProtocolHandler extends Proto
     }
   }
 
-
+  def die_delay = {
+    import OptionSupport._
+    config.die_delay.getOrElse(DEFAULT_DIE_DELAY)
+  }
 
   override def set_connection(connection: BrokerConnection) = {
     super.set_connection(connection)

Modified: activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/dto/StompDTO.java
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/dto/StompDTO.java?rev=1241034&r1=1241033&r2=1241034&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/dto/StompDTO.java
(original)
+++ activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/dto/StompDTO.java
Mon Feb  6 15:04:28 2012
@@ -101,6 +101,9 @@ public class StompDTO extends ProtocolDT
     @XmlAttribute(name="regex_wildcard_end")
     public String regex_wildcard_end;
 
+    @XmlAttribute(name="die_delay")
+    public Long die_delay;
+
     @Override
     public boolean equals(Object o) {
         if (this == o) return true;



Mime
View raw message