interface and default implementation for node

This commit is contained in:
Chris Lu
2012-09-02 14:33:48 -07:00
parent a467d5081c
commit b95c9860ed
8 changed files with 176 additions and 133 deletions

View File

@@ -1,28 +1,31 @@
package topology
import (
"pkg/storage"
_ "fmt"
_ "fmt"
"pkg/storage"
)
type Server struct {
Node
volumes map[storage.VolumeId]*storage.VolumeInfo
Ip NodeId
Port int
PublicUrl string
NodeImpl
volumes map[storage.VolumeId]*storage.VolumeInfo
Ip NodeId
Port int
PublicUrl string
}
func NewServer(id NodeId) *Server{
s := &Server{}
s.Node.Id = id
s.volumes = make(map[storage.VolumeId]*storage.VolumeInfo)
return s
func NewServer(id string) *Server {
s := &Server{}
s.id = NodeId(id)
s.nodeType = "Server"
s.volumes = make(map[storage.VolumeId]*storage.VolumeInfo)
return s
}
func (s *Server) CreateOneVolume(r int, vid storage.VolumeId) storage.VolumeId {
s.AddVolume(&storage.VolumeInfo{Id:vid, Size: 32*1024*1024*1024})
return vid
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)
func (s *Server) AddVolume(v *storage.VolumeInfo) {
s.volumes[v.Id] = v
s.UpAdjustActiveVolumeCountDelta(1)
s.UpAdjustMaxVolumeId(v.Id)
}