diff options
| author | Chris Lu <chris.lu@gmail.com> | 2014-04-13 01:29:52 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2014-04-13 01:29:52 -0700 |
| commit | f7f582ec8698dc43f1a2289dbd06fe0cade7468f (patch) | |
| tree | 1b788ffd9b33ef6807e6aaea3bc24b08cbf10fa8 /go/topology/data_node.go | |
| parent | 008aee0dc1932f75c86e52893044d9cd953ef405 (diff) | |
| download | seaweedfs-f7f582ec8698dc43f1a2289dbd06fe0cade7468f.tar.xz seaweedfs-f7f582ec8698dc43f1a2289dbd06fe0cade7468f.zip | |
1. refactoring, merge "replication" logic into "topology" package
2. when growing volumes, additional preferred "rack" and "dataNode"
paraemters are also provided. Previously only "dataCenter" paraemter is
provided.
Diffstat (limited to 'go/topology/data_node.go')
| -rw-r--r-- | go/topology/data_node.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/go/topology/data_node.go b/go/topology/data_node.go index 0cedb5cfe..ae80e08bb 100644 --- a/go/topology/data_node.go +++ b/go/topology/data_node.go @@ -24,6 +24,7 @@ func NewDataNode(id string) *DataNode { s.NodeImpl.value = s return s } + func (dn *DataNode) AddOrUpdateVolume(v storage.VolumeInfo) { if _, ok := dn.volumes[v.Id]; !ok { dn.volumes[v.Id] = v @@ -36,6 +37,7 @@ func (dn *DataNode) AddOrUpdateVolume(v storage.VolumeInfo) { dn.volumes[v.Id] = v } } + func (dn *DataNode) UpdateVolumes(actualVolumes []storage.VolumeInfo) { actualVolumeMap := make(map[storage.VolumeId]storage.VolumeInfo) for _, v := range actualVolumes { @@ -53,9 +55,15 @@ func (dn *DataNode) UpdateVolumes(actualVolumes []storage.VolumeInfo) { dn.AddOrUpdateVolume(v) } } + func (dn *DataNode) GetDataCenter() *DataCenter { return dn.Parent().Parent().(*NodeImpl).value.(*DataCenter) } + +func (dn *DataNode) GetRack() *Rack { + return dn.Parent().(*NodeImpl).value.(*Rack) +} + func (dn *DataNode) GetTopology() *Topology { p := dn.Parent() for p.Parent() != nil { @@ -64,9 +72,11 @@ func (dn *DataNode) GetTopology() *Topology { t := p.(*Topology) return t } + func (dn *DataNode) MatchLocation(ip string, port int) bool { return dn.Ip == ip && dn.Port == port } + func (dn *DataNode) Url() string { return dn.Ip + ":" + strconv.Itoa(dn.Port) } |
