mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
Merge pull request #2527 from banjiaojuhao/master-assign-by-datanode
This commit is contained in:
commit
b0665a15f4
|
@ -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,17 +295,18 @@ 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) {
|
||||||
if option.Rack != "" && dn.GetRack().Id() != NodeId(option.Rack) {
|
continue
|
||||||
continue
|
}
|
||||||
}
|
if option.Rack != "" && dn.GetRack().Id() != NodeId(option.Rack) {
|
||||||
if option.DataNode != "" && dn.Id() != NodeId(option.DataNode) {
|
continue
|
||||||
continue
|
}
|
||||||
}
|
if option.DataNode != "" && dn.Id() != NodeId(option.DataNode) {
|
||||||
counter++
|
continue
|
||||||
if rand.Intn(counter) < 1 {
|
}
|
||||||
vid, locationList = v, volumeLocationList.Copy()
|
counter++
|
||||||
}
|
if rand.Intn(counter) < 1 {
|
||||||
|
vid, locationList = v, volumeLocationList.Copy()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue