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.

27 lines
732 B

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