raft_server_handlers.go 686 B

1234567891011121314151617181920212223242526
  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. }