| | |
| | | import com.ard.work.component.netty.handler.MessageProtocolEncoder; |
| | | import com.ard.work.domain.cache.TyTcpServerCache; |
| | | import com.ard.work.domain.entity.ArdServerInfo; |
| | | import com.ard.work.service.IArdServerService; |
| | | import com.ard.work.service.IArdServerInfoService; |
| | | import io.netty.bootstrap.Bootstrap; |
| | | import io.netty.channel.*; |
| | | import io.netty.channel.nio.NioEventLoopGroup; |
| | |
| | | private final EventLoopGroup eventLoopGroup = new NioEventLoopGroup(); |
| | | |
| | | @Resource |
| | | private IArdServerService ardServerService; // ← 从数据库读取边缘服务器配置 |
| | | private IArdServerInfoService ardServerService; // ← 从数据库读取边缘服务器配置 |
| | | |
| | | @Resource |
| | | private ClientHandler clientHandler; |
| | |
| | | @PostConstruct |
| | | public void initConnectServers() { |
| | | try { |
| | | var serverList = ardServerService.selectArdServerManagementList(new ArdServerInfo()); // ← 从数据库查询所有服务器配置 |
| | | var serverList = ardServerService.selectArdServerInfoList(new ArdServerInfo()); // ← 从数据库查询所有服务器配置 |
| | | if (serverList == null || serverList.isEmpty()) { |
| | | log.warn("未在数据库中找到边缘服务器配置,跳过连接初始化"); |
| | | return; |
| | |
| | | public void reconnectFailedServers() { |
| | | TyTcpServerCache.getTcpServerCacheMap().forEach((key, state) -> { |
| | | if (Boolean.FALSE.equals(state)) { // 连接失败的服务器 |
| | | ArdServerInfo serverInfo = ardServerService.selectArdServerManagementById(key); |
| | | ArdServerInfo serverInfo = ardServerService.selectArdServerInfoById(key); |
| | | if (serverInfo != null) { |
| | | connectServer(serverInfo); |
| | | } |