From dff2ce5d2fa96693a0b4d55d314976f155fb902c Mon Sep 17 00:00:00 2001 From: chrislu Date: Sun, 24 Sep 2023 23:10:33 -0700 Subject: [PATCH] read existing broker stats --- weed/mq/broker/broker_grpc_balancer.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/weed/mq/broker/broker_grpc_balancer.go b/weed/mq/broker/broker_grpc_balancer.go index 63dda7d69..e602f4bad 100644 --- a/weed/mq/broker/broker_grpc_balancer.go +++ b/weed/mq/broker/broker_grpc_balancer.go @@ -20,11 +20,15 @@ func (broker *MessageQueueBroker) ConnectToBalancer(stream mq_pb.SeaweedMessagin // process init message initMessage := req.GetInit() - brokerStats := balancer.NewBrokerStats() + var brokerStats *balancer.BrokerStats if initMessage != nil { - broker.Balancer.Brokers.Set(initMessage.Broker, brokerStats) + var found bool + brokerStats, found = broker.Balancer.Brokers.Get(initMessage.Broker) + if !found { + brokerStats = balancer.NewBrokerStats() + broker.Balancer.Brokers.Set(initMessage.Broker, brokerStats) + } } else { - // TODO fix this return status.Errorf(codes.InvalidArgument, "balancer init message is empty") } defer func() {