Browse Source

wip

pull/4857/head
chrislu 1 year ago
parent
commit
6c6655de9d
  1. 4
      weed/mq/broker/broker_grpc_balancer.go
  2. 18
      weed/mq/topic/local_manager.go
  3. 13
      weed/pb/mq.proto
  4. 945
      weed/pb/mq_pb/mq.pb.go

4
weed/mq/broker/broker_grpc_balancer.go

@ -40,9 +40,7 @@ func (broker *MessageQueueBroker) ConnectToBalancer(stream mq_pb.SeaweedMessagin
return status.Errorf(codes.Unavailable, "not current broker balancer")
}
if receivedStats := req.GetStats(); receivedStats != nil {
brokerStats.TopicPartitionCount = receivedStats.TopicPartitionCount
brokerStats.ConsumerCount = receivedStats.ConsumerCount
brokerStats.CpuUsagePercent = receivedStats.CpuUsagePercent
brokerStats.UpdateStats(receivedStats)
glog.V(3).Infof("broker %s stats: %+v", initMessage.Broker, brokerStats)
}

18
weed/mq/topic/local_manager.go

@ -58,11 +58,23 @@ func (manager *LocalTopicManager) RemoveTopicPartition(topic Topic, partition Pa
}
func (manager *LocalTopicManager) CollectStats(duration time.Duration) *mq_pb.BrokerStats {
stats := &mq_pb.BrokerStats{}
stats := &mq_pb.BrokerStats{
Stats: make(map[string]*mq_pb.TopicPartitionStats),
}
manager.topics.IterCb(func(topic string, localTopic *LocalTopic) {
for _, localPartition := range localTopic.Partitions {
stats.TopicPartitionCount++
stats.ConsumerCount += localPartition.ConsumerCount
stats.Stats[topic] = &mq_pb.TopicPartitionStats{
Topic: &mq_pb.Topic{
Namespace: string(localTopic.Namespace),
Name: localTopic.Name,
},
Partition: &mq_pb.Partition{
RingSize: localPartition.RingSize,
RangeStart: localPartition.RangeStart,
RangeStop: localPartition.RangeStop,
},
ConsumerCount: localPartition.ConsumerCount,
}
}
})

13
weed/pb/mq.proto

@ -105,10 +105,17 @@ message CheckBrokerLoadResponse {
//////////////////////////////////////////////////
message BrokerStats {
int32 topic_partition_count = 1;
int32 consumer_count = 2;
int32 cpu_usage_percent = 3;
int32 cpu_usage_percent = 1;
map<string, TopicPartitionStats> stats = 2;
}
message TopicPartitionStats {
Topic topic = 1;
Partition partition = 2;
int32 consumer_count = 3;
bool is_leader = 4;
}
message ConnectToBalancerRequest {
message InitMessage {
string broker = 1;

945
weed/pb/mq_pb/mq.pb.go
File diff suppressed because it is too large
View File

Loading…
Cancel
Save