diff options
| author | Konstantin Lebedev <9497591+kmlebedev@users.noreply.github.com> | 2024-07-16 20:03:40 +0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-16 08:03:40 -0700 |
| commit | 67edf1d01413f330d6983125b94e5c3d40a845f2 (patch) | |
| tree | 03d337c508e8d66ffaa92c2916f5970cc6c5d53c /weed/topology/volume_layout.go | |
| parent | ce61a66b651f83b851e85d68e91f62e0aea00ec7 (diff) | |
| download | seaweedfs-67edf1d01413f330d6983125b94e5c3d40a845f2.tar.xz seaweedfs-67edf1d01413f330d6983125b94e5c3d40a845f2.zip | |
[master] Do Automatic Volume Grow in background (#5781)
* Do Automatic Volume Grow in backgound
* pass lastGrowCount to master
* fix build
* fix count to uint64
Diffstat (limited to 'weed/topology/volume_layout.go')
| -rw-r--r-- | weed/topology/volume_layout.go | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/weed/topology/volume_layout.go b/weed/topology/volume_layout.go index 5711a6a9b..c33d0ea0c 100644 --- a/weed/topology/volume_layout.go +++ b/weed/topology/volume_layout.go @@ -107,7 +107,8 @@ func (v *volumesBinaryState) copyState(list *VolumeLocationList) copyState { // mapping from volume to its locations, inverted from server to volume type VolumeLayout struct { growRequest atomic.Bool - rp *super_block.ReplicaPlacement + lastGrowCount atomic.Uint32 + rp *super_block.ReplicaPlacement ttl *needle.TTL diskType types.DiskType vid2location map[needle.VolumeId]*VolumeLocationList @@ -354,6 +355,16 @@ func (vl *VolumeLayout) DoneGrowRequest() { vl.growRequest.Store(false) } +func (vl *VolumeLayout) SetLastGrowCount(count uint32) { + if vl.lastGrowCount.Load() != count { + vl.lastGrowCount.Store(count) + } +} + +func (vl *VolumeLayout) GetLastGrowCount() uint32 { + return vl.lastGrowCount.Load() +} + func (vl *VolumeLayout) ShouldGrowVolumes(option *VolumeGrowOption) bool { total, active, crowded := vl.GetActiveVolumeCount(option) stats.MasterVolumeLayout.WithLabelValues(option.Collection, option.DataCenter, "total").Set(float64(total)) @@ -539,6 +550,13 @@ func (vl *VolumeLayout) ToInfo() (info VolumeLayoutInfo) { return } +func (vl *VolumeLayout) ToGrowOption() (option *VolumeGrowOption) { + option.ReplicaPlacement = vl.rp + option.Ttl = vl.ttl + option.DiskType = vl.diskType + return +} + func (vl *VolumeLayout) Stats() *VolumeLayoutStats { vl.accessLock.RLock() defer vl.accessLock.RUnlock() |
