fix(flashgroupmanager): cluster info list all master nodes.

close#1000181329

Signed-off-by: baihailong <baihailong@oppo.com>
(cherry picked from commit 5074b878b1)
This commit is contained in:
baihailong 2025-06-17 11:08:00 +08:00 committed by chihe
parent 695d57db88
commit e95b3c523e
2 changed files with 15 additions and 0 deletions

View File

@ -55,12 +55,14 @@ func (m *FlashGroupManager) getCluster(w http.ResponseWriter, r *http.Request) {
Name: m.cluster.Name,
CreateTime: time.Unix(m.cluster.CreateTime, 0).Format(proto.TimeFormat),
LeaderAddr: m.leaderInfo.addr,
MasterNodes: make([]proto.NodeView, 0),
FlashNodes: make([]proto.NodeView, 0),
FlashNodeHandleReadTimeout: m.cluster.cfg.flashNodeHandleReadTimeout,
FlashNodeReadDataNodeTimeout: m.cluster.cfg.flashNodeReadDataNodeTimeout,
}
cv.DataNodeStatInfo = new(proto.NodeStatInfo)
cv.MetaNodeStatInfo = new(proto.NodeStatInfo)
cv.MasterNodes = m.cluster.allMasterNodes()
cv.FlashNodes = m.cluster.allFlashNodes()
sendOkReply(w, r, newSuccessHTTPReply(cv))
}
@ -686,6 +688,7 @@ func (m *FlashGroupManager) setNodeInfoHandler(w http.ResponseWriter, r *http.Re
}
}
}
sendOkReply(w, r, newSuccessHTTPReply(fmt.Sprintf("set nodeinfo params %v successfully", params)))
}
func (m *FlashGroupManager) setConfig(key string, value string) (err error) {

View File

@ -635,6 +635,18 @@ func (c *Cluster) masterAddr() (addr string) {
return c.leaderInfo.addr
}
func (c *Cluster) allMasterNodes() (masterNodes []proto.NodeView) {
masterNodes = make([]proto.NodeView, 0)
for _, addr := range c.cfg.peerAddrs {
split := strings.Split(addr, colonSplit)
id, _ := strconv.ParseUint(split[0], 10, 64)
masterNode := proto.NodeView{ID: id, Addr: split[1] + ":" + split[2], Status: true}
masterNodes = append(masterNodes, masterNode)
}
return masterNodes
}
func (c *Cluster) allFlashNodes() (flashNodes []proto.NodeView) {
flashNodes = make([]proto.NodeView, 0)
c.flashNodeTopo.flashNodeMap.Range(func(addr, node interface{}) bool {