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
add brokers
Chris Lu1d4a61af5e34
diff --git a/weed/cluster/cluster.go b/weed/cluster/cluster.goindex 08ff97198a..fa01bd03d7 100644--- a/weed/cluster/cluster.go+++ b/weed/cluster/cluster.go@@ -29,12 +29,15 @@ type Cluster struct {filers map[pb.ServerAddress]*ClusterNodefilersLock sync.RWMutexfilerLeaders *Leaders+ brokers map[pb.ServerAddress]*ClusterNode+ brokersLock sync.RWMutex}func NewCluster() *Cluster {return &Cluster{filers: make(map[pb.ServerAddress]*ClusterNode),filerLeaders: &Leaders{},+ brokers: make(map[pb.ServerAddress]*ClusterNode),}}@@ -54,6 +57,28 @@ func (cluster *Cluster) AddClusterNode(nodeType string, address pb.ServerAddresscreatedTs: time.Now(),}return cluster.ensureFilerLeaders(true, nodeType, address)+ case BrokerType:+ cluster.brokersLock.Lock()+ defer cluster.brokersLock.Unlock()+ if existingNode, found := cluster.brokers[address]; found {+ existingNode.counter+++ return nil+ }+ cluster.brokers[address] = &ClusterNode{+ Address: address,+ Version: version,+ counter: 1,+ createdTs: time.Now(),+ }+ return []*master_pb.KeepConnectedResponse{+ {+ ClusterNodeUpdate: &master_pb.ClusterNodeUpdate{+ NodeType: nodeType,+ Address: string(address),+ IsAdd: true,+ },+ },+ }case MasterType:}return nil@@ -73,6 +98,26 @@ func (cluster *Cluster) RemoveClusterNode(nodeType string, address pb.ServerAddrreturn cluster.ensureFilerLeaders(false, nodeType, address)}}+ case BrokerType:+ cluster.brokersLock.Lock()+ defer cluster.brokersLock.Unlock()+ if existingNode, found := cluster.brokers[address]; !found {+ return nil+ } else {+ existingNode.counter--+ if existingNode.counter <= 0 {+ delete(cluster.brokers, address)+ return []*master_pb.KeepConnectedResponse{+ {+ ClusterNodeUpdate: &master_pb.ClusterNodeUpdate{+ NodeType: nodeType,+ Address: string(address),+ IsAdd: false,+ },+ },+ }+ }+ }case MasterType:}return nil@@ -86,6 +131,12 @@ func (cluster *Cluster) ListClusterNode(nodeType string) (nodes []*ClusterNode)for _, node := range cluster.filers {nodes = append(nodes, node)}+ case BrokerType:+ cluster.brokersLock.RLock()+ defer cluster.brokersLock.RUnlock()+ for _, node := range cluster.brokers {+ nodes = append(nodes, node)+ }case MasterType:}return