|
@ -3,6 +3,7 @@ package weed_server |
|
|
import ( |
|
|
import ( |
|
|
"context" |
|
|
"context" |
|
|
"fmt" |
|
|
"fmt" |
|
|
|
|
|
"math" |
|
|
"math/rand/v2" |
|
|
"math/rand/v2" |
|
|
"strings" |
|
|
"strings" |
|
|
"sync" |
|
|
"sync" |
|
@ -53,7 +54,7 @@ func (ms *MasterServer) ProcessGrowRequest() { |
|
|
if !ms.Topo.IsLeader() { |
|
|
if !ms.Topo.IsLeader() { |
|
|
continue |
|
|
continue |
|
|
} |
|
|
} |
|
|
dcs := ms.Topo.ListDataCenters() |
|
|
|
|
|
|
|
|
dcs := ms.Topo.ListDCAndRacks() |
|
|
var err error |
|
|
var err error |
|
|
for _, vlc := range ms.Topo.ListVolumeLayoutCollections() { |
|
|
for _, vlc := range ms.Topo.ListVolumeLayoutCollections() { |
|
|
vl := vlc.VolumeLayout |
|
|
vl := vlc.VolumeLayout |
|
@ -74,22 +75,28 @@ func (ms *MasterServer) ProcessGrowRequest() { |
|
|
case lastGrowCount > 0 && writable < int(lastGrowCount*2) && float64(crowded+volumeGrowStepCount) > float64(writable)*topology.VolumeGrowStrategy.Threshold: |
|
|
case lastGrowCount > 0 && writable < int(lastGrowCount*2) && float64(crowded+volumeGrowStepCount) > float64(writable)*topology.VolumeGrowStrategy.Threshold: |
|
|
vgr.WritableVolumeCount = volumeGrowStepCount |
|
|
vgr.WritableVolumeCount = volumeGrowStepCount |
|
|
_, err = ms.VolumeGrow(ctx, vgr) |
|
|
_, err = ms.VolumeGrow(ctx, vgr) |
|
|
default: |
|
|
|
|
|
for _, dc := range dcs { |
|
|
|
|
|
if vl.ShouldGrowVolumesByDataNode("DataCenter", dc) { |
|
|
|
|
|
vgr.DataCenter = dc |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
glog.V(0).Infof("volume grow request failed: %+v", err) |
|
|
|
|
|
} |
|
|
|
|
|
writableVolumes := vl.CloneWritableVolumes() |
|
|
|
|
|
for dcId, racks := range dcs { |
|
|
|
|
|
for _, rackId := range racks { |
|
|
|
|
|
if vl.ShouldGrowVolumesByDcAndRack(&writableVolumes, dcId, rackId) { |
|
|
|
|
|
vgr.DataCenter = string(dcId) |
|
|
|
|
|
vgr.Rack = string(rackId) |
|
|
if lastGrowCount > 0 { |
|
|
if lastGrowCount > 0 { |
|
|
vgr.WritableVolumeCount = uint32(int(lastGrowCount) / len(dcs)) |
|
|
|
|
|
|
|
|
vgr.WritableVolumeCount = uint32(math.Ceil(float64(lastGrowCount) / float64(len(dcs)*len(racks)))) |
|
|
} else { |
|
|
} else { |
|
|
vgr.WritableVolumeCount = volumeGrowStepCount |
|
|
vgr.WritableVolumeCount = volumeGrowStepCount |
|
|
} |
|
|
} |
|
|
_, err = ms.VolumeGrow(ctx, vgr) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if _, err = ms.VolumeGrow(ctx, vgr); err != nil { |
|
|
|
|
|
glog.V(0).Infof("volume grow request for dc:%s rack:%s failed: %+v", dcId, rackId, err) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if err != nil { |
|
|
|
|
|
glog.V(0).Infof("volume grow request failed: %+v", err) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}() |
|
|
}() |
|
|