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
change topology mapping definition, improve spelling
ningfd58f2dd674061
diff --git a/weed/server/master_server_handlers_admin.go b/weed/server/master_server_handlers_admin.goindex 47abfb8927..0c85db791d 100644--- a/weed/server/master_server_handlers_admin.go+++ b/weed/server/master_server_handlers_admin.go@@ -48,7 +48,7 @@ func (ms *MasterServer) collectionDeleteHandler(w http.ResponseWriter, r *http.Rfunc (ms *MasterServer) dirStatusHandler(w http.ResponseWriter, r *http.Request) {m := make(map[string]interface{})m["Version"] = util.Version()- m["Topology"] = ms.Topo.ToMap()+ m["Topology"] = ms.Topo.ToInfo()writeJsonQuiet(w, r, http.StatusOK, m)}diff --git a/weed/server/master_server_handlers_ui.go b/weed/server/master_server_handlers_ui.goindex d8260d8d2f..f09022399f 100644--- a/weed/server/master_server_handlers_ui.go+++ b/weed/server/master_server_handlers_ui.go@@ -26,7 +26,7 @@ func (ms *MasterServer) uiStatusHandler(w http.ResponseWriter, r *http.Request)VolumeSizeLimitMB uint32}{util.Version(),- ms.Topo.ToMap(),+ ms.Topo.ToInfo(),ms.Topo.RaftServer,infos,serverStats,@@ -43,7 +43,7 @@ func (ms *MasterServer) uiStatusHandler(w http.ResponseWriter, r *http.Request)VolumeSizeLimitMB uint32}{util.Version(),- ms.Topo.ToMap(),+ ms.Topo.ToInfo(),ms.Topo.HashicorpRaft,infos,serverStats,diff --git a/weed/topology/data_center.go b/weed/topology/data_center.goindex 304a5ccae0..78c23e7480 100644--- a/weed/topology/data_center.go+++ b/weed/topology/data_center.go@@ -31,25 +31,24 @@ func (dc *DataCenter) GetOrCreateRack(rackName string) *Rack {return rack}-type DataCenterMap struct {- Id NodeId `json:"Id"`- Racks []RackMap `json:"Racks"`+type DataCenterInfo struct {+ Id NodeId `json:"Id"`+ Racks []RackInfo `json:"Racks"`}-func (dc *DataCenter) ToMap() DataCenterMap {- m := DataCenterMap{}- m.Id = dc.Id()- var racks []RackMap+func (dc *DataCenter) ToInfo() (info DataCenterInfo) {+ info.Id = dc.Id()+ var racks []RackInfofor _, c := range dc.Children() {rack := c.(*Rack)- racks = append(racks, rack.ToMap())+ racks = append(racks, rack.ToInfo())}- slices.SortFunc(racks, func(a, b RackMap) bool {+ slices.SortFunc(racks, func(a, b RackInfo) bool {return a.Id < b.Id})- m.Racks = racks- return m+ info.Racks = racks+ return}func (dc *DataCenter) ToDataCenterInfo() *master_pb.DataCenterInfo {diff --git a/weed/topology/data_node.go b/weed/topology/data_node.goindex 6a24c4a49e..33bff2d592 100644--- a/weed/topology/data_node.go+++ b/weed/topology/data_node.go@@ -217,7 +217,7 @@ func (dn *DataNode) ServerAddress() pb.ServerAddress {return pb.NewServerAddress(dn.Ip, dn.Port, dn.GrpcPort)}-type DataNodeMap struct {+type DataNodeInfo struct {Url string `json:"Url"`PublicUrl string `json:"PublicUrl"`Volumes int64 `json:"Volumes"`@@ -226,10 +226,9 @@ type DataNodeMap struct {VolumeIds string `json:"VolumeIds"`}-func (dn *DataNode) ToMap() DataNodeMap {- ret := DataNodeMap{}- ret.Url = dn.Url()- ret.PublicUrl = dn.PublicUrl+func (dn *DataNode) ToInfo() (info DataNodeInfo) {+ info.Url = dn.Url()+ info.PublicUrl = dn.PublicUrl// aggregated volume infovar volumeCount, ecShardCount, maxVolumeCount int64@@ -245,12 +244,12 @@ func (dn *DataNode) ToMap() DataNodeMap {volumeIds += " " + d.GetVolumeIds()}- ret.Volumes = volumeCount- ret.EcShards = ecShardCount- ret.Max = maxVolumeCount- ret.VolumeIds = volumeIds+ info.Volumes = volumeCount+ info.EcShards = ecShardCount+ info.Max = maxVolumeCount+ info.VolumeIds = volumeIds- return ret+ return}func (dn *DataNode) ToDataNodeInfo() *master_pb.DataNodeInfo {diff --git a/weed/topology/rack.go b/weed/topology/rack.goindex 0588dfa7da..7b0ed4a543 100644--- a/weed/topology/rack.go+++ b/weed/topology/rack.go@@ -54,26 +54,25 @@ func (r *Rack) GetOrCreateDataNode(ip string, port int, grpcPort int, publicUrlreturn dn}-type RackMap struct {- Id NodeId `json:"Id"`- DataNodes []DataNodeMap `json:"DataNodes"`+type RackInfo struct {+ Id NodeId `json:"Id"`+ DataNodes []DataNodeInfo `json:"DataNodes"`}-func (r *Rack) ToMap() RackMap {- m := RackMap{}- m.Id = r.Id()- var dns []DataNodeMap+func (r *Rack) ToInfo() (info RackInfo) {+ info.Id = r.Id()+ var dns []DataNodeInfofor _, c := range r.Children() {dn := c.(*DataNode)- dns = append(dns, dn.ToMap())+ dns = append(dns, dn.ToInfo())}- slices.SortFunc(dns, func(a, b DataNodeMap) bool {+ slices.SortFunc(dns, func(a, b DataNodeInfo) bool {return a.Url < b.Url})- m.DataNodes = dns- return m+ info.DataNodes = dns+ return}func (r *Rack) ToRackInfo() *master_pb.RackInfo {diff --git a/weed/topology/topology_map.go b/weed/topology/topology_info.gosimilarity index 77%rename from weed/topology/topology_map.gorename to weed/topology/topology_info.goindex b6585e9649..21ce77edf3 100644--- a/weed/topology/topology_map.go+++ b/weed/topology/topology_info.go@@ -5,41 +5,40 @@ import ("golang.org/x/exp/slices")-type TopologyMap struct {- Max int64 `json:"Max"`- Free int64 `json:"Free"`- DataCenters []DataCenterMap `json:"DataCenters"`- Layouts []interface{} `json:"Layouts"`+type TopologyInfo struct {+ Max int64 `json:"Max"`+ Free int64 `json:"Free"`+ DataCenters []DataCenterInfo `json:"DataCenters"`+ Layouts []VolumeLayoutInfo `json:"Layouts"`}-func (t *Topology) ToMap() interface{} {- m := TopologyMap{}- m.Max = t.diskUsages.GetMaxVolumeCount()- m.Free = t.diskUsages.FreeSpace()- var dcs []DataCenterMap+func (t *Topology) ToInfo() (info TopologyInfo) {+ info.Max = t.diskUsages.GetMaxVolumeCount()+ info.Free = t.diskUsages.FreeSpace()+ var dcs []DataCenterInfofor _, c := range t.Children() {dc := c.(*DataCenter)- dcs = append(dcs, dc.ToMap())+ dcs = append(dcs, dc.ToInfo())}- slices.SortFunc(dcs, func(a, b DataCenterMap) bool {+ slices.SortFunc(dcs, func(a, b DataCenterInfo) bool {return a.Id < b.Id})- m.DataCenters = dcs- var layouts []interface{}+ info.DataCenters = dcs+ var layouts []VolumeLayoutInfofor _, col := range t.collectionMap.Items() {c := col.(*Collection)for _, layout := range c.storageType2VolumeLayout.Items() {if layout != nil {- tmp := layout.(*VolumeLayout).ToMap()- tmp["collection"] = c.Name+ tmp := layout.(*VolumeLayout).ToInfo()+ tmp.Collection = c.Namelayouts = append(layouts, tmp)}}}- m.Layouts = layouts- return m+ info.Layouts = layouts+ return}func (t *Topology) ToVolumeMap() interface{} {diff --git a/weed/topology/volume_layout.go b/weed/topology/volume_layout.goindex dee82762ad..03c4c4adfd 100644--- a/weed/topology/volume_layout.go+++ b/weed/topology/volume_layout.go@@ -473,13 +473,19 @@ func (vl *VolumeLayout) SetVolumeCrowded(vid needle.VolumeId) {}}-func (vl *VolumeLayout) ToMap() map[string]interface{} {- m := make(map[string]interface{})- m["replication"] = vl.rp.String()- m["ttl"] = vl.ttl.String()- m["writables"] = vl.writables+type VolumeLayoutInfo struct {+ Replication string `json:"replication"`+ TTL string `json:"ttl"`+ Writables []needle.VolumeId `json:"writables"`+ Collection string `json:"collection"`+}++func (vl *VolumeLayout) ToInfo() (info VolumeLayoutInfo) {+ info.Replication = vl.rp.String()+ info.TTL = vl.ttl.String()+ info.Writables = vl.writables//m["locations"] = vl.vid2location- return m+ return}func (vl *VolumeLayout) Stats() *VolumeLayoutStats {