Search in sources :

Example 1 with CodecEmbedderException

use of org.jboss.netty.handler.codec.embedder.CodecEmbedderException in project opentsdb by OpenTSDB.

the class ConnectionManager method exceptionCaught.

@Override
public void exceptionCaught(final ChannelHandlerContext ctx, final ExceptionEvent e) {
    final Throwable cause = e.getCause();
    final Channel chan = ctx.getChannel();
    if (cause instanceof ClosedChannelException) {
        exceptions_closed.incrementAndGet();
        LOG.warn("Attempt to write to closed channel " + chan);
        return;
    }
    if (cause instanceof IOException) {
        final String message = cause.getMessage();
        if ("Connection reset by peer".equals(message)) {
            exceptions_reset.incrementAndGet();
            return;
        } else if ("Connection timed out".equals(message)) {
            exceptions_timeout.incrementAndGet();
            // and Java managed to do something *far* worse.  That's quite a feat.
            return;
        } else if (cause instanceof ConnectionRefusedException) {
            connections_rejected.incrementAndGet();
            if (LOG.isDebugEnabled()) {
                LOG.debug("Refusing connection from " + chan, e.getCause());
            }
            chan.close();
            return;
        }
    }
    if (cause instanceof CodecEmbedderException) {
        // payload was not compressed as it was announced to be
        LOG.warn("Http codec error : " + cause.getMessage());
        e.getChannel().close();
        return;
    }
    exceptions_unknown.incrementAndGet();
    LOG.error("Unexpected exception from downstream for " + chan, cause);
    e.getChannel().close();
}
Also used : ClosedChannelException(java.nio.channels.ClosedChannelException) CodecEmbedderException(org.jboss.netty.handler.codec.embedder.CodecEmbedderException) Channel(org.jboss.netty.channel.Channel) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 ClosedChannelException (java.nio.channels.ClosedChannelException)1 Channel (org.jboss.netty.channel.Channel)1 CodecEmbedderException (org.jboss.netty.handler.codec.embedder.CodecEmbedderException)1