2019-03-07 04:10:45 +08:00
|
|
|
package weed_server
|
|
|
|
|
|
|
|
import (
|
2020-10-05 00:56:17 +08:00
|
|
|
"github.com/chrislusf/seaweedfs/weed/storage/needle"
|
2019-03-07 04:10:45 +08:00
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
|
|
|
type ClusterStatusResult struct {
|
2020-10-05 00:56:17 +08:00
|
|
|
IsLeader bool `json:"IsLeader,omitempty"`
|
|
|
|
Leader string `json:"Leader,omitempty"`
|
|
|
|
Peers []string `json:"Peers,omitempty"`
|
|
|
|
MaxVolumeId needle.VolumeId `json:"MaxVolumeId,omitempty"`
|
2019-03-07 04:10:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *RaftServer) StatusHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
|
ret := ClusterStatusResult{
|
2020-10-05 00:56:17 +08:00
|
|
|
IsLeader: s.topo.IsLeader(),
|
|
|
|
Peers: s.Peers(),
|
|
|
|
MaxVolumeId: s.topo.GetMaxVolumeId(),
|
2019-03-07 04:10:45 +08:00
|
|
|
}
|
2020-10-05 00:56:17 +08:00
|
|
|
|
2019-03-07 04:10:45 +08:00
|
|
|
if leader, e := s.topo.Leader(); e == nil {
|
|
|
|
ret.Leader = leader
|
|
|
|
}
|
|
|
|
writeJsonQuiet(w, r, http.StatusOK, ret)
|
|
|
|
}
|