From 622297f1a7dfec9eb972bcbdfc8f38cb1dc2bf37 Mon Sep 17 00:00:00 2001 From: Konstantin Lebedev <9497591+kmlebedev@users.noreply.github.com> Date: Mon, 4 Apr 2022 19:16:06 +0500 Subject: [PATCH] add stats raft handler --- weed/command/master.go | 2 +- weed/server/raft_server_handlers.go | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/weed/command/master.go b/weed/command/master.go index bbf9b1de2..e7113cd3e 100644 --- a/weed/command/master.go +++ b/weed/command/master.go @@ -177,7 +177,7 @@ func startMaster(masterOption MasterOptions, masterWhiteList []string) { ms.SetRaftServer(raftServer) r.HandleFunc("/cluster/status", raftServer.StatusHandler).Methods("GET") if *m.raftHashicorp { - //r.HandleFunc("/raft/stats", raftServer.).Methods("GET") + r.HandleFunc("/raft/stats", raftServer.StatsRaftHandler).Methods("GET") } // starting grpc server grpcPort := *masterOption.portGrpc diff --git a/weed/server/raft_server_handlers.go b/weed/server/raft_server_handlers.go index 7e58f1e92..cc3e6e37f 100644 --- a/weed/server/raft_server_handlers.go +++ b/weed/server/raft_server_handlers.go @@ -25,3 +25,11 @@ func (s *RaftServer) StatusHandler(w http.ResponseWriter, r *http.Request) { } writeJsonQuiet(w, r, http.StatusOK, ret) } + +func (s *RaftServer) StatsRaftHandler(w http.ResponseWriter, r *http.Request) { + if s.RaftHashicorp == nil { + writeJsonQuiet(w, r, http.StatusNotFound, nil) + return + } + writeJsonQuiet(w, r, http.StatusOK, s.RaftHashicorp.Stats()) +}