aboutsummaryrefslogtreecommitdiff
path: root/weed/topology/node.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-12-13 19:44:57 -0800
committerChris Lu <chris.lu@gmail.com>2020-12-13 19:44:57 -0800
commita9db24cd052ae4b17773a6bb77b703536bb80039 (patch)
tree33784f7c5a2847ee937a99334533d06bdb94eeb9 /weed/topology/node.go
parentac4d4a65affab189d9a390b96e0bae0256d3161a (diff)
downloadseaweedfs-a9db24cd052ae4b17773a6bb77b703536bb80039.tar.xz
seaweedfs-a9db24cd052ae4b17773a6bb77b703536bb80039.zip
master allocate volumes if ssd type runs out
Diffstat (limited to 'weed/topology/node.go')
-rw-r--r--weed/topology/node.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/weed/topology/node.go b/weed/topology/node.go
index c916857c0..8f525021f 100644
--- a/weed/topology/node.go
+++ b/weed/topology/node.go
@@ -2,6 +2,7 @@ package topology
import (
"errors"
+ "github.com/chrislusf/seaweedfs/weed/storage"
"math/rand"
"strings"
"sync"
@@ -148,6 +149,16 @@ func (n *NodeImpl) String() string {
func (n *NodeImpl) Id() NodeId {
return n.id
}
+func (n *NodeImpl) AvailableSpaceFor(option *VolumeGrowOption) int64 {
+ freeVolumeSlotCount := n.maxVolumeCount + n.remoteVolumeCount - n.volumeCount
+ if option.DiskType == storage.SsdType {
+ freeVolumeSlotCount = n.maxSsdVolumeCount - n.ssdVolumeCount
+ }
+ if n.ecShardCount > 0 {
+ freeVolumeSlotCount = freeVolumeSlotCount - n.ecShardCount/erasure_coding.DataShardsCount - 1
+ }
+ return freeVolumeSlotCount
+}
func (n *NodeImpl) FreeSpace() int64 {
freeVolumeSlotCount := n.maxVolumeCount + n.maxSsdVolumeCount + n.remoteVolumeCount - n.volumeCount - n.ssdVolumeCount
if n.ecShardCount > 0 {