|
@ -5,7 +5,7 @@ import ( |
|
|
"code.google.com/p/weed-fs/go/util" |
|
|
"code.google.com/p/weed-fs/go/util" |
|
|
"encoding/json" |
|
|
"encoding/json" |
|
|
"errors" |
|
|
"errors" |
|
|
"fmt" |
|
|
|
|
|
|
|
|
"log" |
|
|
"net/url" |
|
|
"net/url" |
|
|
"time" |
|
|
"time" |
|
|
) |
|
|
) |
|
@ -14,12 +14,12 @@ func batchVacuumVolumeCheck(vl *VolumeLayout, vid storage.VolumeId, locationlist |
|
|
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())
|
|
|
|
|
|
|
|
|
//log.Println(index, "Check vacuuming", vid, "on", dn.Url())
|
|
|
if e, ret := vacuumVolume_Check(url, vid, garbageThreshold); e != nil { |
|
|
if e, ret := vacuumVolume_Check(url, vid, garbageThreshold); e != nil { |
|
|
//fmt.Println(index, "Error when checking vacuuming", vid, "on", url, e)
|
|
|
|
|
|
|
|
|
//log.Println(index, "Error when checking vacuuming", vid, "on", url, e)
|
|
|
ch <- false |
|
|
ch <- false |
|
|
} else { |
|
|
} else { |
|
|
//fmt.Println(index, "Checked vacuuming", vid, "on", url, "needVacuum", ret)
|
|
|
|
|
|
|
|
|
//log.Println(index, "Checked vacuuming", vid, "on", url, "needVacuum", ret)
|
|
|
ch <- ret |
|
|
ch <- ret |
|
|
} |
|
|
} |
|
|
}(index, dn.Url(), vid) |
|
|
}(index, dn.Url(), vid) |
|
@ -41,12 +41,12 @@ func batchVacuumVolumeCompact(vl *VolumeLayout, vid storage.VolumeId, locationli |
|
|
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, "Start vacuuming", vid, "on", url) |
|
|
|
|
|
|
|
|
log.Println(index, "Start vacuuming", vid, "on", url) |
|
|
if e := vacuumVolume_Compact(url, vid); e != nil { |
|
|
if e := vacuumVolume_Compact(url, vid); e != nil { |
|
|
fmt.Println(index, "Error when vacuuming", vid, "on", url, e) |
|
|
|
|
|
|
|
|
log.Println(index, "Error when vacuuming", vid, "on", url, e) |
|
|
ch <- false |
|
|
ch <- false |
|
|
} else { |
|
|
} else { |
|
|
fmt.Println(index, "Complete vacuuming", vid, "on", url) |
|
|
|
|
|
|
|
|
log.Println(index, "Complete vacuuming", vid, "on", url) |
|
|
ch <- true |
|
|
ch <- true |
|
|
} |
|
|
} |
|
|
}(index, dn.Url(), vid) |
|
|
}(index, dn.Url(), vid) |
|
@ -65,12 +65,12 @@ func batchVacuumVolumeCompact(vl *VolumeLayout, vid storage.VolumeId, locationli |
|
|
func batchVacuumVolumeCommit(vl *VolumeLayout, vid storage.VolumeId, locationlist *VolumeLocationList) bool { |
|
|
func batchVacuumVolumeCommit(vl *VolumeLayout, vid storage.VolumeId, locationlist *VolumeLocationList) bool { |
|
|
isCommitSuccess := true |
|
|
isCommitSuccess := true |
|
|
for _, dn := range locationlist.list { |
|
|
for _, dn := range locationlist.list { |
|
|
fmt.Println("Start Commiting vacuum", vid, "on", dn.Url()) |
|
|
|
|
|
|
|
|
log.Println("Start Commiting vacuum", vid, "on", dn.Url()) |
|
|
if e := vacuumVolume_Commit(dn.Url(), vid); e != nil { |
|
|
if e := vacuumVolume_Commit(dn.Url(), vid); e != nil { |
|
|
fmt.Println("Error when committing vacuum", vid, "on", dn.Url(), e) |
|
|
|
|
|
|
|
|
log.Println("Error when committing vacuum", vid, "on", dn.Url(), e) |
|
|
isCommitSuccess = false |
|
|
isCommitSuccess = false |
|
|
} else { |
|
|
} else { |
|
|
fmt.Println("Complete Commiting vacuum", vid, "on", dn.Url()) |
|
|
|
|
|
|
|
|
log.Println("Complete Commiting vacuum", vid, "on", dn.Url()) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if isCommitSuccess { |
|
|
if isCommitSuccess { |
|
@ -104,7 +104,7 @@ func vacuumVolume_Check(urlLocation string, vid storage.VolumeId, garbageThresho |
|
|
values.Add("garbageThreshold", garbageThreshold) |
|
|
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 { |
|
|
fmt.Println("parameters:", values) |
|
|
|
|
|
|
|
|
log.Println("parameters:", values) |
|
|
return err, false |
|
|
return err, false |
|
|
} |
|
|
} |
|
|
var ret VacuumVolumeResult |
|
|
var ret VacuumVolumeResult |
|
|