2014-04-14 15:13:18 +08:00
|
|
|
package weed_server
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
2014-10-27 02:34:55 +08:00
|
|
|
|
2015-04-17 03:18:06 +08:00
|
|
|
"github.com/chrislusf/seaweedfs/go/glog"
|
2014-04-14 15:13:18 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func (vs *VolumeServer) vacuumVolumeCheckHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
|
err, ret := vs.store.CheckCompactVolume(r.FormValue("volume"), r.FormValue("garbageThreshold"))
|
|
|
|
if err == nil {
|
2015-01-08 16:19:32 +08:00
|
|
|
writeJsonQuiet(w, r, http.StatusOK, map[string]interface{}{"error": "", "result": ret})
|
2014-04-14 15:13:18 +08:00
|
|
|
} else {
|
2015-01-08 16:19:32 +08:00
|
|
|
writeJsonQuiet(w, r, http.StatusInternalServerError, map[string]interface{}{"error": err.Error(), "result": false})
|
2014-04-14 15:13:18 +08:00
|
|
|
}
|
|
|
|
glog.V(2).Infoln("checked compacting volume =", r.FormValue("volume"), "garbageThreshold =", r.FormValue("garbageThreshold"), "vacuum =", ret)
|
|
|
|
}
|
|
|
|
func (vs *VolumeServer) vacuumVolumeCompactHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
|
err := vs.store.CompactVolume(r.FormValue("volume"))
|
|
|
|
if err == nil {
|
2015-01-08 16:19:32 +08:00
|
|
|
writeJsonQuiet(w, r, http.StatusOK, map[string]string{"error": ""})
|
2014-04-14 15:13:18 +08:00
|
|
|
} else {
|
2015-01-08 16:19:32 +08:00
|
|
|
writeJsonError(w, r, http.StatusInternalServerError, err)
|
2014-04-14 15:13:18 +08:00
|
|
|
}
|
|
|
|
glog.V(2).Infoln("compacted volume =", r.FormValue("volume"), ", error =", err)
|
|
|
|
}
|
|
|
|
func (vs *VolumeServer) vacuumVolumeCommitHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
|
err := vs.store.CommitCompactVolume(r.FormValue("volume"))
|
|
|
|
if err == nil {
|
2015-01-08 16:19:32 +08:00
|
|
|
writeJsonQuiet(w, r, http.StatusOK, map[string]string{"error": ""})
|
2014-04-14 15:13:18 +08:00
|
|
|
} else {
|
2015-01-08 16:19:32 +08:00
|
|
|
writeJsonError(w, r, http.StatusInternalServerError, err)
|
2014-04-14 15:13:18 +08:00
|
|
|
}
|
|
|
|
glog.V(2).Infoln("commit compact volume =", r.FormValue("volume"), ", error =", err)
|
|
|
|
}
|