force close connection if its on a connect failure

relates to Repeated ConnectExceptions in logs until node is restarted, fixes #2766
This commit is contained in:
Shay Banon 2013-03-12 14:49:07 -07:00
parent 877105ee19
commit 55ceb01c44
1 changed files with 11 additions and 7 deletions

View File

@ -485,16 +485,20 @@ public class NettyTransport extends AbstractLifecycleComponent<Transport> implem
// ignore // ignore
} }
if (isCloseConnectionException(e.getCause())) { if (isCloseConnectionException(e.getCause())) {
if (logger.isTraceEnabled()) {
logger.trace("close connection exception caught on transport layer [{}], disconnecting from relevant node", e.getCause(), ctx.getChannel()); logger.trace("close connection exception caught on transport layer [{}], disconnecting from relevant node", e.getCause(), ctx.getChannel());
}
// close the channel, which will cause a node to be disconnected if relevant // close the channel, which will cause a node to be disconnected if relevant
ctx.getChannel().close(); ctx.getChannel().close();
disconnectFromNodeChannel(ctx.getChannel(), e.getCause()); disconnectFromNodeChannel(ctx.getChannel(), e.getCause());
} else if (isConnectException(e.getCause()) || e.getCause() instanceof CancelledKeyException) { } else if (isConnectException(e.getCause())) {
if (logger.isTraceEnabled()) { logger.trace("connect exception caught on transport layer [{}]", e.getCause(), ctx.getChannel());
logger.trace("(ignoring) exception caught on transport layer [{}]", e.getCause(), ctx.getChannel()); // close the channel as safe measure, which will cause a node to be disconnected if relevant
} ctx.getChannel().close();
disconnectFromNodeChannel(ctx.getChannel(), e.getCause());
} else if (e.getCause() instanceof CancelledKeyException) {
logger.trace("cancelled key exception caught on transport layer [{}], disconnecting from relevant node", e.getCause(), ctx.getChannel());
// close the channel as safe measure, which will cause a node to be disconnected if relevant
ctx.getChannel().close();
disconnectFromNodeChannel(ctx.getChannel(), e.getCause());
} else { } else {
logger.warn("exception caught on transport layer [{}], closing connection", e.getCause(), ctx.getChannel()); logger.warn("exception caught on transport layer [{}], closing connection", e.getCause(), ctx.getChannel());
// close the channel, which will cause a node to be disconnected if relevant // close the channel, which will cause a node to be disconnected if relevant