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.

54 lines
1.9 KiB

  1. package weed_server
  2. import (
  3. "net/http"
  4. "path/filepath"
  5. "github.com/chrislusf/seaweedfs/go/glog"
  6. "github.com/chrislusf/seaweedfs/go/stats"
  7. "github.com/chrislusf/seaweedfs/go/util"
  8. )
  9. func (vs *VolumeServer) statusHandler(w http.ResponseWriter, r *http.Request) {
  10. m := make(map[string]interface{})
  11. m["Version"] = util.VERSION
  12. m["Volumes"] = vs.store.Status()
  13. writeJsonQuiet(w, r, http.StatusOK, m)
  14. }
  15. func (vs *VolumeServer) assignVolumeHandler(w http.ResponseWriter, r *http.Request) {
  16. err := vs.store.AddVolume(r.FormValue("volume"), r.FormValue("collection"), vs.needleMapKind, r.FormValue("replication"), r.FormValue("ttl"))
  17. if err == nil {
  18. writeJsonQuiet(w, r, http.StatusAccepted, map[string]string{"error": ""})
  19. } else {
  20. writeJsonError(w, r, http.StatusNotAcceptable, err)
  21. }
  22. glog.V(2).Infoln("assign volume =", r.FormValue("volume"), ", collection =", r.FormValue("collection"), ", replication =", r.FormValue("replication"), ", error =", err)
  23. }
  24. func (vs *VolumeServer) deleteCollectionHandler(w http.ResponseWriter, r *http.Request) {
  25. if "benchmark" != r.FormValue("collection") {
  26. glog.V(0).Infoln("deleting collection =", r.FormValue("collection"), "!!!")
  27. return
  28. }
  29. err := vs.store.DeleteCollection(r.FormValue("collection"))
  30. if err == nil {
  31. writeJsonQuiet(w, r, http.StatusOK, map[string]string{"error": ""})
  32. } else {
  33. writeJsonError(w, r, http.StatusInternalServerError, err)
  34. }
  35. glog.V(2).Infoln("deleting collection =", r.FormValue("collection"), ", error =", err)
  36. }
  37. func (vs *VolumeServer) statsDiskHandler(w http.ResponseWriter, r *http.Request) {
  38. m := make(map[string]interface{})
  39. m["Version"] = util.VERSION
  40. var ds []*stats.DiskStatus
  41. for _, loc := range vs.store.Locations {
  42. if dir, e := filepath.Abs(loc.Directory); e == nil {
  43. ds = append(ds, stats.NewDiskStatus(dir))
  44. }
  45. }
  46. m["DiskStatuses"] = ds
  47. writeJsonQuiet(w, r, http.StatusOK, m)
  48. }