Browse Source

Node: add planned vloume count

pull/279/head
tnextday 10 years ago
parent
commit
955d4b25d8
  1. 17
      go/topology/node.go

17
go/topology/node.go

@ -19,11 +19,13 @@ type Node interface {
UpAdjustMaxVolumeCountDelta(maxVolumeCountDelta int) UpAdjustMaxVolumeCountDelta(maxVolumeCountDelta int)
UpAdjustVolumeCountDelta(volumeCountDelta int) UpAdjustVolumeCountDelta(volumeCountDelta int)
UpAdjustActiveVolumeCountDelta(activeVolumeCountDelta int) UpAdjustActiveVolumeCountDelta(activeVolumeCountDelta int)
UpAdjustPlannedVolumeCountDelta(delta int)
UpAdjustMaxVolumeId(vid storage.VolumeId) UpAdjustMaxVolumeId(vid storage.VolumeId)
GetVolumeCount() int GetVolumeCount() int
GetActiveVolumeCount() int GetActiveVolumeCount() int
GetMaxVolumeCount() int GetMaxVolumeCount() int
GetPlannedVolumeCount() int
GetMaxVolumeId() storage.VolumeId GetMaxVolumeId() storage.VolumeId
SetParent(Node) SetParent(Node)
LinkChildNode(node Node) LinkChildNode(node Node)
@ -43,6 +45,7 @@ type NodeImpl struct {
volumeCount int volumeCount int
activeVolumeCount int activeVolumeCount int
maxVolumeCount int maxVolumeCount int
plannedVolumeCount int
parent Node parent Node
children map[NodeId]Node children map[NodeId]Node
maxVolumeId storage.VolumeId maxVolumeId storage.VolumeId
@ -133,7 +136,7 @@ func (n *NodeImpl) Id() NodeId {
return n.id return n.id
} }
func (n *NodeImpl) FreeSpace() int { func (n *NodeImpl) FreeSpace() int {
return n.maxVolumeCount - n.volumeCount
return n.maxVolumeCount - n.volumeCount - n.plannedVolumeCount
} }
func (n *NodeImpl) SetParent(node Node) { func (n *NodeImpl) SetParent(node Node) {
n.parent = node n.parent = node
@ -188,6 +191,14 @@ func (n *NodeImpl) UpAdjustActiveVolumeCountDelta(activeVolumeCountDelta int) {
n.parent.UpAdjustActiveVolumeCountDelta(activeVolumeCountDelta) n.parent.UpAdjustActiveVolumeCountDelta(activeVolumeCountDelta)
} }
} }
func (n *NodeImpl) UpAdjustPlannedVolumeCountDelta(delta int) { //can be negative
n.plannedVolumeCount += delta
if n.parent != nil {
n.parent.UpAdjustPlannedVolumeCountDelta(delta)
}
}
func (n *NodeImpl) UpAdjustMaxVolumeId(vid storage.VolumeId) { //can be negative func (n *NodeImpl) UpAdjustMaxVolumeId(vid storage.VolumeId) { //can be negative
if n.maxVolumeId < vid { if n.maxVolumeId < vid {
n.maxVolumeId = vid n.maxVolumeId = vid
@ -209,6 +220,10 @@ func (n *NodeImpl) GetMaxVolumeCount() int {
return n.maxVolumeCount return n.maxVolumeCount
} }
func (n *NodeImpl) GetPlannedVolumeCount() int {
return n.plannedVolumeCount
}
func (n *NodeImpl) LinkChildNode(node Node) { func (n *NodeImpl) LinkChildNode(node Node) {
if n.children[node.Id()] == nil { if n.children[node.Id()] == nil {
n.children[node.Id()] = node n.children[node.Id()] = node

Loading…
Cancel
Save