mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
dump connection disconnected
dump connection will be disconnected since SocketChannel.cache is overflow.
This commit is contained in:
@@ -7,7 +7,7 @@ import io.netty.channel.AdaptiveRecvByteBufAllocator;
|
|||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import io.netty.channel.ChannelFuture;
|
import io.netty.channel.ChannelFuture;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
import io.netty.channel.SimpleChannelInboundHandler;
|
||||||
import io.netty.channel.ChannelInitializer;
|
import io.netty.channel.ChannelInitializer;
|
||||||
import io.netty.channel.ChannelOption;
|
import io.netty.channel.ChannelOption;
|
||||||
import io.netty.channel.EventLoopGroup;
|
import io.netty.channel.EventLoopGroup;
|
||||||
@@ -71,7 +71,7 @@ public abstract class SocketChannelPool {
|
|||||||
return socket;
|
return socket;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class BusinessHandler extends ChannelInboundHandlerAdapter {
|
public static class BusinessHandler extends SimpleChannelInboundHandler<ByteBuf> {
|
||||||
|
|
||||||
private SocketChannel socket = null;
|
private SocketChannel socket = null;
|
||||||
private final CountDownLatch latch = new CountDownLatch(1);
|
private final CountDownLatch latch = new CountDownLatch(1);
|
||||||
@@ -92,18 +92,19 @@ public abstract class SocketChannelPool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception {
|
||||||
if (socket != null) {
|
if (socket != null) {
|
||||||
socket.writeCache((ByteBuf) msg);
|
socket.writeCache(msg);
|
||||||
} else {
|
} else {
|
||||||
// TODO: need graceful error handler.
|
// TODO: need graceful error handler.
|
||||||
logger.error("no socket available.");
|
logger.error("no socket available.");
|
||||||
}
|
}
|
||||||
ReferenceCountUtil.release(msg);// 添加防止内存泄漏的
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
||||||
|
//need output error for troubeshooting.
|
||||||
|
logger.error("business error.", cause);
|
||||||
ctx.close();
|
ctx.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user