mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
added proper log messages
This commit is contained in:
parent
2add211a86
commit
2deee3f47c
|
@ -58,13 +58,13 @@ func assignVolumeHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
debug("assign volume =", r.FormValue("volume"), ", replicationType =", r.FormValue("replicationType"), ", error =", err)
|
debug("assign volume =", r.FormValue("volume"), ", replicationType =", r.FormValue("replicationType"), ", error =", err)
|
||||||
}
|
}
|
||||||
func vacuumVolumeCheckHandler(w http.ResponseWriter, r *http.Request) {
|
func vacuumVolumeCheckHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
err, ret := store.CheckCompactVolume(r.FormValue("volume"), r.FormValue("garbageThreshold"))
|
err, ret := store.CheckCompactVolume(r.FormValue("volume"), r.FormValue("garbageThreshold"))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
writeJson(w, r, map[string]interface{}{"error": "", "result": ret})
|
writeJson(w, r, map[string]interface{}{"error": "", "result": ret})
|
||||||
} else {
|
} else {
|
||||||
writeJson(w, r, map[string]interface{}{"error": err.Error(), "result": false})
|
writeJson(w, r, map[string]interface{}{"error": err.Error(), "result": false})
|
||||||
}
|
}
|
||||||
debug("checked compacting volume =", r.FormValue("volume"), "garbageThreshold =", r.FormValue("garbageThreshold"), "vacuum =", ret)
|
debug("checked compacting volume =", r.FormValue("volume"), "garbageThreshold =", r.FormValue("garbageThreshold"), "vacuum =", ret)
|
||||||
}
|
}
|
||||||
func vacuumVolumeCompactHandler(w http.ResponseWriter, r *http.Request) {
|
func vacuumVolumeCompactHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
err := store.CompactVolume(r.FormValue("volume"))
|
err := store.CompactVolume(r.FormValue("volume"))
|
||||||
|
@ -157,9 +157,9 @@ func PostHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
errorStatus := ""
|
errorStatus := ""
|
||||||
needToReplicate := !store.HasVolume(volumeId)
|
needToReplicate := !store.HasVolume(volumeId)
|
||||||
if ret > 0 {
|
if ret > 0 {
|
||||||
needToReplicate = needToReplicate || store.GetVolume(volumeId).NeedToReplicate()
|
needToReplicate = needToReplicate || store.GetVolume(volumeId).NeedToReplicate()
|
||||||
}else{
|
} else {
|
||||||
errorStatus = "Failed to write to local disk"
|
errorStatus = "Failed to write to local disk"
|
||||||
}
|
}
|
||||||
if !needToReplicate && ret > 0 {
|
if !needToReplicate && ret > 0 {
|
||||||
needToReplicate = store.GetVolume(volumeId).NeedToReplicate()
|
needToReplicate = store.GetVolume(volumeId).NeedToReplicate()
|
||||||
|
@ -311,13 +311,24 @@ func runVolume(cmd *Command, args []string) bool {
|
||||||
http.HandleFunc("/", storeHandler)
|
http.HandleFunc("/", storeHandler)
|
||||||
http.HandleFunc("/status", statusHandler)
|
http.HandleFunc("/status", statusHandler)
|
||||||
http.HandleFunc("/admin/assign_volume", assignVolumeHandler)
|
http.HandleFunc("/admin/assign_volume", assignVolumeHandler)
|
||||||
http.HandleFunc("/admin/vacuum_volume_check", vacuumVolumeCheckHandler)
|
http.HandleFunc("/admin/vacuum_volume_check", vacuumVolumeCheckHandler)
|
||||||
http.HandleFunc("/admin/vacuum_volume_compact", vacuumVolumeCompactHandler)
|
http.HandleFunc("/admin/vacuum_volume_compact", vacuumVolumeCompactHandler)
|
||||||
http.HandleFunc("/admin/vacuum_volume_commit", vacuumVolumeCommitHandler)
|
http.HandleFunc("/admin/vacuum_volume_commit", vacuumVolumeCommitHandler)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
connected := true
|
||||||
for {
|
for {
|
||||||
store.Join(*masterNode)
|
err := store.Join(*masterNode)
|
||||||
|
if err == nil {
|
||||||
|
if !connected {
|
||||||
|
connected = true
|
||||||
|
log.Println("Reconnected with master")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if connected {
|
||||||
|
connected = false
|
||||||
|
}
|
||||||
|
}
|
||||||
time.Sleep(time.Duration(float32(*vpulse*1e3)*(1+rand.Float32())) * time.Millisecond)
|
time.Sleep(time.Duration(float32(*vpulse*1e3)*(1+rand.Float32())) * time.Millisecond)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
|
@ -104,6 +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)
|
||||||
return err, false
|
return err, false
|
||||||
}
|
}
|
||||||
var ret VacuumVolumeResult
|
var ret VacuumVolumeResult
|
||||||
|
|
Loading…
Reference in a new issue