diff options
author | Robert Gemmell <robbie@apache.org> | 2012-02-19 20:32:26 +0000 |
---|---|---|
committer | Robert Gemmell <robbie@apache.org> | 2012-02-19 20:32:26 +0000 |
commit | f928e4f407cc362b20c19eeca7385978844dc892 (patch) | |
tree | 5c7373edd4ecf5effbc7e17aeac028d42a66c24d | |
parent | 5c03ef9789f31918b23ed4579e7bfb8531ffa509 (diff) | |
download | qpid-python-f928e4f407cc362b20c19eeca7385978844dc892.tar.gz |
QPID-3293: add new system properties for setting client send/receive buffer sizes on connections, restore legacy properties
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1291056 13f79535-47bb-0310-9956-ffa450edef68
3 files changed, 78 insertions, 9 deletions
diff --git a/java/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java b/java/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java index 19a77d143e..3227bb6fc2 100644 --- a/java/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java +++ b/java/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java @@ -134,7 +134,7 @@ public class ClientProperties /** * System property used to set the trust manager factory algorithm. * - * Historically, Qpid referred to this {@value #QPID_SSL_TRUST_STORE_CERT_TYPE_PROP_NAME}. + * Historically, Qpid referred to this as {@value #QPID_SSL_TRUST_STORE_CERT_TYPE_PROP_NAME}. */ public static final String QPID_SSL_TRUST_MANAGER_FACTORY_ALGORITHM_PROP_NAME = "qpid.ssl.TrustManagerFactory.algorithm"; @Deprecated @@ -150,4 +150,22 @@ public class ClientProperties * value is used in the ConnectionStartOk reply to the broker. */ public static final String PROCESS_NAME = "qpid.client_process"; + + /** + * System property used to set the socket receive buffer size. + * + * Historically, Qpid referred to this as {@value #LEGACY_RECEIVE_BUFFER_SIZE_PROP_NAME}. + */ + public static final String RECEIVE_BUFFER_SIZE_PROP_NAME = "qpid.receive_buffer_size"; + @Deprecated + public static final String LEGACY_RECEIVE_BUFFER_SIZE_PROP_NAME = "amqj.receiveBufferSize"; + + /** + * System property used to set the socket send buffer size. + * + * Historically, Qpid referred to this as {@value #LEGACY_SEND_BUFFER_SIZE_PROP_NAME}. + */ + public static final String SEND_BUFFER_SIZE_PROP_NAME = "qpid.send_buffer_size"; + @Deprecated + public static final String LEGACY_SEND_BUFFER_SIZE_PROP_NAME = "amqj.sendBufferSize"; } diff --git a/java/common/src/main/java/org/apache/qpid/transport/ConnectionSettings.java b/java/common/src/main/java/org/apache/qpid/transport/ConnectionSettings.java index d0eb44fffc..084428d182 100644 --- a/java/common/src/main/java/org/apache/qpid/transport/ConnectionSettings.java +++ b/java/common/src/main/java/org/apache/qpid/transport/ConnectionSettings.java @@ -20,6 +20,17 @@ */ package org.apache.qpid.transport; +import static org.apache.qpid.configuration.ClientProperties.AMQJ_TCP_NODELAY_PROP_NAME; +import static org.apache.qpid.configuration.ClientProperties.QPID_SSL_KEY_MANAGER_FACTORY_ALGORITHM_PROP_NAME; +import static org.apache.qpid.configuration.ClientProperties.QPID_SSL_KEY_STORE_CERT_TYPE_PROP_NAME; +import static org.apache.qpid.configuration.ClientProperties.QPID_SSL_TRUST_MANAGER_FACTORY_ALGORITHM_PROP_NAME; +import static org.apache.qpid.configuration.ClientProperties.QPID_SSL_TRUST_STORE_CERT_TYPE_PROP_NAME; +import static org.apache.qpid.configuration.ClientProperties.QPID_TCP_NODELAY_PROP_NAME; +import static org.apache.qpid.configuration.ClientProperties.RECEIVE_BUFFER_SIZE_PROP_NAME; +import static org.apache.qpid.configuration.ClientProperties.SEND_BUFFER_SIZE_PROP_NAME; +import static org.apache.qpid.configuration.ClientProperties.LEGACY_RECEIVE_BUFFER_SIZE_PROP_NAME; +import static org.apache.qpid.configuration.ClientProperties.LEGACY_SEND_BUFFER_SIZE_PROP_NAME; + import java.util.Map; import javax.net.ssl.KeyManagerFactory; @@ -27,12 +38,6 @@ import javax.net.ssl.TrustManagerFactory; import org.apache.qpid.configuration.QpidProperty; -import static org.apache.qpid.configuration.ClientProperties.QPID_TCP_NODELAY_PROP_NAME; -import static org.apache.qpid.configuration.ClientProperties.AMQJ_TCP_NODELAY_PROP_NAME; -import static org.apache.qpid.configuration.ClientProperties.QPID_SSL_KEY_MANAGER_FACTORY_ALGORITHM_PROP_NAME; -import static org.apache.qpid.configuration.ClientProperties.QPID_SSL_KEY_STORE_CERT_TYPE_PROP_NAME; -import static org.apache.qpid.configuration.ClientProperties.QPID_SSL_TRUST_MANAGER_FACTORY_ALGORITHM_PROP_NAME; -import static org.apache.qpid.configuration.ClientProperties.QPID_SSL_TRUST_STORE_CERT_TYPE_PROP_NAME; /** * A ConnectionSettings object can only be associated with @@ -54,8 +59,8 @@ public class ConnectionSettings private int maxChannelCount = 32767; private int maxFrameSize = 65535; private int heartbeatInterval; - private int readBufferSize = 65535; - private int writeBufferSize = 65535; + private int readBufferSize = QpidProperty.intProperty(65535, RECEIVE_BUFFER_SIZE_PROP_NAME, LEGACY_RECEIVE_BUFFER_SIZE_PROP_NAME).get(); + private int writeBufferSize = QpidProperty.intProperty(65535, SEND_BUFFER_SIZE_PROP_NAME, LEGACY_SEND_BUFFER_SIZE_PROP_NAME).get();; private long transportTimeout = 60000; // SSL props diff --git a/java/common/src/test/java/org/apache/qpid/transport/ConnectionSettingsTest.java b/java/common/src/test/java/org/apache/qpid/transport/ConnectionSettingsTest.java index 47773ff2f8..fc4f5374f0 100644 --- a/java/common/src/test/java/org/apache/qpid/transport/ConnectionSettingsTest.java +++ b/java/common/src/test/java/org/apache/qpid/transport/ConnectionSettingsTest.java @@ -101,6 +101,38 @@ public class ConnectionSettingsTest extends QpidTestCase systemPropertyOverrideForTrustFactoryAlgorithm(ClientProperties.QPID_SSL_TRUST_STORE_CERT_TYPE_PROP_NAME, algorithmName); } + public void testSendBufferSizeDefault() + { + assertEquals("unexpected default for buffer size", 65535, _conConnectionSettings.getWriteBufferSize()); + } + + public void testSendBufferSizeOverridden() + { + systemPropertyOverrideForSocketBufferSize(ClientProperties.SEND_BUFFER_SIZE_PROP_NAME, 1024, false); + } + + @SuppressWarnings("deprecation") + public void testtestSendBufferSizeOverriddenLegacyOverridden() + { + systemPropertyOverrideForSocketBufferSize(ClientProperties.LEGACY_SEND_BUFFER_SIZE_PROP_NAME, 1024, false); + } + + public void testReceiveBufferSizeDefault() + { + assertEquals("unexpected default for buffer size", 65535, _conConnectionSettings.getReadBufferSize()); + } + + public void testReceiveBufferSizeOverridden() + { + systemPropertyOverrideForSocketBufferSize(ClientProperties.RECEIVE_BUFFER_SIZE_PROP_NAME, 1024, true); + } + + @SuppressWarnings("deprecation") + public void testtestReceiveBufferSizeOverriddenLegacyOverridden() + { + systemPropertyOverrideForSocketBufferSize(ClientProperties.LEGACY_RECEIVE_BUFFER_SIZE_PROP_NAME, 1024, true); + } + private void systemPropertyOverrideForTcpDelay(String propertyName, boolean value) { resetSystemProperty(propertyName, String.valueOf(value)); @@ -119,6 +151,20 @@ public class ConnectionSettingsTest extends QpidTestCase assertEquals(value, _conConnectionSettings.getTrustManagerFactoryAlgorithm()); } + + private void systemPropertyOverrideForSocketBufferSize(String propertyName, int value, boolean read) + { + resetSystemProperty(propertyName, String.valueOf(value)); + if(read) + { + assertEquals("unexpected value for receive buffer", value, _conConnectionSettings.getReadBufferSize()); + } + else + { + assertEquals("unexpected value for send buffer", value, _conConnectionSettings.getWriteBufferSize()); + } + } + private void resetSystemProperty(String propertyName, String value) { setTestSystemProperty(propertyName, value); |