filer prefer volume server in same data center (#3405)
* initial prefer same data center https://github.com/seaweedfs/seaweedfs/issues/3404 * GetDataCenter * prefer same data center for ReplicationSource * GetDataCenterId * remove glog
This commit is contained in:
committed by
GitHub
parent
28a1f42962
commit
4d08393b7c
@@ -192,6 +192,13 @@ func (dn *DataNode) GetDataCenter() *DataCenter {
|
||||
return dcValue.(*DataCenter)
|
||||
}
|
||||
|
||||
func (dn *DataNode) GetDataCenterId() string {
|
||||
if dc := dn.GetDataCenter(); dc != nil {
|
||||
return string(dc.Id())
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (dn *DataNode) GetRack() *Rack {
|
||||
return dn.Parent().(*NodeImpl).value.(*Rack)
|
||||
}
|
||||
|
||||
@@ -76,8 +76,9 @@ func (t *Topology) ToVolumeLocations() (volumeLocations []*master_pb.VolumeLocat
|
||||
for _, d := range rack.Children() {
|
||||
dn := d.(*DataNode)
|
||||
volumeLocation := &master_pb.VolumeLocation{
|
||||
Url: dn.Url(),
|
||||
PublicUrl: dn.PublicUrl,
|
||||
Url: dn.Url(),
|
||||
PublicUrl: dn.PublicUrl,
|
||||
DataCenter: dn.GetDataCenterId(),
|
||||
}
|
||||
for _, v := range dn.GetVolumes() {
|
||||
volumeLocation.NewVids = append(volumeLocation.NewVids, uint32(v.Id))
|
||||
|
||||
@@ -115,9 +115,10 @@ func (vg *VolumeGrowth) findAndGrow(grpcDialOption grpc.DialOption, topo *Topolo
|
||||
if err = vg.grow(grpcDialOption, topo, vid, option, servers...); err == nil {
|
||||
for _, server := range servers {
|
||||
result = append(result, &master_pb.VolumeLocation{
|
||||
Url: server.Url(),
|
||||
PublicUrl: server.PublicUrl,
|
||||
NewVids: []uint32{uint32(vid)},
|
||||
Url: server.Url(),
|
||||
PublicUrl: server.PublicUrl,
|
||||
DataCenter: server.GetDataCenterId(),
|
||||
NewVids: []uint32{uint32(vid)},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user