mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
fix when volume growth are partial successful in automatic mode
This commit is contained in:
parent
3ae2eabf09
commit
63ebafa113
|
@ -32,22 +32,34 @@ func NewDefaultVolumeGrowth() *VolumeGrowth {
|
||||||
return &VolumeGrowth{copy1factor: 7, copy2factor: 6, copy3factor: 3}
|
return &VolumeGrowth{copy1factor: 7, copy2factor: 6, copy3factor: 3}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (vg *VolumeGrowth) GrowByType(repType storage.ReplicationType, dataCenter string, topo *topology.Topology) (int, error) {
|
func (vg *VolumeGrowth) AutomaticGrowByType(repType storage.ReplicationType, dataCenter string, topo *topology.Topology) (count int, err error) {
|
||||||
|
factor := 1
|
||||||
switch repType {
|
switch repType {
|
||||||
case storage.Copy000:
|
case storage.Copy000:
|
||||||
return vg.GrowByCountAndType(vg.copy1factor, repType, dataCenter, topo)
|
factor = 1
|
||||||
|
count, err = vg.GrowByCountAndType(vg.copy1factor, repType, dataCenter, topo)
|
||||||
case storage.Copy001:
|
case storage.Copy001:
|
||||||
return vg.GrowByCountAndType(vg.copy2factor, repType, dataCenter, topo)
|
factor = 2
|
||||||
|
count, err = vg.GrowByCountAndType(vg.copy2factor, repType, dataCenter, topo)
|
||||||
case storage.Copy010:
|
case storage.Copy010:
|
||||||
return vg.GrowByCountAndType(vg.copy2factor, repType, dataCenter, topo)
|
factor = 2
|
||||||
|
count, err = vg.GrowByCountAndType(vg.copy2factor, repType, dataCenter, topo)
|
||||||
case storage.Copy100:
|
case storage.Copy100:
|
||||||
return vg.GrowByCountAndType(vg.copy2factor, repType, dataCenter, topo)
|
factor = 2
|
||||||
|
count, err = vg.GrowByCountAndType(vg.copy2factor, repType, dataCenter, topo)
|
||||||
case storage.Copy110:
|
case storage.Copy110:
|
||||||
return vg.GrowByCountAndType(vg.copy3factor, repType, dataCenter, topo)
|
factor = 3
|
||||||
|
count, err = vg.GrowByCountAndType(vg.copy3factor, repType, dataCenter, topo)
|
||||||
case storage.Copy200:
|
case storage.Copy200:
|
||||||
return vg.GrowByCountAndType(vg.copy3factor, repType, dataCenter, topo)
|
factor = 3
|
||||||
|
count, err = vg.GrowByCountAndType(vg.copy3factor, repType, dataCenter, topo)
|
||||||
|
default:
|
||||||
|
err = errors.New("Unknown Replication Type!")
|
||||||
}
|
}
|
||||||
return 0, errors.New("Unknown Replication Type!")
|
if count > 0 && count%factor == 0 {
|
||||||
|
return count, nil
|
||||||
|
}
|
||||||
|
return count, err
|
||||||
}
|
}
|
||||||
func (vg *VolumeGrowth) GrowByCountAndType(count int, repType storage.ReplicationType, dataCenter string, topo *topology.Topology) (counter int, err error) {
|
func (vg *VolumeGrowth) GrowByCountAndType(count int, repType storage.ReplicationType, dataCenter string, topo *topology.Topology) (counter int, err error) {
|
||||||
vg.accessLock.Lock()
|
vg.accessLock.Lock()
|
||||||
|
|
|
@ -91,7 +91,7 @@ func dirAssignHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
writeJsonQuiet(w, r, map[string]string{"error": "No free volumes left!"})
|
writeJsonQuiet(w, r, map[string]string{"error": "No free volumes left!"})
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
if _, err = vg.GrowByType(rt, dataCenter, topo); err != nil {
|
if _, err = vg.AutomaticGrowByType(rt, dataCenter, topo); err != nil {
|
||||||
writeJsonQuiet(w, r, map[string]string{"error": "Cannot grow volume group! " + err.Error()})
|
writeJsonQuiet(w, r, map[string]string{"error": "Cannot grow volume group! " + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue