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.

53 lines
2.1 KiB

  1. package weed_server
  2. import (
  3. "net/http"
  4. "strconv"
  5. "github.com/chrislusf/seaweedfs/weed/glog"
  6. )
  7. func (vs *VolumeServer) vacuumVolumeCheckHandler(w http.ResponseWriter, r *http.Request) {
  8. err, ret := vs.store.CheckCompactVolume(r.FormValue("volume"), r.FormValue("garbageThreshold"))
  9. if err == nil {
  10. writeJsonQuiet(w, r, http.StatusOK, map[string]interface{}{"error": "", "result": ret})
  11. } else {
  12. writeJsonQuiet(w, r, http.StatusInternalServerError, map[string]interface{}{"error": err.Error(), "result": false})
  13. }
  14. glog.V(2).Infoln("checked compacting volume =", r.FormValue("volume"), "garbageThreshold =", r.FormValue("garbageThreshold"), "vacuum =", ret)
  15. }
  16. func (vs *VolumeServer) vacuumVolumeCompactHandler(w http.ResponseWriter, r *http.Request) {
  17. var preallocate int64
  18. var err error
  19. if r.FormValue("preallocate") != "" {
  20. preallocate, err = strconv.ParseInt(r.FormValue("preallocate"), 10, 64)
  21. if err != nil {
  22. glog.V(0).Infoln("Failed to parse int64 preallocate = %s: %v", r.FormValue("preallocate"), err)
  23. }
  24. }
  25. err = vs.store.CompactVolume(r.FormValue("volume"), preallocate)
  26. if err == nil {
  27. writeJsonQuiet(w, r, http.StatusOK, map[string]string{"error": ""})
  28. } else {
  29. writeJsonError(w, r, http.StatusInternalServerError, err)
  30. }
  31. glog.V(2).Infoln("compacted volume =", r.FormValue("volume"), ", error =", err)
  32. }
  33. func (vs *VolumeServer) vacuumVolumeCommitHandler(w http.ResponseWriter, r *http.Request) {
  34. err := vs.store.CommitCompactVolume(r.FormValue("volume"))
  35. if err == nil {
  36. writeJsonQuiet(w, r, http.StatusOK, map[string]string{"error": ""})
  37. } else {
  38. writeJsonError(w, r, http.StatusInternalServerError, err)
  39. }
  40. glog.V(2).Infoln("commit compact volume =", r.FormValue("volume"), ", error =", err)
  41. }
  42. func (vs *VolumeServer) vacuumVolumeCleanupHandler(w http.ResponseWriter, r *http.Request) {
  43. err := vs.store.CommitCleanupVolume(r.FormValue("volume"))
  44. if err == nil {
  45. writeJsonQuiet(w, r, http.StatusOK, map[string]string{"error": ""})
  46. } else {
  47. writeJsonError(w, r, http.StatusInternalServerError, err)
  48. }
  49. glog.V(2).Infoln("cleanup compact volume =", r.FormValue("volume"), ", error =", err)
  50. }