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.

26 lines
686 B

  1. package weed_server
  2. import (
  3. "github.com/chrislusf/seaweedfs/weed/storage/needle"
  4. "net/http"
  5. )
  6. type ClusterStatusResult struct {
  7. IsLeader bool `json:"IsLeader,omitempty"`
  8. Leader string `json:"Leader,omitempty"`
  9. Peers []string `json:"Peers,omitempty"`
  10. MaxVolumeId needle.VolumeId `json:"MaxVolumeId,omitempty"`
  11. }
  12. func (s *RaftServer) StatusHandler(w http.ResponseWriter, r *http.Request) {
  13. ret := ClusterStatusResult{
  14. IsLeader: s.topo.IsLeader(),
  15. Peers: s.Peers(),
  16. MaxVolumeId: s.topo.GetMaxVolumeId(),
  17. }
  18. if leader, e := s.topo.Leader(); e == nil {
  19. ret.Leader = leader
  20. }
  21. writeJsonQuiet(w, r, http.StatusOK, ret)
  22. }