seaweedfs/weed/server/volume_server_handlers_admin.go

63 lines
1.9 KiB
Go
Raw Normal View History

package weed_server
import (
"github.com/seaweedfs/seaweedfs/weed/topology"
"net/http"
"path/filepath"
2018-10-16 12:44:41 +08:00
"github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb"
"github.com/seaweedfs/seaweedfs/weed/stats"
"github.com/seaweedfs/seaweedfs/weed/util"
)
func (vs *VolumeServer) healthzHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Server", "SeaweedFS Volume "+util.VERSION)
volumeInfos := vs.store.VolumeInfos()
for _, vinfo := range volumeInfos {
if len(vinfo.Collection) == 0 {
continue
}
if vinfo.ReplicaPlacement.GetCopyCount() > 1 {
_, err := topology.GetWritableRemoteReplications(vs.store, vs.grpcDialOption, vinfo.Id, vs.GetMaster)
if err != nil {
w.WriteHeader(http.StatusServiceUnavailable)
return
}
}
}
w.WriteHeader(http.StatusOK)
}
func (vs *VolumeServer) statusHandler(w http.ResponseWriter, r *http.Request) {
2020-09-21 07:00:01 +08:00
w.Header().Set("Server", "SeaweedFS Volume "+util.VERSION)
m := make(map[string]interface{})
2020-06-02 15:10:35 +08:00
m["Version"] = util.Version()
var ds []*volume_server_pb.DiskStatus
for _, loc := range vs.store.Locations {
if dir, e := filepath.Abs(loc.Directory); e == nil {
2020-12-14 16:51:57 +08:00
newDiskStatus := stats.NewDiskStatus(dir)
2021-02-14 07:42:42 +08:00
newDiskStatus.DiskType = loc.DiskType.String()
2020-12-14 16:51:57 +08:00
ds = append(ds, newDiskStatus)
}
}
m["DiskStatuses"] = ds
2019-12-03 12:49:50 +08:00
m["Volumes"] = vs.store.VolumeInfos()
writeJsonQuiet(w, r, http.StatusOK, m)
}
func (vs *VolumeServer) statsDiskHandler(w http.ResponseWriter, r *http.Request) {
2020-09-21 07:00:01 +08:00
w.Header().Set("Server", "SeaweedFS Volume "+util.VERSION)
m := make(map[string]interface{})
2020-06-02 15:10:35 +08:00
m["Version"] = util.Version()
var ds []*volume_server_pb.DiskStatus
for _, loc := range vs.store.Locations {
if dir, e := filepath.Abs(loc.Directory); e == nil {
2020-12-14 16:51:57 +08:00
newDiskStatus := stats.NewDiskStatus(dir)
2021-02-14 07:42:42 +08:00
newDiskStatus.DiskType = loc.DiskType.String()
2020-12-14 16:51:57 +08:00
ds = append(ds, newDiskStatus)
}
}
2015-03-20 01:39:22 +08:00
m["DiskStatuses"] = ds
writeJsonQuiet(w, r, http.StatusOK, m)
}