aboutsummaryrefslogtreecommitdiff
path: root/go/topology/topology.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2014-04-21 02:11:10 -0700
committerChris Lu <chris.lu@gmail.com>2014-04-21 02:11:10 -0700
commit1818a2a2da412710f57d58f0228009f782b760af (patch)
treee51f2e816dabcc7ac1ea42118bc9c74469367910 /go/topology/topology.go
parent637469e656c09d6e8d682e90ed0497f64e892f29 (diff)
downloadseaweedfs-1818a2a2da412710f57d58f0228009f782b760af.tar.xz
seaweedfs-1818a2a2da412710f57d58f0228009f782b760af.zip
Change to protocol buffer for volume-join-masster message
Reduced size to about 1/5 of the previous json format message
Diffstat (limited to 'go/topology/topology.go')
-rw-r--r--go/topology/topology.go21
1 files changed, 15 insertions, 6 deletions
diff --git a/go/topology/topology.go b/go/topology/topology.go
index 9db3e78ae..f1daffb53 100644
--- a/go/topology/topology.go
+++ b/go/topology/topology.go
@@ -2,6 +2,7 @@ package topology
import (
"code.google.com/p/weed-fs/go/glog"
+ "code.google.com/p/weed-fs/go/operation"
"code.google.com/p/weed-fs/go/sequence"
"code.google.com/p/weed-fs/go/storage"
"errors"
@@ -143,16 +144,24 @@ func (t *Topology) RegisterVolumeLayout(v storage.VolumeInfo, dn *DataNode) {
t.GetVolumeLayout(v.Collection, v.ReplicaPlacement).RegisterVolume(&v, dn)
}
-func (t *Topology) RegisterVolumes(init bool, volumeInfos []storage.VolumeInfo, ip string, port int, publicUrl string, maxVolumeCount int, maxFileKey uint64, dcName string, rackName string) {
- t.Sequence.SetMax(maxFileKey)
- dcName, rackName = t.configuration.Locate(ip, dcName, rackName)
+func (t *Topology) RegisterVolumes(joinMessage *operation.JoinMessage) {
+ t.Sequence.SetMax(*joinMessage.MaxFileKey)
+ dcName, rackName := t.configuration.Locate(*joinMessage.Ip, *joinMessage.DataCenter, *joinMessage.Rack)
dc := t.GetOrCreateDataCenter(dcName)
rack := dc.GetOrCreateRack(rackName)
- dn := rack.FindDataNode(ip, port)
- if init && dn != nil {
+ dn := rack.FindDataNode(*joinMessage.Ip, int(*joinMessage.Port))
+ if *joinMessage.IsInit && dn != nil {
t.UnRegisterDataNode(dn)
}
- dn = rack.GetOrCreateDataNode(ip, port, publicUrl, maxVolumeCount)
+ dn = rack.GetOrCreateDataNode(*joinMessage.Ip, int(*joinMessage.Port), *joinMessage.PublicUrl, int(*joinMessage.MaxVolumeCount))
+ var volumeInfos []storage.VolumeInfo
+ for _, v := range joinMessage.Volumes {
+ if vi, err := storage.NewVolumeInfo(v); err == nil {
+ volumeInfos = append(volumeInfos, vi)
+ } else {
+ glog.V(0).Infoln("Fail to convert joined volume information:", err.Error())
+ }
+ }
dn.UpdateVolumes(volumeInfos)
for _, v := range volumeInfos {
t.RegisterVolumeLayout(v, dn)