You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.4 KiB

  1. package weed_server
  2. import (
  3. "net/http"
  4. "github.com/chrislusf/weed-fs/go/glog"
  5. )
  6. func (vs *VolumeServer) vacuumVolumeCheckHandler(w http.ResponseWriter, r *http.Request) {
  7. err, ret := vs.store.CheckCompactVolume(r.FormValue("volume"), r.FormValue("garbageThreshold"))
  8. if err == nil {
  9. writeJsonQuiet(w, r, map[string]interface{}{"error": "", "result": ret})
  10. } else {
  11. writeJsonQuiet(w, r, map[string]interface{}{"error": err.Error(), "result": false})
  12. }
  13. glog.V(2).Infoln("checked compacting volume =", r.FormValue("volume"), "garbageThreshold =", r.FormValue("garbageThreshold"), "vacuum =", ret)
  14. }
  15. func (vs *VolumeServer) vacuumVolumeCompactHandler(w http.ResponseWriter, r *http.Request) {
  16. err := vs.store.CompactVolume(r.FormValue("volume"))
  17. if err == nil {
  18. writeJsonQuiet(w, r, map[string]string{"error": ""})
  19. } else {
  20. writeJsonQuiet(w, r, map[string]string{"error": err.Error()})
  21. }
  22. glog.V(2).Infoln("compacted volume =", r.FormValue("volume"), ", error =", err)
  23. }
  24. func (vs *VolumeServer) vacuumVolumeCommitHandler(w http.ResponseWriter, r *http.Request) {
  25. err := vs.store.CommitCompactVolume(r.FormValue("volume"))
  26. if err == nil {
  27. writeJsonQuiet(w, r, map[string]interface{}{"error": ""})
  28. } else {
  29. writeJsonQuiet(w, r, map[string]string{"error": err.Error()})
  30. }
  31. glog.V(2).Infoln("commit compact volume =", r.FormValue("volume"), ", error =", err)
  32. }