mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-09-23 04:03:35 +08:00
use ShouldGrowVolumesByDcAndRack (#6280)
This commit is contained in:

committed by
GitHub

parent
167b50be88
commit
8836fa19b6
@@ -365,25 +365,10 @@ func (vl *VolumeLayout) ShouldGrowVolumes() bool {
|
||||
return writable <= crowded
|
||||
}
|
||||
|
||||
func (vl *VolumeLayout) ShouldGrowVolumesByDataNode(nodeType string, dataNode string) bool {
|
||||
vl.accessLock.RLock()
|
||||
writables := make([]needle.VolumeId, len(vl.writables))
|
||||
copy(writables, vl.writables)
|
||||
vl.accessLock.RUnlock()
|
||||
|
||||
dataNodeId := NodeId(dataNode)
|
||||
for _, v := range writables {
|
||||
for _, dn := range vl.vid2location[v].list {
|
||||
dataNodeFound := false
|
||||
switch nodeType {
|
||||
case "DataCenter":
|
||||
dataNodeFound = dn.GetDataCenter().Id() == dataNodeId
|
||||
case "Rack":
|
||||
dataNodeFound = dn.GetRack().Id() == dataNodeId
|
||||
case "DataNode":
|
||||
dataNodeFound = dn.Id() == dataNodeId
|
||||
}
|
||||
if dataNodeFound {
|
||||
func (vl *VolumeLayout) ShouldGrowVolumesByDcAndRack(writables *[]needle.VolumeId, dcId NodeId, rackId NodeId) bool {
|
||||
for _, v := range *writables {
|
||||
for _, dn := range vl.Lookup(v) {
|
||||
if dn.GetDataCenter().Id() == dcId && dn.GetRack().Id() == rackId {
|
||||
if info, err := dn.GetVolumesById(v); err == nil && !vl.isCrowdedVolume(&info) {
|
||||
return false
|
||||
}
|
||||
@@ -399,6 +384,14 @@ func (vl *VolumeLayout) GetWritableVolumeCount() (active, crowded int) {
|
||||
return len(vl.writables), len(vl.crowded)
|
||||
}
|
||||
|
||||
func (vl *VolumeLayout) CloneWritableVolumes() (writables []needle.VolumeId) {
|
||||
vl.accessLock.RLock()
|
||||
writables = make([]needle.VolumeId, len(vl.writables))
|
||||
copy(writables, vl.writables)
|
||||
vl.accessLock.RUnlock()
|
||||
return writables
|
||||
}
|
||||
|
||||
func (vl *VolumeLayout) removeFromWritable(vid needle.VolumeId) bool {
|
||||
toDeleteIndex := -1
|
||||
for k, id := range vl.writables {
|
||||
|
Reference in New Issue
Block a user