add to the receive timeout exception the request id that it timed out on

This commit is contained in:
kimchy 2010-12-10 12:40:39 +02:00
parent 2a7f964ca2
commit bc2dc9465a
3 changed files with 16 additions and 3 deletions

View File

@ -37,7 +37,13 @@ public class ActionTransportException extends TransportException {
} }
public ActionTransportException(String name, TransportAddress address, String action, Throwable cause) { public ActionTransportException(String name, TransportAddress address, String action, Throwable cause) {
super(buildMessage(name, address, action), cause); super(buildMessage(name, address, action, null), cause);
this.address = address;
this.action = action;
}
public ActionTransportException(String name, TransportAddress address, String action, String msg, Throwable cause) {
super(buildMessage(name, address, action, msg), cause);
this.address = address; this.address = address;
this.action = action; this.action = action;
} }
@ -56,7 +62,7 @@ public class ActionTransportException extends TransportException {
return action; return action;
} }
private static String buildMessage(String name, TransportAddress address, String action) { private static String buildMessage(String name, TransportAddress address, String action, String msg) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (name != null) { if (name != null) {
sb.append('[').append(name).append(']'); sb.append('[').append(name).append(']');
@ -67,6 +73,9 @@ public class ActionTransportException extends TransportException {
if (action != null) { if (action != null) {
sb.append('[').append(action).append(']'); sb.append('[').append(action).append(']');
} }
if (msg != null) {
sb.append(" ").append(msg);
}
return sb.toString(); return sb.toString();
} }
} }

View File

@ -30,6 +30,10 @@ public class ReceiveTimeoutTransportException extends ActionTransportException {
super(node.name(), node.address(), action, null); super(node.name(), node.address(), action, null);
} }
public ReceiveTimeoutTransportException(DiscoveryNode node, String action, String msg) {
super(node.name(), node.address(), action, msg, null);
}
// @Override public Throwable fillInStackTrace() { // @Override public Throwable fillInStackTrace() {
// return fillStack(); // return fillStack();
// } // }

View File

@ -313,7 +313,7 @@ public class TransportService extends AbstractLifecycleComponent<TransportServic
if (holder != null) { if (holder != null) {
// add it to the timeout information holder, in case we are going to get a response later // add it to the timeout information holder, in case we are going to get a response later
timeoutInfoHandlers.put(requestId, new TimeoutInfoHolder(holder.node(), holder.action())); timeoutInfoHandlers.put(requestId, new TimeoutInfoHolder(holder.node(), holder.action()));
holder.handler().handleException(new ReceiveTimeoutTransportException(holder.node(), holder.action())); holder.handler().handleException(new ReceiveTimeoutTransportException(holder.node(), holder.action(), "request_id [" + requestId + "]"));
} }
} }
} }