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
Sort VolumeInfos by VolumeId in Store.Status(); Ordered VolumeInfos is more Human-readable, especially when there is a lot of volumes.
yanyiwub7a18580b8fc
diff --git a/go/storage/store.go b/go/storage/store.goindex ee65ce9e32..8228c12a2f 100644--- a/go/storage/store.go+++ b/go/storage/store.go@@ -223,7 +223,9 @@ func (s *Store) Status() []*VolumeInfo {var stats []*VolumeInfofor _, location := range s.Locations {for k, v := range location.volumes {- s := &VolumeInfo{Id: VolumeId(k), Size: v.ContentSize(),+ s := &VolumeInfo{+ Id: VolumeId(k),+ Size: v.ContentSize(),Collection: v.Collection,ReplicaPlacement: v.ReplicaPlacement,Version: v.Version(),@@ -235,6 +237,7 @@ func (s *Store) Status() []*VolumeInfo {stats = append(stats, s)}}+ sortVolumeInfos(stats)return stats}diff --git a/go/storage/volume_info.go b/go/storage/volume_info.goindex ad58fee440..a2f139c896 100644--- a/go/storage/volume_info.go+++ b/go/storage/volume_info.go@@ -3,6 +3,7 @@ package storageimport ("fmt""github.com/chrislusf/seaweedfs/go/operation"+ "sort")type VolumeInfo struct {@@ -42,3 +43,23 @@ func (vi VolumeInfo) String() string {return fmt.Sprintf("Id:%d, Size:%d, ReplicaPlacement:%s, Collection:%s, Version:%v, FileCount:%d, DeleteCount:%d, DeletedByteCount:%d, ReadOnly:%v",vi.Id, vi.Size, vi.ReplicaPlacement, vi.Collection, vi.Version, vi.FileCount, vi.DeleteCount, vi.DeletedByteCount, vi.ReadOnly)}++/*VolumesInfo sorting*/++type volumeInfos []*VolumeInfo++func (vis volumeInfos) Len() int {+ return len(vis)+}++func (vis volumeInfos) Less(i, j int) bool {+ return vis[i].Id < vis[j].Id+}++func (vis volumeInfos) Swap(i, j int) {+ vis[i], vis[j] = vis[j], vis[i]+}++func sortVolumeInfos(vis volumeInfos) {+ sort.Sort(vis)+}