Jonathan Hart

Add descriptive message for MessagingExceptions.

We can print this message in EventuallyConsistentMapImpl rather than printing
a stack trace which doesn't add any value because the exception always comes
from the same place.

Change-Id: Ia233e7ae8605b2b59ffd4ef834209fdaa86e9376
......@@ -42,17 +42,26 @@ public class MessagingException extends IOException {
* Exception indicating no remote registered remote handler.
*/
public static class NoRemoteHandler extends MessagingException {
public NoRemoteHandler() {
super("No remote message handler registered for this message");
}
}
/**
* Exception indicating handler failure.
*/
public static class RemoteHandlerFailure extends MessagingException {
public RemoteHandlerFailure() {
super("Remote handler failed to handle message");
}
}
/**
* Exception indicating failure due to invalid message strucuture such as an incorrect preamble.
* Exception indicating failure due to invalid message structure such as an incorrect preamble.
*/
public static class ProcotolException extends MessagingException {
public static class ProtocolException extends MessagingException {
public ProtocolException() {
super("Failed to process message due to invalid message structure");
}
}
}
......
......@@ -545,7 +545,7 @@ public class NettyMessagingManager implements MessagingService {
} else if (message.status() == Status.ERROR_HANDLER_EXCEPTION) {
callback.completeExceptionally(new MessagingException.RemoteHandlerFailure());
} else if (message.status() == Status.PROTOCOL_EXCEPTION) {
callback.completeExceptionally(new MessagingException.ProcotolException());
callback.completeExceptionally(new MessagingException.ProtocolException());
}
} else {
log.debug("Received a reply for message id:[{}]. "
......
......@@ -588,7 +588,8 @@ public class EventuallyConsistentMapImpl<K, V>
peer)
.whenComplete((result, error) -> {
if (error != null) {
log.debug("Failed to send anti-entropy advertisement to {}", peer, error);
log.debug("Failed to send anti-entropy advertisement to {}: {}",
peer, error.getMessage());
} else if (result == AntiEntropyResponse.PROCESSED) {
antiEntropyTimes.put(peer, adCreationTime);
}
......@@ -603,7 +604,8 @@ public class EventuallyConsistentMapImpl<K, V>
peer)
.whenComplete((result, error) -> {
if (error != null) {
log.debug("Failed to send update request to {}", peer, error);
log.debug("Failed to send update request to {}: {}",
peer, error.getMessage());
}
});
}
......