|
@ -10,12 +10,12 @@ import ( |
|
|
"time" |
|
|
"time" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
func batchVacuumVolumeCheck(vl *VolumeLayout, vid storage.VolumeId, locationlist *VolumeLocationList) bool { |
|
|
|
|
|
|
|
|
func batchVacuumVolumeCheck(vl *VolumeLayout, vid storage.VolumeId, locationlist *VolumeLocationList, garbageThreshold string) bool { |
|
|
ch := make(chan bool, locationlist.Length()) |
|
|
ch := make(chan bool, locationlist.Length()) |
|
|
for index, dn := range locationlist.list { |
|
|
for index, dn := range locationlist.list { |
|
|
go func(index int, url string, vid storage.VolumeId) { |
|
|
go func(index int, url string, vid storage.VolumeId) { |
|
|
//fmt.Println(index, "Check vacuuming", vid, "on", dn.Url())
|
|
|
//fmt.Println(index, "Check vacuuming", vid, "on", dn.Url())
|
|
|
if e, ret := vacuumVolume_Check(url, vid); e != nil { |
|
|
|
|
|
|
|
|
if e, ret := vacuumVolume_Check(url, vid, garbageThreshold); e != nil { |
|
|
//fmt.Println(index, "Error when checking vacuuming", vid, "on", url, e)
|
|
|
//fmt.Println(index, "Error when checking vacuuming", vid, "on", url, e)
|
|
|
ch <- false |
|
|
ch <- false |
|
|
} else { |
|
|
} else { |
|
@ -78,11 +78,11 @@ func batchVacuumVolumeCommit(vl *VolumeLayout, vid storage.VolumeId, locationlis |
|
|
} |
|
|
} |
|
|
return isCommitSuccess |
|
|
return isCommitSuccess |
|
|
} |
|
|
} |
|
|
func (t *Topology) Vacuum() int { |
|
|
|
|
|
|
|
|
func (t *Topology) Vacuum(garbageThreshold string) int { |
|
|
for _, vl := range t.replicaType2VolumeLayout { |
|
|
for _, vl := range t.replicaType2VolumeLayout { |
|
|
if vl != nil { |
|
|
if vl != nil { |
|
|
for vid, locationlist := range vl.vid2location { |
|
|
for vid, locationlist := range vl.vid2location { |
|
|
if batchVacuumVolumeCheck(vl, vid, locationlist) { |
|
|
|
|
|
|
|
|
if batchVacuumVolumeCheck(vl, vid, locationlist, garbageThreshold) { |
|
|
if batchVacuumVolumeCompact(vl, vid, locationlist) { |
|
|
if batchVacuumVolumeCompact(vl, vid, locationlist) { |
|
|
batchVacuumVolumeCommit(vl, vid, locationlist) |
|
|
batchVacuumVolumeCommit(vl, vid, locationlist) |
|
|
} |
|
|
} |
|
@ -98,10 +98,10 @@ type VacuumVolumeResult struct { |
|
|
Error string |
|
|
Error string |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func vacuumVolume_Check(urlLocation string, vid storage.VolumeId) (error, bool) { |
|
|
|
|
|
|
|
|
func vacuumVolume_Check(urlLocation string, vid storage.VolumeId, garbageThreshold string) (error, bool) { |
|
|
values := make(url.Values) |
|
|
values := make(url.Values) |
|
|
values.Add("volume", vid.String()) |
|
|
values.Add("volume", vid.String()) |
|
|
values.Add("garbageThreshold", "0.3") |
|
|
|
|
|
|
|
|
values.Add("garbageThreshold", garbageThreshold) |
|
|
jsonBlob, err := util.Post("http://"+urlLocation+"/admin/vacuum_volume_check", values) |
|
|
jsonBlob, err := util.Post("http://"+urlLocation+"/admin/vacuum_volume_check", values) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return err, false |
|
|
return err, false |
|
|