qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rob...@apache.org
Subject qpid-jms git commit: QPIDJMS-87: make the local maxFrameSize value configurable
Date Fri, 17 Jul 2015 16:16:41 GMT
Repository: qpid-jms
Updated Branches:
  refs/heads/master 32839a599 -> bf0dac455


QPIDJMS-87: make the local maxFrameSize value configurable


Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/bf0dac45
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/bf0dac45
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/bf0dac45

Branch: refs/heads/master
Commit: bf0dac455ae24261faa13fa3bde57984b7b6e336
Parents: 32839a5
Author: Robert Gemmell <robbie@apache.org>
Authored: Fri Jul 17 17:16:08 2015 +0100
Committer: Robert Gemmell <robbie@apache.org>
Committed: Fri Jul 17 17:16:08 2015 +0100

----------------------------------------------------------------------
 .../qpid/jms/provider/amqp/AmqpProvider.java    | 28 +++++++++++++-----
 .../integration/ConnectionIntegrationTest.java  | 31 ++++++++++++++++++++
 .../jms/integration/SaslIntegrationTest.java    |  2 +-
 .../provider/amqp/AmqpProviderFactoryTest.java  | 11 +++++++
 .../qpid/jms/test/testpeer/TestAmqpPeer.java    | 11 +++++--
 5 files changed, 71 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/bf0dac45/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpProvider.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpProvider.java
b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpProvider.java
index a927bf0..5db3472 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpProvider.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpProvider.java
@@ -118,6 +118,7 @@ public class AmqpProvider implements Provider, TransportListener {
     private int channelMax = DEFAULT_CHANNEL_MAX;
     private int idleTimeout = 60000;
     private long sessionOutoingWindow = -1; //Use proton default
+    private int maxFrameSize = DEFAULT_MAX_FRAME_SIZE;
 
     private final URI remoteURI;
     private final AtomicBoolean closed = new AtomicBoolean();
@@ -268,7 +269,10 @@ public class AmqpProvider implements Provider, TransportListener {
                             requestTimeout = connectionInfo.getRequestTimeout();
 
                             Connection protonConnection = Connection.Factory.create();
-                            protonTransport.setMaxFrameSize(getMaxFrameSize());
+
+                            if(getMaxFrameSize() > 0) {
+                                protonTransport.setMaxFrameSize(getMaxFrameSize());
+                            }
                             protonTransport.setChannelMax(getChannelMax());
                             protonTransport.setIdleTimeout(idleTimeout);
                             protonTransport.bind(protonConnection);
@@ -955,6 +959,21 @@ public class AmqpProvider implements Provider, TransportListener {
         this.idleTimeout = idleTimeout;
     }
 
+    public int getMaxFrameSize() {
+        return maxFrameSize;
+    }
+
+    /**
+     * Sets the max frame size (in bytes).
+     *
+     * Values of -1 indicates to use the proton default.
+     *
+     * @param maxFrameSize the frame size in bytes.
+     */
+    public void setMaxFrameSize(int maxFrameSize) {
+        this.maxFrameSize = maxFrameSize;
+    }
+
     public long getSessionOutgoingWindow() {
         return sessionOutoingWindow;
     }
@@ -1006,13 +1025,6 @@ public class AmqpProvider implements Provider, TransportListener {
         this.presettleProducers = presettle;
     }
 
-    /**
-     * @return the currently set Max Frame Size value.
-     */
-    public int getMaxFrameSize() {
-        return DEFAULT_MAX_FRAME_SIZE;
-    }
-
     @Override
     public String toString() {
         return "AmqpProvider: " + getRemoteURI().getHost() + ":" + getRemoteURI().getPort();

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/bf0dac45/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/ConnectionIntegrationTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/ConnectionIntegrationTest.java
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/ConnectionIntegrationTest.java
index 6cf87c6..a3b2b15 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/ConnectionIntegrationTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/ConnectionIntegrationTest.java
@@ -63,6 +63,7 @@ import org.apache.qpid.jms.test.testpeer.basictypes.ConnectionError;
 import org.apache.qpid.jms.test.testpeer.matchers.CoordinatorMatcher;
 import org.apache.qpid.jms.util.MetaDataSupport;
 import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.UnsignedInteger;
 import org.apache.qpid.proton.amqp.transaction.TxnCapability;
 import org.hamcrest.Matcher;
 import org.junit.Test;
@@ -150,6 +151,36 @@ public class ConnectionIntegrationTest extends QpidJmsTestCase {
     }
 
     @Test(timeout = 20000)
+    public void testMaxFrameSizeOptionCommunicatedInOpen() throws Exception {
+        int frameSize = 39215;
+        doMaxFrameSizeOptionTestImpl(frameSize, UnsignedInteger.valueOf(frameSize));
+    }
+
+    @Test(timeout = 20000)
+    public void testMaxFrameSizeOptionCommunicatedInOpenDefault() throws Exception {
+        doMaxFrameSizeOptionTestImpl(-1, UnsignedInteger.MAX_VALUE);
+    }
+
+    private void doMaxFrameSizeOptionTestImpl(int uriOption, UnsignedInteger transmittedValue)
throws JMSException, InterruptedException, Exception, IOException {
+        try (TestAmqpPeer testPeer = new TestAmqpPeer();) {
+            testPeer.expectSaslLayerDisabledConnect(equalTo(transmittedValue));
+            // Each connection creates a session for managing temporary destinations etc
+            testPeer.expectBegin();
+
+            String uri = "amqp://localhost:" + testPeer.getServerPort() + "?amqp.saslLayer=false&amqp.maxFrameSize="
+ uriOption;
+            ConnectionFactory factory = new JmsConnectionFactory(uri);
+            Connection connection = factory.createConnection();
+            connection.start();
+
+            testPeer.waitForAllHandlersToComplete(3000);
+            assertNull(testPeer.getThrowable());
+
+            testPeer.expectClose();
+            connection.close();
+        }
+    }
+
+    @Test(timeout = 20000)
     public void testAmqpHostnameSetByDefault() throws Exception {
         doAmqpHostnameTestImpl("localhost", false, equalTo("localhost"));
     }

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/bf0dac45/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SaslIntegrationTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SaslIntegrationTest.java
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SaslIntegrationTest.java
index 4f9c299..c41416b 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SaslIntegrationTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SaslIntegrationTest.java
@@ -227,7 +227,7 @@ public class SaslIntegrationTest extends QpidJmsTestCase {
     public void testSaslLayerDisabledConnection() throws Exception {
         try (TestAmqpPeer testPeer = new TestAmqpPeer();) {
             // Expect a connection with no SASL layer.
-            testPeer.expectSaslLayerDisabledConnect();
+            testPeer.expectSaslLayerDisabledConnect(null);
             // Each connection creates a session for managing temporary destinations etc
             testPeer.expectBegin();
 

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/bf0dac45/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/AmqpProviderFactoryTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/AmqpProviderFactoryTest.java
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/AmqpProviderFactoryTest.java
index c68559e..5068d6a 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/AmqpProviderFactoryTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/AmqpProviderFactoryTest.java
@@ -95,6 +95,17 @@ public class AmqpProviderFactoryTest extends QpidJmsTestCase {
     }
 
     @Test(timeout = 20000)
+    public void testCreateProviderAppliesMaxFrameSizeURIOption() throws IOException, Exception
{
+        int frameSize = 274893;
+        Provider provider = AmqpProviderFactory.create(new URI(peerURI.toString() + "?amqp.maxFrameSize="
+ frameSize));
+        assertNotNull(provider);
+        assertTrue(provider instanceof AmqpProvider);
+        AmqpProvider amqpProvider = (AmqpProvider) provider;
+
+        assertEquals("maxFrameSize option was not applied", frameSize, amqpProvider.getMaxFrameSize());
+    }
+
+    @Test(timeout = 20000)
     public void testCreateProviderAppliesOptions() throws IOException, Exception {
         URI configuredURI = new URI(peerURI.toString() +
             "?amqp.presettleConsumers=true" +

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/bf0dac45/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java
index e72f9d2..6f34ea5 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java
@@ -543,15 +543,20 @@ public class TestAmqpPeer implements AutoCloseable
      * to the AMQP connection (useful to skip a stage for connections that don't
      * require SASL, e.g. because of anonymous or client certificate authentication).
      */
-    public void expectSaslLayerDisabledConnect()
+    public void expectSaslLayerDisabledConnect(Matcher<?> maxFrameSizeMatcher)
     {
         addHandler(new HeaderHandlerImpl(AmqpHeader.HEADER, AmqpHeader.HEADER));
 
         OpenFrame openFrame = createOpenFrame();
 
         OpenMatcher openMatcher = new OpenMatcher()
-            .withContainerId(notNullValue(String.class))
-            .onCompletion(new FrameSender(
+            .withContainerId(notNullValue(String.class));
+
+        if(maxFrameSizeMatcher != null) {
+            openMatcher.withMaxFrameSize(maxFrameSizeMatcher);
+        }
+
+        openMatcher.onCompletion(new FrameSender(
                     this, FrameType.AMQP, 0,
                     openFrame,
                     null));


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message