Enhance: add a http request to get cluster persist configuration

Signed-off-by: liubingxing <liubbingxing@gmail.com>
This commit is contained in:
liubingxing 2023-04-13 09:47:29 +08:00 committed by leonrayang
parent 7eab0dc9f0
commit 9dd4398a90
3 changed files with 23 additions and 1 deletions

View File

@ -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))
}
}

View File

@ -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).

View File

@ -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"