You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
944 B
43 lines
944 B
package topology
|
|
|
|
import (
|
|
_ "fmt"
|
|
"pkg/storage"
|
|
)
|
|
|
|
type DataNode struct {
|
|
NodeImpl
|
|
volumes map[storage.VolumeId]*storage.VolumeInfo
|
|
Ip string
|
|
Port int
|
|
PublicUrl string
|
|
lastSeen int64 // unix time in seconds
|
|
}
|
|
|
|
func NewDataNode(id string) *DataNode {
|
|
s := &DataNode{}
|
|
s.id = NodeId(id)
|
|
s.nodeType = "DataNode"
|
|
s.volumes = make(map[storage.VolumeId]*storage.VolumeInfo)
|
|
return s
|
|
}
|
|
func (dn *DataNode) CreateOneVolume(r int, vid storage.VolumeId) storage.VolumeId {
|
|
dn.AddVolume(&storage.VolumeInfo{Id: vid})
|
|
return vid
|
|
}
|
|
func (dn *DataNode) AddVolume(v *storage.VolumeInfo) {
|
|
dn.volumes[v.Id] = v
|
|
dn.UpAdjustActiveVolumeCountDelta(1)
|
|
dn.UpAdjustMaxVolumeId(v.Id)
|
|
}
|
|
func (dn *DataNode) GetTopology() *Topology {
|
|
p := dn.parent
|
|
for p.Parent()!=nil{
|
|
p = p.Parent()
|
|
}
|
|
t := p.(*Topology)
|
|
return t
|
|
}
|
|
func (dn *DataNode) MatchLocation(ip string, port int) bool {
|
|
return dn.Ip == ip && dn.Port == port
|
|
}
|