aboutsummaryrefslogtreecommitdiff
path: root/weed/topology/node.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-12-13 03:11:24 -0800
committerChris Lu <chris.lu@gmail.com>2020-12-13 03:11:24 -0800
commitd156c74ec097add1954fa2a0a9a55eb02b44bb0e (patch)
tree872edef3665d27b852631303f031aa97470f4ad5 /weed/topology/node.go
parente9cd798bd372741753efcba2af594b00fe7b8437 (diff)
downloadseaweedfs-d156c74ec097add1954fa2a0a9a55eb02b44bb0e.tar.xz
seaweedfs-d156c74ec097add1954fa2a0a9a55eb02b44bb0e.zip
volume server set volume type and heartbeat to the master
Diffstat (limited to 'weed/topology/node.go')
-rw-r--r--weed/topology/node.go36
1 files changed, 35 insertions, 1 deletions
diff --git a/weed/topology/node.go b/weed/topology/node.go
index 114417edf..c916857c0 100644
--- a/weed/topology/node.go
+++ b/weed/topology/node.go
@@ -19,17 +19,21 @@ type Node interface {
FreeSpace() int64
ReserveOneVolume(r int64) (*DataNode, error)
UpAdjustMaxVolumeCountDelta(maxVolumeCountDelta int64)
+ UpAdjustMaxSsdVolumeCountDelta(maxSsdVolumeCountDelta int64)
UpAdjustVolumeCountDelta(volumeCountDelta int64)
+ UpAdjustSsdVolumeCountDelta(ssdVolumeCountDelta int64)
UpAdjustRemoteVolumeCountDelta(remoteVolumeCountDelta int64)
UpAdjustEcShardCountDelta(ecShardCountDelta int64)
UpAdjustActiveVolumeCountDelta(activeVolumeCountDelta int64)
UpAdjustMaxVolumeId(vid needle.VolumeId)
GetVolumeCount() int64
+ GetSsdVolumeCount() int64
GetEcShardCount() int64
GetActiveVolumeCount() int64
GetRemoteVolumeCount() int64
GetMaxVolumeCount() int64
+ GetMaxSsdVolumeCount() int64
GetMaxVolumeId() needle.VolumeId
SetParent(Node)
LinkChildNode(node Node)
@@ -47,9 +51,11 @@ type Node interface {
type NodeImpl struct {
volumeCount int64
remoteVolumeCount int64
+ ssdVolumeCount int64
activeVolumeCount int64
ecShardCount int64
maxVolumeCount int64
+ maxSsdVolumeCount int64
id NodeId
parent Node
sync.RWMutex // lock children
@@ -143,7 +149,7 @@ func (n *NodeImpl) Id() NodeId {
return n.id
}
func (n *NodeImpl) FreeSpace() int64 {
- freeVolumeSlotCount := n.maxVolumeCount + n.remoteVolumeCount - n.volumeCount
+ freeVolumeSlotCount := n.maxVolumeCount + n.maxSsdVolumeCount + n.remoteVolumeCount - n.volumeCount - n.ssdVolumeCount
if n.ecShardCount > 0 {
freeVolumeSlotCount = freeVolumeSlotCount - n.ecShardCount/erasure_coding.DataShardsCount - 1
}
@@ -200,6 +206,15 @@ func (n *NodeImpl) UpAdjustMaxVolumeCountDelta(maxVolumeCountDelta int64) { //ca
n.parent.UpAdjustMaxVolumeCountDelta(maxVolumeCountDelta)
}
}
+func (n *NodeImpl) UpAdjustMaxSsdVolumeCountDelta(maxSsdVolumeCountDelta int64) { //can be negative
+ if maxSsdVolumeCountDelta == 0 {
+ return
+ }
+ atomic.AddInt64(&n.maxSsdVolumeCount, maxSsdVolumeCountDelta)
+ if n.parent != nil {
+ n.parent.UpAdjustMaxSsdVolumeCountDelta(maxSsdVolumeCountDelta)
+ }
+}
func (n *NodeImpl) UpAdjustVolumeCountDelta(volumeCountDelta int64) { //can be negative
if volumeCountDelta == 0 {
return
@@ -218,6 +233,15 @@ func (n *NodeImpl) UpAdjustRemoteVolumeCountDelta(remoteVolumeCountDelta int64)
n.parent.UpAdjustRemoteVolumeCountDelta(remoteVolumeCountDelta)
}
}
+func (n *NodeImpl) UpAdjustSsdVolumeCountDelta(ssdVolumeCountDelta int64) { //can be negative
+ if ssdVolumeCountDelta == 0 {
+ return
+ }
+ atomic.AddInt64(&n.ssdVolumeCount, ssdVolumeCountDelta)
+ if n.parent != nil {
+ n.parent.UpAdjustSsdVolumeCountDelta(ssdVolumeCountDelta)
+ }
+}
func (n *NodeImpl) UpAdjustEcShardCountDelta(ecShardCountDelta int64) { //can be negative
if ecShardCountDelta == 0 {
return
@@ -250,6 +274,9 @@ func (n *NodeImpl) GetMaxVolumeId() needle.VolumeId {
func (n *NodeImpl) GetVolumeCount() int64 {
return n.volumeCount
}
+func (n *NodeImpl) GetSsdVolumeCount() int64 {
+ return n.ssdVolumeCount
+}
func (n *NodeImpl) GetEcShardCount() int64 {
return n.ecShardCount
}
@@ -262,6 +289,9 @@ func (n *NodeImpl) GetActiveVolumeCount() int64 {
func (n *NodeImpl) GetMaxVolumeCount() int64 {
return n.maxVolumeCount
}
+func (n *NodeImpl) GetMaxSsdVolumeCount() int64 {
+ return n.maxSsdVolumeCount
+}
func (n *NodeImpl) LinkChildNode(node Node) {
n.Lock()
@@ -269,8 +299,10 @@ func (n *NodeImpl) LinkChildNode(node Node) {
if n.children[node.Id()] == nil {
n.children[node.Id()] = node
n.UpAdjustMaxVolumeCountDelta(node.GetMaxVolumeCount())
+ n.UpAdjustMaxSsdVolumeCountDelta(node.GetMaxSsdVolumeCount())
n.UpAdjustMaxVolumeId(node.GetMaxVolumeId())
n.UpAdjustVolumeCountDelta(node.GetVolumeCount())
+ n.UpAdjustSsdVolumeCountDelta(node.GetSsdVolumeCount())
n.UpAdjustRemoteVolumeCountDelta(node.GetRemoteVolumeCount())
n.UpAdjustEcShardCountDelta(node.GetEcShardCount())
n.UpAdjustActiveVolumeCountDelta(node.GetActiveVolumeCount())
@@ -287,10 +319,12 @@ func (n *NodeImpl) UnlinkChildNode(nodeId NodeId) {
node.SetParent(nil)
delete(n.children, node.Id())
n.UpAdjustVolumeCountDelta(-node.GetVolumeCount())
+ n.UpAdjustSsdVolumeCountDelta(-node.GetSsdVolumeCount())
n.UpAdjustRemoteVolumeCountDelta(-node.GetRemoteVolumeCount())
n.UpAdjustEcShardCountDelta(-node.GetEcShardCount())
n.UpAdjustActiveVolumeCountDelta(-node.GetActiveVolumeCount())
n.UpAdjustMaxVolumeCountDelta(-node.GetMaxVolumeCount())
+ n.UpAdjustMaxSsdVolumeCountDelta(-node.GetMaxSsdVolumeCount())
glog.V(0).Infoln(n, "removes", node.Id())
}
}