Author: david.lloyd(a)jboss.com
Date: 2010-02-27 18:20:58 -0500 (Sat, 27 Feb 2010)
New Revision: 5765
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundRequest.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundRequestInputHandler.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundClient.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundReplyBufferWriter.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundRequest.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundRequestBufferWriter.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteConnectionHandler.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteMessageHandler.java
Log:
Improve trace logging
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundRequest.java
===================================================================
---
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundRequest.java 2010-02-27
21:48:46 UTC (rev 5764)
+++
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundRequest.java 2010-02-27
23:20:58 UTC (rev 5765)
@@ -34,11 +34,13 @@
private OutboundReplyHandler replyHandler;
private final NioByteInput byteInput;
private final RemoteConnectionHandler remoteConnectionHandler;
+ private final int rid;
private State state = State.RECEIVING;
InboundRequest(final RemoteConnectionHandler remoteConnectionHandler, final int rid)
{
this.remoteConnectionHandler = remoteConnectionHandler;
byteInput = new NioByteInput(new InboundRequestInputHandler(this, rid));
+ this.rid = rid;
}
void ack() {
@@ -79,4 +81,8 @@
RemoteConnectionHandler getRemoteConnectionHandler() {
return remoteConnectionHandler;
}
+
+ public String toString() {
+ return "Inbound request ID " + rid;
+ }
}
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundRequestInputHandler.java
===================================================================
---
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundRequestInputHandler.java 2010-02-27
21:48:46 UTC (rev 5764)
+++
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundRequestInputHandler.java 2010-02-27
23:20:58 UTC (rev 5765)
@@ -47,6 +47,8 @@
buffer.flip();
connectionHandler.sendBlocking(buffer);
connectionHandler.flushBlocking();
+ } catch (IOException e) {
+ RemoteConnectionHandler.log.trace(e, "Failed to acknowledge chunk for
%s", this);
} finally {
bufferPool.free(buffer);
}
@@ -55,4 +57,8 @@
public void close() throws IOException {
// todo: stream was closed, no action needed
}
+
+ public String toString() {
+ return "Inbound request input handler for request ID " + rid;
+ }
}
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundClient.java
===================================================================
---
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundClient.java 2010-02-27
21:48:46 UTC (rev 5764)
+++
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundClient.java 2010-02-27
23:20:58 UTC (rev 5765)
@@ -36,6 +36,7 @@
private final String serviceType;
private final String groupName;
private RemoteConnectionHandler remoteConnectionHandler;
+ private RequestHandler requestHandler;
OutboundClient(final RemoteConnectionHandler remoteConnectionHandler, final int id,
final Result<RequestHandler> result, final String serviceType, final String
groupName) {
this.remoteConnectionHandler = remoteConnectionHandler;
@@ -88,6 +89,15 @@
return id;
}
+ RequestHandler getRequestHandler() {
+ return requestHandler;
+ }
+
+ void setResult(final RequestHandler requestHandler) {
+ result.setResult(requestHandler);
+ this.requestHandler = requestHandler;
+ }
+
enum State {
REPLY_WAIT,
ESTABLISHED,
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundReplyBufferWriter.java
===================================================================
---
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundReplyBufferWriter.java 2010-02-27
21:48:46 UTC (rev 5764)
+++
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundReplyBufferWriter.java 2010-02-27
23:20:58 UTC (rev 5765)
@@ -46,6 +46,7 @@
final RemoteConnectionHandler connectionHandler =
inboundRequest.getRemoteConnectionHandler();
final Pool<ByteBuffer> bufferPool = connectionHandler.getBufferPool();
final ByteBuffer buffer = bufferPool.allocate();
+ RemoteConnectionHandler.log.trace("Allocated buffer %s for %s", buffer,
this);
buffer.putInt(RemoteConnectionHandler.LENGTH_PLACEHOLDER);
buffer.put(exception ? RemoteProtocol.REPLY_EXCEPTION : RemoteProtocol.REPLY);
buffer.putInt(id);
@@ -55,6 +56,7 @@
} else {
buffer.put((byte)0);
}
+ RemoteConnectionHandler.log.trace("Prepopulated buffer %s for %s",
buffer, this);
return buffer;
}
@@ -70,6 +72,7 @@
if (eof) {
buffer.put(7, (byte) (buffer.get(3) | RemoteProtocol.MSG_FLAG_LAST));
}
+ RemoteConnectionHandler.log.trace("Sending buffer %s for %s",
buffer, this);
connectionHandler.sendBlocking(buffer);
} finally {
connectionHandler.getBufferPool().free(buffer);
@@ -79,4 +82,8 @@
public void flush() throws IOException {
inboundRequest.getRemoteConnectionHandler().flushBlocking();
}
+
+ public String toString() {
+ return "Outbound reply buffer writer for " + inboundRequest;
+ }
}
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundRequest.java
===================================================================
---
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundRequest.java 2010-02-27
21:48:46 UTC (rev 5764)
+++
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundRequest.java 2010-02-27
23:20:58 UTC (rev 5765)
@@ -108,4 +108,8 @@
ReplyHandler getInboundReplyHandler() {
return inboundReplyHandler;
}
+
+ public String toString() {
+ return "Outbound Request for client ID " + cid;
+ }
}
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundRequestBufferWriter.java
===================================================================
---
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundRequestBufferWriter.java 2010-02-27
21:48:46 UTC (rev 5764)
+++
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundRequestBufferWriter.java 2010-02-27
23:20:58 UTC (rev 5765)
@@ -41,6 +41,7 @@
public ByteBuffer getBuffer() {
final ByteBuffer buffer =
outboundRequest.getRemoteConnectionHandler().getBufferPool().allocate();
+ RemoteConnectionHandler.log.trace("Allocated buffer %s for %s", buffer,
this);
buffer.putInt(RemoteConnectionHandler.LENGTH_PLACEHOLDER);
buffer.put(RemoteProtocol.REQUEST);
buffer.putInt(rid);
@@ -51,7 +52,7 @@
} else {
buffer.put((byte)0);
}
- RemoteConnectionHandler.log.trace("Allocated buffer %s for %s", buffer,
this);
+ RemoteConnectionHandler.log.trace("Prepopulated buffer %s for %s",
buffer, this);
return buffer;
}
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteConnectionHandler.java
===================================================================
---
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteConnectionHandler.java 2010-02-27
21:48:46 UTC (rev 5764)
+++
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteConnectionHandler.java 2010-02-27
23:20:58 UTC (rev 5765)
@@ -167,7 +167,7 @@
for (IntKeyMap.Entry<OutboundClient> entry : outboundClients) {
final OutboundClient outboundClient = entry.getValue();
synchronized (outboundClient) {
- // todo close the request handler
+ IoUtils.safeClose(outboundClient.getRequestHandler());
}
}
for (IntKeyMap.Entry<InboundClient> entry : inboundClients) {
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteMessageHandler.java
===================================================================
---
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteMessageHandler.java 2010-02-27
21:48:46 UTC (rev 5764)
+++
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteMessageHandler.java 2010-02-27
23:20:58 UTC (rev 5765)
@@ -118,7 +118,7 @@
synchronized (client) {
// todo assert client state == waiting
client.setState(OutboundClient.State.ESTABLISHED);
- client.getResult().setResult(new OutboundRequestHandler(client));
+ client.setResult(new OutboundRequestHandler(client));
}
return;
}
@@ -150,13 +150,15 @@
synchronized (inboundRequests) {
if ((flags & RemoteProtocol.MSG_FLAG_FIRST) != 0) {
cid = buffer.getInt();
- inboundRequest = new InboundRequest(connectionHandler, 0);
+ inboundRequest = new InboundRequest(connectionHandler, rid);
start = true;
// todo - check for duplicate
inboundRequests.put(rid, inboundRequest);
+ RemoteConnectionHandler.log.trace("Received first request
message %s for %s", buffer, inboundRequest);
} else {
cid = 0;
inboundRequest = inboundRequests.get(rid);
+ RemoteConnectionHandler.log.trace("Received subsequent
request message %s for %s", buffer, inboundRequest);
}
if (inboundRequest == null) {
RemoteConnectionHandler.log.trace("Received request for
unknown request ID %d", Integer.valueOf(rid));
@@ -220,10 +222,12 @@
}
synchronized (outboundRequest) {
if ((flags & RemoteProtocol.MSG_FLAG_FIRST) != 0) {
+ RemoteConnectionHandler.log.trace("Received first reply
message %s for %s", buffer, outboundRequest);
// todo - check for duplicate
outboundRequest.setByteInput(byteInput = new NioByteInput(new
InboundReplyInputHandler(outboundRequest, rid)));
connectionHandler.getConnectionContext().getConnectionProviderContext().getExecutor().execute(new
InboundReplyTask(connectionHandler, outboundRequest));
} else {
+ RemoteConnectionHandler.log.trace("Received subsequent reply
message %s for %s", buffer, outboundRequest);
byteInput = outboundRequest.getByteInput();
}
}