diff options
| author | Konstantin Lebedev <9497591+kmlebedev@users.noreply.github.com> | 2024-09-04 20:16:44 +0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-04 08:16:44 -0700 |
| commit | 67a252ee8a0cbcf0f33cb7c94de21d4791ef1f39 (patch) | |
| tree | 36c494fa2bba916714cd0ac53e9070a4a1295d6b /weed/topology/topology.go | |
| parent | eb02946c977be57a0325d9ed86847699e99661c1 (diff) | |
| download | seaweedfs-67a252ee8a0cbcf0f33cb7c94de21d4791ef1f39.tar.xz seaweedfs-67a252ee8a0cbcf0f33cb7c94de21d4791ef1f39.zip | |
[master] refactor func ShouldGrowVolumes (#5884)
Diffstat (limited to 'weed/topology/topology.go')
| -rw-r--r-- | weed/topology/topology.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/weed/topology/topology.go b/weed/topology/topology.go index 6bfd912cb..ba3be97c4 100644 --- a/weed/topology/topology.go +++ b/weed/topology/topology.go @@ -329,7 +329,7 @@ func (t *Topology) UnRegisterVolumeLayout(v storage.VolumeInfo, dn *DataNode) { } func (t *Topology) DataCenterExists(dcName string) bool { - return dcName == "" || t.GetOrCreateDataCenter(dcName) != nil + return dcName == "" || t.GetDataCenter(dcName) != nil } func (t *Topology) GetDataCenter(dcName string) (dc *DataCenter) { @@ -358,6 +358,15 @@ func (t *Topology) GetOrCreateDataCenter(dcName string) *DataCenter { return dc } +func (t *Topology) ListDataCenters() (dcs []string) { + t.RLock() + defer t.RUnlock() + for _, c := range t.children { + dcs = append(dcs, string(c.(*DataCenter).Id())) + } + return dcs +} + func (t *Topology) SyncDataNodeRegistration(volumes []*master_pb.VolumeInformationMessage, dn *DataNode) (newVolumes, deletedVolumes []storage.VolumeInfo) { // convert into in memory struct storage.VolumeInfo var volumeInfos []storage.VolumeInfo |
