mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
send initial list of volume location
This commit is contained in:
parent
a12c7b86b0
commit
e8d4be579d
|
@ -143,6 +143,12 @@ func (ms *MasterServer) KeepConnected(stream master_pb.Seaweed_KeepConnectedServ
|
|||
ms.clientChansLock.Unlock()
|
||||
}()
|
||||
|
||||
for _, message := range ms.Topo.ToVolumeLocations() {
|
||||
if err := stream.Send(message); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
go func() {
|
||||
for {
|
||||
_, err := stream.Recv()
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package topology
|
||||
|
||||
import "github.com/chrislusf/seaweedfs/weed/pb/master_pb"
|
||||
|
||||
func (t *Topology) ToMap() interface{} {
|
||||
m := make(map[string]interface{})
|
||||
m["Max"] = t.GetMaxVolumeCount()
|
||||
|
@ -51,3 +53,24 @@ func (t *Topology) ToVolumeMap() interface{} {
|
|||
m["DataCenters"] = dcs
|
||||
return m
|
||||
}
|
||||
|
||||
func (t *Topology) ToVolumeLocations() (volumeLocations []*master_pb.VolumeLocation) {
|
||||
for _, c := range t.Children() {
|
||||
dc := c.(*DataCenter)
|
||||
for _, r := range dc.Children() {
|
||||
rack := r.(*Rack)
|
||||
for _, d := range rack.Children() {
|
||||
dn := d.(*DataNode)
|
||||
volumeLocation := &master_pb.VolumeLocation{
|
||||
Url: dn.Url(),
|
||||
PublicUrl: dn.PublicUrl,
|
||||
}
|
||||
for _, v := range dn.GetVolumes() {
|
||||
volumeLocation.NewVids = append(volumeLocation.NewVids, uint32(v.Id))
|
||||
}
|
||||
volumeLocations = append(volumeLocations, volumeLocation)
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue