From e941d0c2f471fcecede4a8efd6ac6a4895454275 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Thu, 30 May 2019 09:17:58 -0700 Subject: [PATCH] list ec collections also --- weed/server/master_grpc_server_collection.go | 2 +- weed/topology/topology.go | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/weed/server/master_grpc_server_collection.go b/weed/server/master_grpc_server_collection.go index 23188d856..02a1ee3a7 100644 --- a/weed/server/master_grpc_server_collection.go +++ b/weed/server/master_grpc_server_collection.go @@ -19,7 +19,7 @@ func (ms *MasterServer) CollectionList(ctx context.Context, req *master_pb.Colle collections := ms.Topo.ListCollections() for _, c := range collections { resp.Collections = append(resp.Collections, &master_pb.Collection{ - Name: c.Name, + Name: c, }) } diff --git a/weed/topology/topology.go b/weed/topology/topology.go index 667846f02..07b70dd9f 100644 --- a/weed/topology/topology.go +++ b/weed/topology/topology.go @@ -126,9 +126,21 @@ func (t *Topology) GetVolumeLayout(collectionName string, rp *storage.ReplicaPla }).(*Collection).GetOrCreateVolumeLayout(rp, ttl) } -func (t *Topology) ListCollections() (ret []*Collection) { +func (t *Topology) ListCollections() (ret []string) { + + mapOfCollections := make(map[string]bool) for _, c := range t.collectionMap.Items() { - ret = append(ret, c.(*Collection)) + mapOfCollections[c.(*Collection).Name] = true + } + + t.ecShardMapLock.RLock() + for _, ecVolumeLocation := range t.ecShardMap { + mapOfCollections[ecVolumeLocation.Collection] = true + } + t.ecShardMapLock.RUnlock() + + for k, _ := range mapOfCollections { + ret = append(ret, k) } return ret }