reduce duplicated code by using a tree of Node

This commit is contained in:
Chris Lu
2012-08-29 00:58:03 -07:00
parent 97e4a1d6eb
commit f7adf1687f
6 changed files with 80 additions and 151 deletions

View File

@@ -0,0 +1,21 @@
package topology
import (
"pkg/storage"
)
type Server struct {
Node
volumes map[storage.VolumeId]*storage.VolumeInfo
Ip NodeId
Port int
PublicUrl string
}
func (s *Server) CreateOneVolume(r int, vid storage.VolumeId) storage.VolumeId {
s.AddVolume(&storage.VolumeInfo{Id:vid, Size: 32*1024*1024*1024})
return vid
}
func (s *Server) AddVolume(v *storage.VolumeInfo){
s.volumes[v.Id] = v
s.Node.AddVolume(v)
}