|
@ -89,6 +89,7 @@ func pickBrokersExcluded(brokers []string, count int, excludedLeadBroker string, |
|
|
return pickedBrokers |
|
|
return pickedBrokers |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// EnsureAssignmentsToActiveBrokers ensures the assignments are assigned to active brokers
|
|
|
func EnsureAssignmentsToActiveBrokers(activeBrokers cmap.ConcurrentMap[string, *BrokerStats], followerCount int, assignments []*mq_pb.BrokerPartitionAssignment) (hasChanges bool) { |
|
|
func EnsureAssignmentsToActiveBrokers(activeBrokers cmap.ConcurrentMap[string, *BrokerStats], followerCount int, assignments []*mq_pb.BrokerPartitionAssignment) (hasChanges bool) { |
|
|
candidates := make([]string, 0, activeBrokers.Count()) |
|
|
candidates := make([]string, 0, activeBrokers.Count()) |
|
|
for brokerStatsItem := range activeBrokers.IterBuffered() { |
|
|
for brokerStatsItem := range activeBrokers.IterBuffered() { |
|
@ -123,20 +124,22 @@ func EnsureAssignmentsToActiveBrokers(activeBrokers cmap.ConcurrentMap[string, * |
|
|
if assignment.LeaderBroker == "" { |
|
|
if assignment.LeaderBroker == "" { |
|
|
assignment.LeaderBroker = pickedBrokers[i] |
|
|
assignment.LeaderBroker = pickedBrokers[i] |
|
|
i++ |
|
|
i++ |
|
|
|
|
|
hasChanges = true |
|
|
} |
|
|
} |
|
|
j := 0 |
|
|
j := 0 |
|
|
for ; j<len(assignment.FollowerBrokers); j++ { |
|
|
for ; j<len(assignment.FollowerBrokers); j++ { |
|
|
if assignment.FollowerBrokers[j] == "" { |
|
|
if assignment.FollowerBrokers[j] == "" { |
|
|
assignment.FollowerBrokers[j] = pickedBrokers[i] |
|
|
assignment.FollowerBrokers[j] = pickedBrokers[i] |
|
|
i++ |
|
|
i++ |
|
|
|
|
|
hasChanges = true |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if i < len(pickedBrokers) { |
|
|
if i < len(pickedBrokers) { |
|
|
assignment.FollowerBrokers = append(assignment.FollowerBrokers, pickedBrokers[i:]...) |
|
|
assignment.FollowerBrokers = append(assignment.FollowerBrokers, pickedBrokers[i:]...) |
|
|
|
|
|
hasChanges = true |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
hasChanges = hasChanges || count > 0 |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return |
|
|
return |
|
|