From 3a706d3378aa3626501370352963883fd2783558 Mon Sep 17 00:00:00 2001 From: zhangzengfei <zhangzengfei@smartai.com> Date: 星期二, 28 十一月 2023 11:24:49 +0800 Subject: [PATCH] 添加appcenter,完善算法上传下载功能 --- system-service/service/clusterService.go | 28 +++++++++++++++++++++++++++- 1 files changed, 27 insertions(+), 1 deletions(-) diff --git a/system-service/service/clusterService.go b/system-service/service/clusterService.go index feffd61..a39741f 100644 --- a/system-service/service/clusterService.go +++ b/system-service/service/clusterService.go @@ -138,6 +138,31 @@ return false, "" } +// 鏍规嵁闆嗙兢鍚嶇О鍜屽瘑鐮佸垱寤洪泦缇� +func (s ClusterService) UpdateDriftStateByNodeId(clusterId, nodeId, role string) (bool, string) { + var node models.Node + isSuccess := node.UpdateDriftStateByNodeId(role, nodeId, false) + + if isSuccess { + // 閫氱煡涓昏妭鐐瑰彉鏇� + chMsg := protomsg.DbChangeMessage{ + Id: clusterId, + Table: protomsg.TableChanged_T_Cluster, + Action: protomsg.DbAction_Insert, + Info: "slave2master", + } + + s.AddDbMessage(&chMsg) + + err := serf.Agent.UserEvent(serf.UserEventChangeMaster, []byte(nodeId), false) + if err != nil { + logger.Error("UserEventSyncVirtualIp err:", err) + } + } + + return isSuccess, "" +} + func (s ClusterService) SearchByPwd(pwd string) (err error) { _, isSearching := getFromSearchMap() if isSearching { @@ -444,7 +469,7 @@ return false } - joinSql := fmt.Sprintf("update cluster_node set isDelete=0,drift_state='',node_ip='%s',create_time='%s' where node_id='%s'", serverIp+":"+strconv.Itoa(dbSync.DefaultBindPort), fmtTimeStr, config.Server.AnalyServerId) + joinSql := fmt.Sprintf("update cluster_node set isDelete=0,drift_state='slave',node_ip='%s',create_time='%s' where node_id='%s'", serverIp+":"+strconv.Itoa(dbSync.DefaultBindPort), fmtTimeStr, config.Server.AnalyServerId) if err = tx.Exec(joinSql).Error; err != nil { logger.Debug("update isDelete err:", err) return false @@ -471,6 +496,7 @@ func ClusterSyncProcMessage(payload []byte) { if serf.Agent == nil { logger.Error("鏈姞鍏ラ泦缇�") + return } err := serf.Agent.UserEvent(serf.UserEventSyncMessage, payload, false) -- Gitblit v1.8.0