diff options
author | Kim van der Riet <kpvdr@apache.org> | 2012-08-27 15:40:33 +0000 |
---|---|---|
committer | Kim van der Riet <kpvdr@apache.org> | 2012-08-27 15:40:33 +0000 |
commit | 868ce7469262d6fd2fe3f2e7f04cfe7af654d59f (patch) | |
tree | 63e6b5e62554609beb21e8c8d0610569f36d2743 /java/common/src | |
parent | 2e5ff8f1b328831043e6d7e323249d62187234c6 (diff) | |
download | qpid-python-868ce7469262d6fd2fe3f2e7f04cfe7af654d59f.tar.gz |
QPID-3858: Updated code to include recent refactoring by Gordon (gsim) - see QPID-4178.
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/asyncstore@1377715 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/common/src')
-rw-r--r-- | java/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java | 13 | ||||
-rw-r--r-- | java/common/src/main/java/org/apache/qpid/configuration/CommonProperties.java (renamed from java/common/src/main/java/org/apache/qpid/transport/ProtocolViolationException.java) | 20 | ||||
-rw-r--r-- | java/common/src/main/java/org/apache/qpid/transport/Connection.java | 26 | ||||
-rw-r--r-- | java/common/src/main/java/org/apache/qpid/transport/ConnectionSettings.java | 22 | ||||
-rw-r--r-- | java/common/src/main/java/org/apache/qpid/transport/network/io/IoNetworkTransport.java | 7 |
5 files changed, 58 insertions, 30 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 97fbd43ea0..5268ce9bc2 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 @@ -20,10 +20,11 @@ package org.apache.qpid.configuration; /** * This class centralized the Qpid client properties. + * + * @see CommonProperties */ public class ClientProperties { - /** * Currently with Qpid it is not possible to change the client ID. * If one is not specified upon connection construction, an id is generated automatically. @@ -118,10 +119,6 @@ public class ClientProperties */ public static final String REJECT_BEHAVIOUR_PROP_NAME = "qpid.reject.behaviour"; - private ClientProperties() - { - } - /** * System property used to set the key manager factory algorithm. * @@ -192,4 +189,10 @@ public class ClientProperties * waiting because the client was flow controlled by the broker. */ public static final long DEFAULT_FLOW_CONTROL_WAIT_NOTIFY_PERIOD = 5000L; + + + private ClientProperties() + { + //No instances + } } diff --git a/java/common/src/main/java/org/apache/qpid/transport/ProtocolViolationException.java b/java/common/src/main/java/org/apache/qpid/configuration/CommonProperties.java index 6787157e8e..2449f457e5 100644 --- a/java/common/src/main/java/org/apache/qpid/transport/ProtocolViolationException.java +++ b/java/common/src/main/java/org/apache/qpid/configuration/CommonProperties.java @@ -18,18 +18,24 @@ * under the License. * */ -package org.apache.qpid.transport; - +package org.apache.qpid.configuration; /** - * ProtocolViolationException + * Centralised record of Qpid common properties. * + * @see ClientProperties */ - -public final class ProtocolViolationException extends ConnectionException +public class CommonProperties { - public ProtocolViolationException(String msg,Throwable cause) + /** + * The timeout used by the IO layer for timeouts such as send timeout in IoSender, and the close timeout for IoSender and IoReceiver + */ + public static final String IO_NETWORK_TRANSPORT_TIMEOUT_PROP_NAME = "qpid.io_network_transport_timeout"; + public static final int IO_NETWORK_TRANSPORT_TIMEOUT_DEFAULT = 60000; + + + private CommonProperties() { - super(msg, cause); + //no instances } } 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 388e3442bf..e87851cf7d 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 @@ -382,7 +382,7 @@ public class Connection extends ConnectionInvoker { log.debug("SEND: [%s] %s", this, event); } - Sender s = sender; + Sender<ProtocolEvent> s = sender; if (s == null) { throw new ConnectionException("connection closed"); @@ -415,15 +415,23 @@ public class Connection extends ConnectionInvoker public void dispatch(Method method) { - Session ssn = getSession(method.getChannel()); + int channel = method.getChannel(); + Session ssn = getSession(channel); if(ssn != null) { ssn.received(method); } else { - throw new ProtocolViolationException( - "Received frames for an already detached session", null); + /* + * A peer receiving any other control on a detached transport MUST discard it and + * send a session.detached with the "not-attached" reason code. + */ + if(log.isDebugEnabled()) + { + log.debug("Control received on unattached channel : %d", channel); + } + invokeSessionDetached(channel, SessionDetachCode.NOT_ATTACHED); } } @@ -663,7 +671,7 @@ public class Connection extends ConnectionInvoker public void setServerProperties(final Map<String, Object> serverProperties) { - _serverProperties = serverProperties == null ? Collections.EMPTY_MAP : serverProperties; + _serverProperties = serverProperties == null ? Collections.<String, Object>emptyMap() : serverProperties; } public Map<String, Object> getServerProperties() @@ -719,4 +727,12 @@ public class Connection extends ConnectionInvoker { return _localAddress; } + + private void invokeSessionDetached(int channel, SessionDetachCode sessionDetachCode) + { + SessionDetached sessionDetached = new SessionDetached(); + sessionDetached.setChannel(channel); + sessionDetached.setCode(sessionDetachCode); + invoke(sessionDetached); + } } 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 c90a11594c..14dfeb18ec 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 @@ -60,9 +60,9 @@ public class ConnectionSettings private int maxChannelCount = 32767; private int maxFrameSize = 65535; private int heartbeatInterval; + private int connectTimeout = 30000; 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 private boolean useSSL; @@ -345,6 +345,16 @@ public class ConnectionSettings this.trustStoreType = trustStoreType; } + public int getConnectTimeout() + { + return connectTimeout; + } + + public void setConnectTimeout(int connectTimeout) + { + this.connectTimeout = connectTimeout; + } + public int getReadBufferSize() { return readBufferSize; @@ -364,14 +374,4 @@ public class ConnectionSettings { this.writeBufferSize = writeBufferSize; } - - public long getTransportTimeout() - { - return transportTimeout; - } - - public void setTransportTimeout(long transportTimeout) - { - this.transportTimeout = transportTimeout; - } } diff --git a/java/common/src/main/java/org/apache/qpid/transport/network/io/IoNetworkTransport.java b/java/common/src/main/java/org/apache/qpid/transport/network/io/IoNetworkTransport.java index dfb318b80c..9b6f0a0b1b 100644 --- a/java/common/src/main/java/org/apache/qpid/transport/network/io/IoNetworkTransport.java +++ b/java/common/src/main/java/org/apache/qpid/transport/network/io/IoNetworkTransport.java @@ -33,6 +33,8 @@ import javax.net.ssl.SSLPeerUnverifiedException; import javax.net.ssl.SSLServerSocket; import javax.net.ssl.SSLServerSocketFactory; import javax.net.ssl.SSLSocket; + +import org.apache.qpid.configuration.CommonProperties; import org.apache.qpid.protocol.ProtocolEngine; import org.apache.qpid.protocol.ProtocolEngineFactory; import org.apache.qpid.transport.ConnectionSettings; @@ -47,7 +49,8 @@ import org.slf4j.LoggerFactory; public class IoNetworkTransport implements OutgoingNetworkTransport, IncomingNetworkTransport { private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(IoNetworkTransport.class); - private static final int TIMEOUT = 60000; + private static final int TIMEOUT = Integer.getInteger(CommonProperties.IO_NETWORK_TRANSPORT_TIMEOUT_PROP_NAME, + CommonProperties.IO_NETWORK_TRANSPORT_TIMEOUT_DEFAULT); private Socket _socket; private IoNetworkConnection _connection; @@ -75,7 +78,7 @@ public class IoNetworkTransport implements OutgoingNetworkTransport, IncomingNet InetAddress address = InetAddress.getByName(settings.getHost()); - _socket.connect(new InetSocketAddress(address, settings.getPort()), TIMEOUT); + _socket.connect(new InetSocketAddress(address, settings.getPort()), settings.getConnectTimeout()); } catch (SocketException e) { |