mirror of
https://github.com/cubefs/cubefs.git
synced 2026-08-02 02:00:56 +00:00
Enhance: add a http request to get cluster persist configuration
Signed-off-by: liubingxing <liubbingxing@gmail.com>
This commit is contained in:
parent
7eab0dc9f0
commit
9dd4398a90
@ -4244,3 +4244,21 @@ func (m *Server) getFileStats(w http.ResponseWriter, r *http.Request) {
|
||||
sendOkReply(w, r, newSuccessHTTPReply(fmt.Sprintf(
|
||||
"getFileStats enable value [%v]", m.cluster.fileStatsEnable)))
|
||||
}
|
||||
|
||||
func (m *Server) GetClusterValue(w http.ResponseWriter, r *http.Request) {
|
||||
result, err := m.cluster.fsm.store.SeekForPrefix([]byte(clusterPrefix))
|
||||
if err != nil {
|
||||
log.LogErrorf("action[GetClusterValue],err:%v", err.Error())
|
||||
sendErrReply(w, r, newErrHTTPReply(proto.ErrInternalError))
|
||||
return
|
||||
}
|
||||
for _, value := range result {
|
||||
cv := &clusterValue{}
|
||||
if err = json.Unmarshal(value, cv); err != nil {
|
||||
log.LogErrorf("action[GetClusterValue], unmarshal err:%v", err.Error())
|
||||
sendErrReply(w, r, newErrHTTPReply(proto.ErrUnmarshalData))
|
||||
return
|
||||
}
|
||||
sendOkReply(w, r, newSuccessHTTPReply(cv))
|
||||
}
|
||||
}
|
||||
|
||||
@ -196,6 +196,10 @@ func (m *Server) registerAPIRoutes(router *mux.Router) {
|
||||
Path(proto.AdminGetFileStats).
|
||||
HandlerFunc(m.getFileStats)
|
||||
|
||||
router.NewRoute().Methods(http.MethodGet, http.MethodPost).
|
||||
Path(proto.AdminGetClusterValue).
|
||||
HandlerFunc(m.GetClusterValue)
|
||||
|
||||
// volume management APIs
|
||||
router.NewRoute().Methods(http.MethodGet, http.MethodPost).
|
||||
Path(proto.AdminCreateVol).
|
||||
|
||||
@ -67,7 +67,7 @@ const (
|
||||
AdminQueryDecommissionToken = "/admin/queryDecommissionToken"
|
||||
AdminSetFileStats = "/admin/setFileStatsEnable"
|
||||
AdminGetFileStats = "/admin/getFileStatsEnable"
|
||||
|
||||
AdminGetClusterValue = "/admin/getClusterValue"
|
||||
//graphql master api
|
||||
AdminClusterAPI = "/api/cluster"
|
||||
AdminUserAPI = "/api/user"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user