1
0
Fork 0
mirror of https://github.com/chrislusf/seaweedfs synced 2024-07-02 15:16:51 +02:00

assign fileId according to DataNode with empty DataCenter and Rack

This commit is contained in:
banjiaojuhao 2021-12-21 17:28:33 +08:00
parent 7227cfddf5
commit dda6b90d25

View file

@ -281,7 +281,7 @@ func (vl *VolumeLayout) PickForWrite(count uint64, option *VolumeGrowOption) (*n
//glog.V(0).Infoln("No more writable volumes!") //glog.V(0).Infoln("No more writable volumes!")
return nil, 0, nil, errors.New("No more writable volumes!") return nil, 0, nil, errors.New("No more writable volumes!")
} }
if option.DataCenter == "" { if option.DataCenter == "" && option.Rack == "" && option.DataNode == "" {
vid := vl.writables[rand.Intn(lenWriters)] vid := vl.writables[rand.Intn(lenWriters)]
locationList := vl.vid2location[vid] locationList := vl.vid2location[vid]
if locationList != nil { if locationList != nil {
@ -295,7 +295,9 @@ func (vl *VolumeLayout) PickForWrite(count uint64, option *VolumeGrowOption) (*n
for _, v := range vl.writables { for _, v := range vl.writables {
volumeLocationList := vl.vid2location[v] volumeLocationList := vl.vid2location[v]
for _, dn := range volumeLocationList.list { for _, dn := range volumeLocationList.list {
if dn.GetDataCenter().Id() == NodeId(option.DataCenter) { if option.DataCenter != "" && dn.GetDataCenter().Id() != NodeId(option.DataCenter) {
continue
}
if option.Rack != "" && dn.GetRack().Id() != NodeId(option.Rack) { if option.Rack != "" && dn.GetRack().Id() != NodeId(option.Rack) {
continue continue
} }
@ -308,7 +310,6 @@ func (vl *VolumeLayout) PickForWrite(count uint64, option *VolumeGrowOption) (*n
} }
} }
} }
}
return &vid, count, locationList, nil return &vid, count, locationList, nil
} }