diff options
| author | Kim van der Riet <kpvdr@apache.org> | 2007-01-25 21:00:22 +0000 |
|---|---|---|
| committer | Kim van der Riet <kpvdr@apache.org> | 2007-01-25 21:00:22 +0000 |
| commit | 58f37a88b1cf6e6a3fa27d184238885a875cbb9f (patch) | |
| tree | aaad64c2879a64275a41097c58cfff609b603e8f /java/client | |
| parent | 3335bfa2ddc5c83890b967792fb2442ee0680b83 (diff) | |
| download | qpid-python-58f37a88b1cf6e6a3fa27d184238885a875cbb9f.tar.gz | |
Added mechanism to track connection ids for logging and debugging purposes. Changed format of log/debug messages for RequestManager and ResponseManager.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/qpid.0-9@499968 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/client')
3 files changed, 29 insertions, 11 deletions
diff --git a/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java b/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java index 4da086b3bd..bb3c33f2fe 100644 --- a/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java +++ b/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java @@ -78,7 +78,7 @@ import org.apache.qpid.url.URLSyntaxException; public class AMQConnection extends Closeable implements Connection, QueueConnection, TopicConnection, Referenceable { private static final Logger _logger = Logger.getLogger(AMQConnection.class); - + private AtomicInteger _idFactory = new AtomicInteger(0); /** @@ -155,6 +155,10 @@ public class AMQConnection extends Closeable implements Connection, QueueConnect private AMQException _lastAMQException = null; + // Keeps a tally of connections for logging and debugging + private static AtomicInteger _ConnectionId; + static { _ConnectionId = new AtomicInteger(0); } + /* * The connection meta data */ @@ -200,7 +204,7 @@ public class AMQConnection extends Closeable implements Connection, QueueConnect public AMQConnection(ConnectionURL connectionURL) throws AMQException { _logger.info("Connection:" + connectionURL); - + _ConnectionId.incrementAndGet(); if (connectionURL == null) { throw new IllegalArgumentException("Connection must be specified"); @@ -1020,4 +1024,9 @@ public class AMQConnection extends Closeable implements Connection, QueueConnect AMQConnectionFactory.class.getName(), null); // factory location } + + public int getConnectionId() + { + return _ConnectionId.get(); + } } diff --git a/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java b/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java index edef6c57c2..4d15c3cb35 100644 --- a/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java +++ b/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java @@ -576,4 +576,9 @@ public class AMQProtocolHandler extends IoHandlerAdapter { _failoverState = failoverState; } + + public int getConnectionId() + { + return _connection.getConnectionId(); + } } diff --git a/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolSession.java b/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolSession.java index 2980a86374..de5cd4821d 100644 --- a/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolSession.java +++ b/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolSession.java @@ -106,6 +106,8 @@ public class AMQProtocolSession implements AMQProtocolWriter, ProtocolVersionLis */ protected int _queueId = 1; protected final Object _queueIdLock = new Object(); + + protected int _ConnectionId; /** * No-arg constructor for use by test subclass - has to initialise final vars @@ -118,8 +120,9 @@ public class AMQProtocolSession implements AMQProtocolWriter, ProtocolVersionLis _stateManager = new AMQStateManager(this); // Add channel 0 request and response managers, since they will not be added through the usual mechanism - _channelId2RequestMgrMap.put(0, new RequestManager(0, this, false)); - _channelId2ResponseMgrMap.put(0, new ResponseManager(0, _stateManager, this, false)); + _ConnectionId = 0; + _channelId2RequestMgrMap.put(0, new RequestManager(_ConnectionId, 0, this, false)); + _channelId2ResponseMgrMap.put(0, new ResponseManager(_ConnectionId, 0, _stateManager, this, false)); } public AMQProtocolSession(AMQProtocolHandler protocolHandler, IoSession protocolSession, AMQConnection connection) @@ -131,8 +134,9 @@ public class AMQProtocolSession implements AMQProtocolWriter, ProtocolVersionLis _stateManager = new AMQStateManager(this); // Add channel 0 request and response managers, since they will not be added through the usual mechanism - _channelId2RequestMgrMap.put(0, new RequestManager(0, this, false)); - _channelId2ResponseMgrMap.put(0, new ResponseManager(0, _stateManager, this, false)); + _ConnectionId = _protocolHandler == null ? 0 : _protocolHandler.getConnectionId(); + _channelId2RequestMgrMap.put(0, new RequestManager(_ConnectionId, 0, this, false)); + _channelId2ResponseMgrMap.put(0, new ResponseManager(_ConnectionId, 0, _stateManager, this, false)); } public AMQProtocolSession(AMQProtocolHandler protocolHandler, IoSession protocolSession, AMQConnection connection, AMQStateManager stateManager) @@ -146,8 +150,9 @@ public class AMQProtocolSession implements AMQProtocolWriter, ProtocolVersionLis _stateManager.setProtocolSession(this); // Add channel 0 request and response managers, since they will not be added through the usual mechanism - _channelId2RequestMgrMap.put(0, new RequestManager(0, this, false)); - _channelId2ResponseMgrMap.put(0, new ResponseManager(0, _stateManager, this, false)); + _ConnectionId = _protocolHandler == null ? 0 : _protocolHandler.getConnectionId(); + _channelId2RequestMgrMap.put(0, new RequestManager(_ConnectionId, 0, this, false)); + _channelId2ResponseMgrMap.put(0, new ResponseManager(_ConnectionId, 0, _stateManager, this, false)); } public void init() @@ -379,12 +384,11 @@ public class AMQProtocolSession implements AMQProtocolWriter, ProtocolVersionLis // Add request and response handlers, one per channel, if they do not already exist if (_channelId2RequestMgrMap.get(channelId) == null) { - _channelId2RequestMgrMap.put(channelId, new RequestManager(channelId, this, false)); + _channelId2RequestMgrMap.put(channelId, new RequestManager(_ConnectionId, channelId, this, false)); } if (_channelId2ResponseMgrMap.get(channelId) == null) { - - _channelId2ResponseMgrMap.put(channelId, new ResponseManager(channelId, _stateManager, this, false)); + _channelId2ResponseMgrMap.put(channelId, new ResponseManager(_ConnectionId, channelId, _stateManager, this, false)); } } |
