Browse Source

refactor

pull/4605/head
chrislu 2 years ago
parent
commit
a82c44972b
  1. 4
      weed/cluster/cluster.go
  2. 6
      weed/cluster/group_members.go

4
weed/cluster/cluster.go

@ -44,9 +44,7 @@ func newClusterNodeGroups() *ClusterNodeGroups {
func (g *ClusterNodeGroups) getGroupMembers(filerGroup FilerGroupName, createIfNotFound bool) *GroupMembers { func (g *ClusterNodeGroups) getGroupMembers(filerGroup FilerGroupName, createIfNotFound bool) *GroupMembers {
members, found := g.groupMembers[filerGroup] members, found := g.groupMembers[filerGroup]
if !found && createIfNotFound { if !found && createIfNotFound {
members = &GroupMembers{
members: make(map[pb.ServerAddress]*ClusterNode),
}
members = newGroupMembers()
g.groupMembers[filerGroup] = members g.groupMembers[filerGroup] = members
} }
return members return members

6
weed/cluster/group_members.go

@ -9,6 +9,12 @@ type GroupMembers struct {
members map[pb.ServerAddress]*ClusterNode members map[pb.ServerAddress]*ClusterNode
} }
func newGroupMembers() *GroupMembers {
return &GroupMembers{
members: make(map[pb.ServerAddress]*ClusterNode),
}
}
func (m *GroupMembers) addMember(dataCenter DataCenter, rack Rack, address pb.ServerAddress, version string) *ClusterNode { func (m *GroupMembers) addMember(dataCenter DataCenter, rack Rack, address pb.ServerAddress, version string) *ClusterNode {
if existingNode, found := m.members[address]; found { if existingNode, found := m.members[address]; found {
existingNode.counter++ existingNode.counter++

Loading…
Cancel
Save