断开连接取消定时任务
This commit is contained in:
@@ -3,6 +3,7 @@ package com.tongran.agent.client.netty.handler;
|
|||||||
import com.tongran.agent.client.core.config.GlobalConfig;
|
import com.tongran.agent.client.core.config.GlobalConfig;
|
||||||
import com.tongran.agent.client.core.session.SessionManager;
|
import com.tongran.agent.client.core.session.SessionManager;
|
||||||
import com.tongran.agent.client.scheduler.service.AppInitializer;
|
import com.tongran.agent.client.scheduler.service.AppInitializer;
|
||||||
|
import com.tongran.agent.client.service.AgentService;
|
||||||
import com.tongran.agent.client.utils.AssertLog;
|
import com.tongran.agent.client.utils.AssertLog;
|
||||||
import io.netty.channel.ChannelHandler;
|
import io.netty.channel.ChannelHandler;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
@@ -26,6 +27,9 @@ public class TCPListenHandler extends ChannelInboundHandlerAdapter {
|
|||||||
|
|
||||||
private final SessionManager sessionManager;
|
private final SessionManager sessionManager;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AgentService agentService;
|
||||||
|
|
||||||
public TCPListenHandler() {
|
public TCPListenHandler() {
|
||||||
this.sessionManager = SessionManager.getInstance();
|
this.sessionManager = SessionManager.getInstance();
|
||||||
}
|
}
|
||||||
@@ -41,6 +45,7 @@ public class TCPListenHandler extends ChannelInboundHandlerAdapter {
|
|||||||
sessionManager.remove(ctx.channel());
|
sessionManager.remove(ctx.channel());
|
||||||
try {
|
try {
|
||||||
GlobalConfig.isCollect = false;
|
GlobalConfig.isCollect = false;
|
||||||
|
agentService.cancelCollect();
|
||||||
appInitializer.run();
|
appInitializer.run();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -51,6 +56,7 @@ public class TCPListenHandler extends ChannelInboundHandlerAdapter {
|
|||||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable e) {
|
public void exceptionCaught(ChannelHandlerContext ctx, Throwable e) {
|
||||||
if (e instanceof IOException) {
|
if (e instanceof IOException) {
|
||||||
AssertLog.info("<<<<<<[终端断开连接]{} {}", sessionManager.client(ctx), e.getMessage());
|
AssertLog.info("<<<<<<[终端断开连接]{} {}", sessionManager.client(ctx), e.getMessage());
|
||||||
|
agentService.cancelCollect();
|
||||||
} else {
|
} else {
|
||||||
AssertLog.info(">>>>>>[消息处理异常]" + sessionManager.client(ctx), e);
|
AssertLog.info(">>>>>>[消息处理异常]" + sessionManager.client(ctx), e);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user