You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ce...@apache.org on 2013/03/12 05:06:29 UTC
svn commit: r1455404 - in /activemq/activemq-apollo/trunk:
apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/
apollo-broker/src/test/resources/org/apache/activemq/apollo/broker/transport/
apollo-broker/src/test/scala/org/apache/activemq/ap...
Author: ceposta
Date: Tue Mar 12 04:06:28 2013
New Revision: 1455404
URL: http://svn.apache.org/r1455404
Log:
Changed to use boolean transport buffer auto tune settings and made docs more clear https://issues.apache.org/jira/browse/APLO-304
Added:
activemq/activemq-apollo/trunk/apollo-broker/src/test/resources/org/apache/activemq/apollo/broker/transport/
activemq/activemq-apollo/trunk/apollo-broker/src/test/resources/org/apache/activemq/apollo/broker/transport/auto-tune-config.xml
activemq/activemq-apollo/trunk/apollo-broker/src/test/scala/org/apache/activemq/apollo/broker/transport/ConfigForSocketAutoTuningTest.scala
Modified:
activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Connector.scala
activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/AcceptingConnectorDTO.java
activemq/activemq-apollo/trunk/apollo-website/src/documentation/user-manual.md
Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Connector.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Connector.scala?rev=1455404&r1=1455403&r2=1455404&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Connector.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Connector.scala Tue Mar 12 04:06:28 2013
@@ -137,6 +137,8 @@ class AcceptingConnector(val broker:Brok
var dead_messages_received:Long = 0
var dead_read_counter:Long = 0
var dead_write_counter:Long = 0
+ var receive_buffer_auto_tune = true;
+ var send_buffer_auto_tune = true;
def status = {
val result = new ConnectorStatusDTO
@@ -235,8 +237,8 @@ class AcceptingConnector(val broker:Brok
def mem_size(value:String) = Option(value).map(MemoryPropertyEditor.parse(_).toInt)
assert(config!=null, "Connector must be configured before it is started.")
- send_buffer_size = mem_size(config.send_buffer_size)
- receive_buffer_size = mem_size(config.receive_buffer_size)
+ receive_buffer_auto_tune = config.receive_buffer_auto_tune
+ send_buffer_auto_tune = config.send_buffer_auto_tune
accepted.set(0)
connected.set(0)
@@ -282,23 +284,29 @@ class AcceptingConnector(val broker:Brok
transport_server match {
case transport_server: TcpTransportServer =>
- val next_receive_buffer_size = receive_buffer_size.getOrElse(broker.auto_tuned_send_receiver_buffer_size)
- if( next_receive_buffer_size!=last_receive_buffer_size ) {
- debug("%s connector receive_buffer_size set to: %d", id, next_receive_buffer_size)
-
- // lets avoid updating the socket settings each period.
- transport_server.setReceiveBufferSize(next_receive_buffer_size)
- last_receive_buffer_size = next_receive_buffer_size
+ if(receive_buffer_auto_tune){
+ val next_receive_buffer_size = broker.auto_tuned_send_receiver_buffer_size
+ if( next_receive_buffer_size!=last_receive_buffer_size ) {
+ debug("%s connector receive_buffer_size set to: %d", id, next_receive_buffer_size)
+
+ // lets avoid updating the socket settings each period.
+ transport_server.setReceiveBufferSize(next_receive_buffer_size)
+ last_receive_buffer_size = next_receive_buffer_size
+ }
}
- val next_send_buffer_size = send_buffer_size.getOrElse(broker.auto_tuned_send_receiver_buffer_size)
- if( next_send_buffer_size!=last_send_buffer_size ) {
- debug("%s connector send_buffer_size set to: %d", id, next_send_buffer_size)
- // lets avoid updating the socket settings each period.
- transport_server.setSendBufferSize(next_send_buffer_size)
- last_send_buffer_size = next_send_buffer_size
+
+ if(send_buffer_auto_tune){
+ val next_send_buffer_size = broker.auto_tuned_send_receiver_buffer_size
+ if( next_send_buffer_size!=last_send_buffer_size ) {
+ debug("%s connector send_buffer_size set to: %d", id, next_send_buffer_size)
+ // lets avoid updating the socket settings each period.
+ transport_server.setSendBufferSize(next_send_buffer_size)
+ last_send_buffer_size = next_send_buffer_size
+ }
}
+
case _ =>
}
}
Added: activemq/activemq-apollo/trunk/apollo-broker/src/test/resources/org/apache/activemq/apollo/broker/transport/auto-tune-config.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/test/resources/org/apache/activemq/apollo/broker/transport/auto-tune-config.xml?rev=1455404&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/src/test/resources/org/apache/activemq/apollo/broker/transport/auto-tune-config.xml (added)
+++ activemq/activemq-apollo/trunk/apollo-broker/src/test/resources/org/apache/activemq/apollo/broker/transport/auto-tune-config.xml Tue Mar 12 04:06:28 2013
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<broker xmlns="http://activemq.apache.org/schema/activemq/apollo">
+
+ <virtual_host id="default">
+ <host_name>test</host_name>
+ </virtual_host>
+
+ <connector id="tcp" bind="tcp://0.0.0.0:61613" receive_buffer_auto_tune="false"
+ send_buffer_auto_tune="false"/>
+</broker>
Added: activemq/activemq-apollo/trunk/apollo-broker/src/test/scala/org/apache/activemq/apollo/broker/transport/ConfigForSocketAutoTuningTest.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/test/scala/org/apache/activemq/apollo/broker/transport/ConfigForSocketAutoTuningTest.scala?rev=1455404&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/src/test/scala/org/apache/activemq/apollo/broker/transport/ConfigForSocketAutoTuningTest.scala (added)
+++ activemq/activemq-apollo/trunk/apollo-broker/src/test/scala/org/apache/activemq/apollo/broker/transport/ConfigForSocketAutoTuningTest.scala Tue Mar 12 04:06:28 2013
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.apollo.broker.transport
+
+import org.apache.activemq.apollo.util.{ServiceControl, FunSuiteSupport}
+import org.apache.activemq.apollo.broker.{Broker, AcceptingConnector, Connector, BrokerFactory}
+
+/**
+ *
+ * @author <a href="http://www.christianposta.com/blog">Christian Posta</a>
+ */
+class ConfigForSocketAutoTuningTest extends FunSuiteSupport{
+
+ test("Config for socket receive buffers"){
+ val uri = "xml:classpath:org/apache/activemq/apollo/broker/transport/auto-tune-config.xml"
+ info("Loading broker configuration from the classpath with URI: " + uri)
+ val broker = BrokerFactory.createBroker(uri)
+ ServiceControl.start(broker, "broker")
+ broker.connectors.foreach{ case (s, c) =>
+ assert(!c.asInstanceOf[AcceptingConnector].receive_buffer_auto_tune)
+ assert(!c.asInstanceOf[AcceptingConnector].send_buffer_auto_tune)
+ }
+
+ ServiceControl.stop(broker, "broker")
+
+ }
+
+ test("Default auto tune settings"){
+ val broker = new Broker
+ ServiceControl.start(broker, "broker")
+ assert(broker.first_accepting_connector != null)
+ broker.connectors.foreach{ case (s, c) =>
+ assert(c.asInstanceOf[AcceptingConnector].receive_buffer_auto_tune)
+ assert(c.asInstanceOf[AcceptingConnector].send_buffer_auto_tune)
+ }
+ ServiceControl.stop(broker, "broker")
+ }
+
+}
Modified: activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/AcceptingConnectorDTO.java
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/AcceptingConnectorDTO.java?rev=1455404&r1=1455403&r2=1455404&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/AcceptingConnectorDTO.java (original)
+++ activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/AcceptingConnectorDTO.java Tue Mar 12 04:06:28 2013
@@ -60,6 +60,19 @@ public class AcceptingConnectorDTO exten
public String send_buffer_size;
/**
+ * Sets whether or not to auto tune the internal socket receive buffer (aka the socket's SO_RCVBUF)
+ */
+ @XmlAttribute(name="receive_buffer_auto_tune")
+ public boolean receive_buffer_auto_tune = true;
+
+
+ /**
+ * Sets whether or not to auto tune the internal socket send buffer (aka the socket's SO_SNDBUF)
+ */
+ @XmlAttribute(name="send_buffer_auto_tune")
+ public boolean send_buffer_auto_tune = true;
+
+ /**
* A broker accepts connections via it's configured connectors.
*/
@XmlElementRef
Modified: activemq/activemq-apollo/trunk/apollo-website/src/documentation/user-manual.md
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-website/src/documentation/user-manual.md?rev=1455404&r1=1455403&r2=1455404&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-website/src/documentation/user-manual.md (original)
+++ activemq/activemq-apollo/trunk/apollo-website/src/documentation/user-manual.md Tue Mar 12 04:06:28 2013
@@ -160,18 +160,18 @@ A `connector` element can be configured
* `protocol` : Defaults to `any` which means that any of the broker's
supported protocols can connect via this transport.
-* `receive_buffer_size` : Sets the size of the internal socket receive
- buffer (aka setting the socket's SO_RCVBUF) to a fixed value, and auto
- tuning will not be used.
-
-* `send_buffer_size` : Sets the size of the internal socket send buffer
- (aka setting the socket's SO_SNDBUF) to a fixed value, and auto-tuning
- will not be used.
-
-When the `receive_buffer_size` or `send_buffer_size` attributes are not set,
-then the broker will 'auto-tune' them to be between '64k' and '2k' based on the
-max number of connections established against the broker in the last 5 minutes
-and the size of the JVM heap.
+* `receive_buffer_size_auto_tune` : Sets whether or not to auto tune the internal
+ socket receive buffer (aka the socket's SO_RCVBUF). Auto tuning happens
+ every 1 second. Default is true
+
+* `send_buffer_size_auto_tune` : Sets whether or not to auto tune the internal
+ socket send buffer (aka the socket's SO_SNDBUF). Auto tuning happens
+ every 1 second. Default is true
+
+By default, the broker will 'auto-tune' a connector's transports to be between
+'64k' and '2k' based on the max number of connections established against the
+broker in the last 5 minutes and the size of the JVM heap. Set `receive_buffer_size_auto_tune`
+and `send_buffer_size_auto_tune` to false to disable this auto tuning.
Furthermore, the connector element may contain protocol specific
configuration elements. For example, to have the broker set the `user_id`