只有发送过离线通知的节点才会发送恢复在线通知

This commit is contained in:
GoEdgeLab
2022-08-07 17:28:54 +08:00
parent 2aa93e826d
commit d00061d3c4
4 changed files with 66 additions and 20 deletions

View File

@@ -1668,10 +1668,31 @@ func (this *NodeDAO) UpdateNodeActive(tx *dbs.Tx, nodeId int64, isActive bool) e
_, err := this.Query(tx).
Pk(nodeId).
Set("isActive", isActive).
Set("inactiveNotifiedAt", 0).
Update()
return err
}
// UpdateNodeInactiveNotifiedAt 修改节点的离线通知时间
func (this *NodeDAO) UpdateNodeInactiveNotifiedAt(tx *dbs.Tx, nodeId int64, inactiveAt int64) error {
if nodeId <= 0 {
return errors.New("invalid nodeId")
}
_, err := this.Query(tx).
Pk(nodeId).
Set("inactiveNotifiedAt", inactiveAt).
Update()
return err
}
// FindNodeInactiveNotifiedAt 读取上次的节点离线通知时间
func (this *NodeDAO) FindNodeInactiveNotifiedAt(tx *dbs.Tx, nodeId int64) (int64, error) {
return this.Query(tx).
Pk(nodeId).
Result("inactiveNotifiedAt").
FindInt64Col(0)
}
// FindNodeActive 检查节点活跃状态
func (this *NodeDAO) FindNodeActive(tx *dbs.Tx, nodeId int64) (bool, error) {
isActive, err := this.Query(tx).
@@ -1827,6 +1848,19 @@ func (this *NodeDAO) FindParentNodeConfigs(tx *dbs.Tx, nodeId int64, groupId int
if err != nil {
return nil, err
}
} else if nodeId > 0 {
// 当前节点所属分组
groupId, err = this.Query(tx).Result("groupId").FindInt64Col(0)
if err != nil {
return nil, err
}
if groupId > 0 {
parentNodes, err = this.FindEnabledNodesWithGroupIdAndLevel(tx, groupId, level+1)
if err != nil {
return nil, err
}
}
}
// 当前集群的L2