feat(sj_1.0.0): 优化剔除下线机器死锁问题
This commit is contained in:
parent
514c6fcd13
commit
1ec5a6e1d1
@ -73,7 +73,7 @@ CREATE TABLE `sj_notify_recipient`
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`namespace_id` varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' COMMENT '命名空间id',
|
||||
`recipient_name` varchar(64) NOT NULL COMMENT '接收人名称',
|
||||
`notify_type` tinyint(4) NOT NULL DEFAULT 0 COMMENT '通知类型 1、钉钉 2、邮件 3、企业微信 4 飞书',
|
||||
`notify_type` tinyint(4) NOT NULL DEFAULT 0 COMMENT '通知类型 1、钉钉 2、邮件 3、企业微信 4 飞书 5 webhook',
|
||||
`notify_attribute` varchar(512) NOT NULL COMMENT '配置属性',
|
||||
`description` varchar(256) NOT NULL DEFAULT '' COMMENT '描述',
|
||||
`create_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
|
@ -18,6 +18,7 @@ import org.springframework.util.CollectionUtils;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -42,8 +43,13 @@ public class OfflineNodeSchedule extends AbstractSchedule implements Lifecycle {
|
||||
LocalDateTime endTime = LocalDateTime.now().minusSeconds(
|
||||
ServerRegister.DELAY_TIME + (ServerRegister.DELAY_TIME / 3));
|
||||
|
||||
List<ServerNode> serverNodes = serverNodeMapper.selectList(
|
||||
new LambdaQueryWrapper<ServerNode>().select(ServerNode::getId)
|
||||
.le(ServerNode::getExpireAt, endTime));
|
||||
if (!CollectionUtils.isEmpty(serverNodes)) {
|
||||
// 先删除DB中需要下线的机器
|
||||
serverNodeMapper.delete(new LambdaQueryWrapper<ServerNode>().le(ServerNode::getExpireAt, endTime));
|
||||
serverNodeMapper.deleteBatchIds(serverNodes.stream().map(ServerNode::getId).collect(Collectors.toSet()));
|
||||
}
|
||||
|
||||
Set<RegisterNodeInfo> allPods = CacheRegisterTable.getAllPods();
|
||||
Set<RegisterNodeInfo> waitOffline = allPods.stream().filter(registerNodeInfo -> registerNodeInfo.getExpireAt().isBefore(endTime)).collect(
|
||||
|
Loading…
Reference in New Issue
Block a user