2012-08-29 15:58:03 +08:00
|
|
|
package topology
|
|
|
|
|
|
|
|
import (
|
2012-09-03 05:33:48 +08:00
|
|
|
_ "fmt"
|
|
|
|
"pkg/storage"
|
2012-08-29 15:58:03 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
type Server struct {
|
2012-09-03 05:33:48 +08:00
|
|
|
NodeImpl
|
|
|
|
volumes map[storage.VolumeId]*storage.VolumeInfo
|
|
|
|
Ip NodeId
|
|
|
|
Port int
|
|
|
|
PublicUrl string
|
2012-08-29 15:58:03 +08:00
|
|
|
}
|
2012-09-03 05:33:48 +08:00
|
|
|
|
|
|
|
func NewServer(id string) *Server {
|
|
|
|
s := &Server{}
|
|
|
|
s.id = NodeId(id)
|
|
|
|
s.nodeType = "Server"
|
|
|
|
s.volumes = make(map[storage.VolumeId]*storage.VolumeInfo)
|
|
|
|
return s
|
2012-08-31 16:35:11 +08:00
|
|
|
}
|
2012-08-29 15:58:03 +08:00
|
|
|
func (s *Server) CreateOneVolume(r int, vid storage.VolumeId) storage.VolumeId {
|
2012-09-03 05:33:48 +08:00
|
|
|
s.AddVolume(&storage.VolumeInfo{Id: vid, Size: 32 * 1024 * 1024 * 1024})
|
|
|
|
return vid
|
2012-08-29 15:58:03 +08:00
|
|
|
}
|
2012-09-03 05:33:48 +08:00
|
|
|
func (s *Server) AddVolume(v *storage.VolumeInfo) {
|
|
|
|
s.volumes[v.Id] = v
|
|
|
|
s.UpAdjustActiveVolumeCountDelta(1)
|
|
|
|
s.UpAdjustMaxVolumeId(v.Id)
|
2012-08-29 15:58:03 +08:00
|
|
|
}
|