mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-11-28 13:31:27 +08:00
master: avoid creating too many volumes
fix https://github.com/chrislusf/seaweedfs/issues/2062
This commit is contained in:
parent
4596e64710
commit
d2d36a3f9d
@ -242,9 +242,9 @@ func (n *NodeImpl) CollectDeadNodeAndFullVolumes(freshThreshHold int64, volumeSi
|
||||
for _, v := range dn.GetVolumes() {
|
||||
if v.Size >= volumeSizeLimit {
|
||||
//fmt.Println("volume",v.Id,"size",v.Size,">",volumeSizeLimit)
|
||||
n.GetTopology().chanFullVolumes <- &v
|
||||
n.GetTopology().chanFullVolumes <- v
|
||||
}else if float64(v.Size) > float64(volumeSizeLimit) * growThreshold {
|
||||
n.GetTopology().chanCrowdedVolumes <- &v
|
||||
n.GetTopology().chanCrowdedVolumes <- v
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,8 +34,8 @@ type Topology struct {
|
||||
|
||||
Sequence sequence.Sequencer
|
||||
|
||||
chanFullVolumes chan *storage.VolumeInfo
|
||||
chanCrowdedVolumes chan *storage.VolumeInfo
|
||||
chanFullVolumes chan storage.VolumeInfo
|
||||
chanCrowdedVolumes chan storage.VolumeInfo
|
||||
|
||||
Configuration *Configuration
|
||||
|
||||
@ -57,8 +57,8 @@ func NewTopology(id string, seq sequence.Sequencer, volumeSizeLimit uint64, puls
|
||||
|
||||
t.Sequence = seq
|
||||
|
||||
t.chanFullVolumes = make(chan *storage.VolumeInfo)
|
||||
t.chanCrowdedVolumes = make(chan *storage.VolumeInfo)
|
||||
t.chanFullVolumes = make(chan storage.VolumeInfo)
|
||||
t.chanCrowdedVolumes = make(chan storage.VolumeInfo)
|
||||
|
||||
t.Configuration = &Configuration{}
|
||||
|
||||
|
@ -39,7 +39,7 @@ func (t *Topology) StartRefreshWritableVolumes(grpcDialOption grpc.DialOption, g
|
||||
}
|
||||
}()
|
||||
}
|
||||
func (t *Topology) SetVolumeCapacityFull(volumeInfo *storage.VolumeInfo) bool {
|
||||
func (t *Topology) SetVolumeCapacityFull(volumeInfo storage.VolumeInfo) bool {
|
||||
diskType := types.ToDiskType(volumeInfo.DiskType)
|
||||
vl := t.GetVolumeLayout(volumeInfo.Collection, volumeInfo.ReplicaPlacement, volumeInfo.Ttl, diskType)
|
||||
if !vl.SetVolumeCapacityFull(volumeInfo.Id) {
|
||||
@ -68,7 +68,7 @@ func (t *Topology) SetVolumeCapacityFull(volumeInfo *storage.VolumeInfo) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (t *Topology) SetVolumeCrowded(volumeInfo *storage.VolumeInfo) {
|
||||
func (t *Topology) SetVolumeCrowded(volumeInfo storage.VolumeInfo) {
|
||||
diskType := types.ToDiskType(volumeInfo.DiskType)
|
||||
vl := t.GetVolumeLayout(volumeInfo.Collection, volumeInfo.ReplicaPlacement, volumeInfo.Ttl, diskType)
|
||||
vl.SetVolumeCrowded(volumeInfo.Id)
|
||||
|
@ -108,7 +108,7 @@ type VolumeLayout struct {
|
||||
diskType types.DiskType
|
||||
vid2location map[needle.VolumeId]*VolumeLocationList
|
||||
writables []needle.VolumeId // transient array of writable volume id
|
||||
crowded map[needle.VolumeId]interface{}
|
||||
crowded map[needle.VolumeId]struct{}
|
||||
readonlyVolumes *volumesBinaryState // readonly volumes
|
||||
oversizedVolumes *volumesBinaryState // oversized volumes
|
||||
volumeSizeLimit uint64
|
||||
@ -129,7 +129,7 @@ func NewVolumeLayout(rp *super_block.ReplicaPlacement, ttl *needle.TTL, diskType
|
||||
diskType: diskType,
|
||||
vid2location: make(map[needle.VolumeId]*VolumeLocationList),
|
||||
writables: *new([]needle.VolumeId),
|
||||
crowded: make(map[needle.VolumeId]interface{}),
|
||||
crowded: make(map[needle.VolumeId]struct{}),
|
||||
readonlyVolumes: NewVolumesBinaryState(readOnlyState, rp, ExistCopies()),
|
||||
oversizedVolumes: NewVolumesBinaryState(oversizedState, rp, ExistCopies()),
|
||||
volumeSizeLimit: volumeSizeLimit,
|
||||
@ -421,7 +421,7 @@ func (vl *VolumeLayout) removeFromCrowded(vid needle.VolumeId) {
|
||||
|
||||
func (vl *VolumeLayout) setVolumeCrowded(vid needle.VolumeId) {
|
||||
if _, ok := vl.crowded[vid]; !ok {
|
||||
vl.crowded[vid] = nil
|
||||
vl.crowded[vid] = struct{}{}
|
||||
glog.V(0).Infoln("Volume", vid, "becomes crowded")
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user