diff options
| author | Lisandro Pin <lisandro.pin@proton.ch> | 2025-04-16 23:28:58 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-16 14:28:58 -0700 |
| commit | cea34dc21a3ac234baf46a131ee687ba25df2acb (patch) | |
| tree | 39e85778094dc1aea5d4acb6a37e5e77cae64bdc /weed/topology/topology.go | |
| parent | df6f23068101f6fe817f93a128c688069ea279e5 (diff) | |
| download | seaweedfs-cea34dc21a3ac234baf46a131ee687ba25df2acb.tar.xz seaweedfs-cea34dc21a3ac234baf46a131ee687ba25df2acb.zip | |
Fix implementation of `master_pb.CollectionList` RPC call (#6715)
Diffstat (limited to 'weed/topology/topology.go')
| -rw-r--r-- | weed/topology/topology.go | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/weed/topology/topology.go b/weed/topology/topology.go index 8e55d33a9..750c00ea2 100644 --- a/weed/topology/topology.go +++ b/weed/topology/topology.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "math/rand/v2" + "slices" "sync" "time" @@ -268,23 +269,29 @@ func (t *Topology) GetVolumeLayout(collectionName string, rp *super_block.Replic } func (t *Topology) ListCollections(includeNormalVolumes, includeEcVolumes bool) (ret []string) { + found := make(map[string]bool) - mapOfCollections := make(map[string]bool) - for _, c := range t.collectionMap.Items() { - mapOfCollections[c.(*Collection).Name] = true + if includeNormalVolumes { + t.collectionMap.RLock() + for _, c := range t.collectionMap.Items() { + found[c.(*Collection).Name] = true + } + t.collectionMap.RUnlock() } if includeEcVolumes { t.ecShardMapLock.RLock() for _, ecVolumeLocation := range t.ecShardMap { - mapOfCollections[ecVolumeLocation.Collection] = true + found[ecVolumeLocation.Collection] = true } t.ecShardMapLock.RUnlock() } - for k := range mapOfCollections { + for k := range found { ret = append(ret, k) } + slices.Sort(ret) + return ret } @@ -317,6 +324,7 @@ func (t *Topology) RegisterVolumeLayout(v storage.VolumeInfo, dn *DataNode) { vl.RegisterVolume(&v, dn) vl.EnsureCorrectWritables(&v) } + func (t *Topology) UnRegisterVolumeLayout(v storage.VolumeInfo, dn *DataNode) { glog.Infof("removing volume info: %+v from %v", v, dn.id) if v.ReplicaPlacement.GetCopyCount() > 1 { |
