|
@ -12,7 +12,7 @@ type Node struct { |
|
|
maxVolumeCount int |
|
|
maxVolumeCount int |
|
|
parent *Node |
|
|
parent *Node |
|
|
children map[NodeId]*Node |
|
|
children map[NodeId]*Node |
|
|
isLeaf bool |
|
|
|
|
|
|
|
|
maxVolumeId storage.VolumeId |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (n *Node) ReserveOneVolume(r int, vid storage.VolumeId) bool { |
|
|
func (n *Node) ReserveOneVolume(r int, vid storage.VolumeId) bool { |
|
@ -33,6 +33,9 @@ func (n *Node) ReserveOneVolume(r int, vid storage.VolumeId) bool { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (n *Node) AddVolume(v *storage.VolumeInfo) { |
|
|
func (n *Node) AddVolume(v *storage.VolumeInfo) { |
|
|
|
|
|
if n.maxVolumeId < v.Id { |
|
|
|
|
|
n.maxVolumeId = v.Id |
|
|
|
|
|
} |
|
|
n.countVolumeCount++ |
|
|
n.countVolumeCount++ |
|
|
if n.reservedVolumeCount > 0 { //if reserved
|
|
|
if n.reservedVolumeCount > 0 { //if reserved
|
|
|
n.reservedVolumeCount-- |
|
|
n.reservedVolumeCount-- |
|
@ -42,6 +45,10 @@ func (n *Node) AddVolume(v *storage.VolumeInfo) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (n *Node) GetMaxVolumeId() storage.VolumeId { |
|
|
|
|
|
return n.maxVolumeId |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
func (n *Node) AddNode(node *Node) { |
|
|
func (n *Node) AddNode(node *Node) { |
|
|
n.children[node.id] = node |
|
|
n.children[node.id] = node |
|
|
n.countVolumeCount += node.countVolumeCount |
|
|
n.countVolumeCount += node.countVolumeCount |
|
|