SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
refactor
chrisluc616081ab9d8
diff --git a/weed/mq/broker/broker_grpc_pub.go b/weed/mq/broker/broker_grpc_pub.goindex e8238a5f75..3b585f6f66 100644--- a/weed/mq/broker/broker_grpc_pub.go+++ b/weed/mq/broker/broker_grpc_pub.go@@ -149,26 +149,17 @@ func (b *MessageQueueBroker) PublishMessage(stream mq_pb.SeaweedMessaging_Publis}func (b *MessageQueueBroker) loadLocalTopicPartitionFromFiler(t topic.Topic, p topic.Partition) (localTopicPartition *topic.LocalPartition, err error) {+ self := b.option.BrokerAddress()+ glog.V(0).Infof("broker %s load topic %v partition %v", self, t, p)+// load local topic partition from configuration on filer if not foundvar conf *mq_pb.ConfigureTopicResponse- topicDir := fmt.Sprintf("%s/%s/%s", filer.TopicsDir, t.Namespace, t.Name)- if err = b.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {- data, err := filer.ReadInsideFiler(client, topicDir, "topic.conf")- if err != nil {- return fmt.Errorf("read topic %v partition %v conf: %v", t, p, err)- }- // parse into filer conf object- conf = &mq_pb.ConfigureTopicResponse{}- if err = jsonpb.Unmarshal(data, conf); err != nil {- return fmt.Errorf("unmarshal topic %v partition %v conf: %v", t, p, err)- }- return nil- }); err != nil {+ conf, err = b.readTopicConfFromFiler(t, p)+ if err != nil {return nil, err}// create local topic partition- self := b.option.BrokerAddress()var hasCreated boolfor _, assignment := range conf.BrokerPartitionAssignments {if assignment.LeaderBroker == string(self) && p.Equals(topic.FromPbPartition(assignment.Partition)) {@@ -186,6 +177,25 @@ func (b *MessageQueueBroker) loadLocalTopicPartitionFromFiler(t topic.Topic, p treturn localTopicPartition, nil}+func (b *MessageQueueBroker) readTopicConfFromFiler(t topic.Topic, p topic.Partition) (conf *mq_pb.ConfigureTopicResponse, err error) {+ topicDir := fmt.Sprintf("%s/%s/%s", filer.TopicsDir, t.Namespace, t.Name)+ if err = b.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {+ data, err := filer.ReadInsideFiler(client, topicDir, "topic.conf")+ if err != nil {+ return fmt.Errorf("read topic %v partition %v conf: %v", t, p, err)+ }+ // parse into filer conf object+ conf = &mq_pb.ConfigureTopicResponse{}+ if err = jsonpb.Unmarshal(data, conf); err != nil {+ return fmt.Errorf("unmarshal topic %v partition %v conf: %v", t, p, err)+ }+ return nil+ }); err != nil {+ return nil, err+ }+ return conf, err+}+// duplicated from master_grpc_server.gofunc findClientAddress(ctx context.Context) string {// fmt.Printf("FromContext %+v\n", ctx)