upd: 日志统一

This commit is contained in:
骑着蜗牛追导弹 2024-12-06 21:57:21 +08:00
parent e187a378d5
commit 767c710e84
2 changed files with 10 additions and 7 deletions

View File

@ -29,17 +29,19 @@ public class ConfigClientHandler extends ChannelInboundHandlerAdapter {
@Override @Override
public void channelRegistered(ChannelHandlerContext ctx) throws Exception { public void channelRegistered(ChannelHandlerContext ctx) throws Exception {
logger.info("当Channel已经注册到它的EventLoop并且能够处理I/O时被调用"); /// logger.info("当Channel已经注册到它的EventLoop并且能够处理I/O时被调用");
super.channelRegistered(ctx);
} }
@Override @Override
public void channelUnregistered(ChannelHandlerContext ctx) throws Exception { public void channelUnregistered(ChannelHandlerContext ctx) throws Exception {
logger.info("当Channel从它的EventLoop注销并且无法处理任何I/O时被调用"); /// logger.info("当Channel从它的EventLoop注销并且无法处理任何I/O时被调用");
super.channelUnregistered(ctx);
} }
@Override @Override
public void channelActive(ChannelHandlerContext ctx) throws Exception { public void channelActive(ChannelHandlerContext ctx) throws Exception {
logger.info("当Channel处于活动状态已经连接到它的远程节点时被调用, 注册客户端"); /// logger.info("当Channel处于活动状态已经连接到它的远程节点时被调用, 注册客户端");
SmallMessage smallMessage = new SmallMessage(); SmallMessage smallMessage = new SmallMessage();
smallMessage.setType(TransferMessageType.REGISTER); smallMessage.setType(TransferMessageType.REGISTER);
smallMessage.setResp(SmallMessage.Response.ok(ClientConfigLoader.clientInfo)); smallMessage.setResp(SmallMessage.Response.ok(ClientConfigLoader.clientInfo));
@ -48,8 +50,9 @@ public class ConfigClientHandler extends ChannelInboundHandlerAdapter {
@Override @Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception { public void channelInactive(ChannelHandlerContext ctx) throws Exception {
logger.info("当Channel离开活动状态并且不再连接到它的远程节点时被调用"); /// logger.info("当Channel离开活动状态并且不再连接到它的远程节点时被调用");
/// this.configClient.reConnect(); /// this.configClient.reConnect();
super.channelInactive(ctx);
} }
@Override @Override

View File

@ -109,7 +109,7 @@ public class ConfigServerHandler extends ChannelInboundHandlerAdapter {
@Override @Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
log.error("Channel发生异常被调用", cause); log.error("Channel发生异常", cause);
/// cause.printStackTrace(); /// cause.printStackTrace();
ConfigClientManage.unregister(ctx.channel().id()); ConfigClientManage.unregister(ctx.channel().id());
ctx.close(); ctx.close();
@ -117,13 +117,13 @@ public class ConfigServerHandler extends ChannelInboundHandlerAdapter {
@Override @Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception { public void channelInactive(ChannelHandlerContext ctx) throws Exception {
log.info("当Channel处于非活动状态已经连接到它的远程节点时被调用"); /// log.info("当Channel处于非活动状态已经连接到它的远程节点时被调用");
ConfigClientManage.unregister(ctx.channel().id()); ConfigClientManage.unregister(ctx.channel().id());
} }
@Override @Override
public void channelUnregistered(ChannelHandlerContext ctx) throws Exception { public void channelUnregistered(ChannelHandlerContext ctx) throws Exception {
log.info("当Channel从它的EventLoop注销并且不能够处理I/O时被调用"); /// log.info("当Channel从它的EventLoop注销并且不能够处理I/O时被调用");
ConfigClientManage.unregister(ctx.channel().id()); ConfigClientManage.unregister(ctx.channel().id());
} }
} }