From 12181a6cd1fde75d48d4c048d9dd704e2f901524 Mon Sep 17 00:00:00 2001 From: Robert Gemmell Date: Mon, 8 Aug 2011 22:54:37 +0000 Subject: QPID-3385: assign IDs from a generator within the MultiVersionProtocolEngineFactory, which is shared across all protocol versions git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1155136 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/qpid/protocol/ServerProtocolEngine.java | 29 ++++++++++++++++++++++ .../java/org/apache/qpid/transport/Connection.java | 7 ------ .../org/apache/qpid/transport/ServerDelegate.java | 22 ++++++---------- .../network/mina/MinaNetworkHandlerTest.java | 8 +++++- 4 files changed, 43 insertions(+), 23 deletions(-) create mode 100644 java/common/src/main/java/org/apache/qpid/protocol/ServerProtocolEngine.java (limited to 'java/common') diff --git a/java/common/src/main/java/org/apache/qpid/protocol/ServerProtocolEngine.java b/java/common/src/main/java/org/apache/qpid/protocol/ServerProtocolEngine.java new file mode 100644 index 0000000000..e8362f79f0 --- /dev/null +++ b/java/common/src/main/java/org/apache/qpid/protocol/ServerProtocolEngine.java @@ -0,0 +1,29 @@ +/* + * + * 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.qpid.protocol; + +public interface ServerProtocolEngine extends ProtocolEngine +{ + /** + * Gets the connection ID associated with this ProtocolEngine + */ + long getConnectionId(); +} diff --git a/java/common/src/main/java/org/apache/qpid/transport/Connection.java b/java/common/src/main/java/org/apache/qpid/transport/Connection.java index 7d17397b2d..eef6c047d3 100644 --- a/java/common/src/main/java/org/apache/qpid/transport/Connection.java +++ b/java/common/src/main/java/org/apache/qpid/transport/Connection.java @@ -126,8 +126,6 @@ public class Connection extends ConnectionInvoker private SecurityLayer securityLayer; private String _clientId; - private static final AtomicLong idGenerator = new AtomicLong(0); - private final long _connectionId = idGenerator.incrementAndGet(); private final AtomicBoolean connectionLost = new AtomicBoolean(false); public Connection() {} @@ -360,11 +358,6 @@ public class Connection extends ConnectionInvoker _sessionFactory = sessionFactory; } - public long getConnectionId() - { - return _connectionId; - } - public ConnectionDelegate getConnectionDelegate() { return delegate; diff --git a/java/common/src/main/java/org/apache/qpid/transport/ServerDelegate.java b/java/common/src/main/java/org/apache/qpid/transport/ServerDelegate.java index 11af86f412..82fa6ca473 100644 --- a/java/common/src/main/java/org/apache/qpid/transport/ServerDelegate.java +++ b/java/common/src/main/java/org/apache/qpid/transport/ServerDelegate.java @@ -170,22 +170,7 @@ public class ServerDelegate extends ConnectionDelegate @Override public void connectionTuneOk(Connection conn, ConnectionTuneOk ok) { - int okChannelMax = ok.getChannelMax(); - - if (okChannelMax > getChannelMax()) - { - _logger.error("Connection '" + conn.getConnectionId() + "' being severed, " + - "client connectionTuneOk returned a channelMax (" + okChannelMax + - ") above the servers offered limit (" + getChannelMax() +")"); - - //Due to the error we must forcefully close the connection without negotiation - conn.getSender().close(); - return; - } - //0 means no implied limit, except available server resources - //(or that forced by protocol limitations [0xFFFF]) - conn.setChannelMax(okChannelMax == 0 ? Connection.MAX_CHANNEL_MAX : okChannelMax); } @Override @@ -215,4 +200,11 @@ public class ServerDelegate extends ConnectionDelegate ssn.sessionAttached(atc.getName()); ssn.setState(Session.State.OPEN); } + + protected void setConnectionTuneOkChannelMax(final Connection conn, final int okChannelMax) + { + //0 means no implied limit, except available server resources + //(or that forced by protocol limitations [0xFFFF]) + conn.setChannelMax(okChannelMax == 0 ? Connection.MAX_CHANNEL_MAX : okChannelMax); + } } diff --git a/java/common/src/test/java/org/apache/qpid/transport/network/mina/MinaNetworkHandlerTest.java b/java/common/src/test/java/org/apache/qpid/transport/network/mina/MinaNetworkHandlerTest.java index 1a1b5af805..976b141fc0 100644 --- a/java/common/src/test/java/org/apache/qpid/transport/network/mina/MinaNetworkHandlerTest.java +++ b/java/common/src/test/java/org/apache/qpid/transport/network/mina/MinaNetworkHandlerTest.java @@ -34,6 +34,7 @@ import java.util.concurrent.TimeUnit; import org.apache.qpid.framing.AMQDataBlock; import org.apache.qpid.protocol.ProtocolEngine; import org.apache.qpid.protocol.ProtocolEngineFactory; +import org.apache.qpid.protocol.ServerProtocolEngine; import org.apache.qpid.test.utils.QpidTestCase; import org.apache.qpid.transport.ConnectionSettings; import org.apache.qpid.transport.NetworkTransportConfiguration; @@ -333,7 +334,7 @@ public class MinaNetworkHandlerTest extends QpidTestCase } } - public class CountingProtocolEngine implements ProtocolEngine + public class CountingProtocolEngine implements ServerProtocolEngine { public ArrayList _receivedBytes = new ArrayList(); private int _readBytes; @@ -447,6 +448,11 @@ public class MinaNetworkHandlerTest extends QpidTestCase return _closed; } + public long getConnectionId() + { + return -1; + } + } private class EchoProtocolEngine extends CountingProtocolEngine -- cgit v1.2.1