mirror of
https://github.com/chrislusf/seaweedfs
synced 2024-07-05 16:47:04 +02:00
refactor
This commit is contained in:
parent
a5b906c0dd
commit
9ce7c482b3
|
@ -67,7 +67,12 @@ func (balancer *Balancer) RemoveBroker(broker string, stats *BrokerStats) {
|
||||||
if !found {
|
if !found {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
pickedBroker := pickBrokers(balancer.Brokers, 1)
|
||||||
|
if len(pickedBroker) == 0 {
|
||||||
partitionSlotToBrokerList.RemoveBroker(broker)
|
partitionSlotToBrokerList.RemoveBroker(broker)
|
||||||
|
} else {
|
||||||
|
partitionSlotToBrokerList.ReplaceBroker(broker, pickedBroker[0])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
balancer.onPubRemoveBroker(broker, stats)
|
balancer.onPubRemoveBroker(broker, stats)
|
||||||
balancer.OnRemoveBroker(broker, stats)
|
balancer.OnRemoveBroker(broker, stats)
|
||||||
|
|
|
@ -44,9 +44,13 @@ func (ps *PartitionSlotToBrokerList) AddBroker(partition *mq_pb.Partition, broke
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
func (ps *PartitionSlotToBrokerList) RemoveBroker(broker string) {
|
func (ps *PartitionSlotToBrokerList) RemoveBroker(broker string) {
|
||||||
|
ps.ReplaceBroker(broker, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ps *PartitionSlotToBrokerList) ReplaceBroker(oldBroker string, newBroker string) {
|
||||||
for _, partitionSlot := range ps.PartitionSlots {
|
for _, partitionSlot := range ps.PartitionSlots {
|
||||||
if partitionSlot.AssignedBroker == broker {
|
if partitionSlot.AssignedBroker == oldBroker {
|
||||||
partitionSlot.AssignedBroker = ""
|
partitionSlot.AssignedBroker = newBroker
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue