From 4a874031746f2c94fbe455a8c933c83ce1d7005e Mon Sep 17 00:00:00 2001 From: Ryan Leung Date: Wed, 12 Sep 2018 15:31:15 +0800 Subject: [PATCH] fix hot store command (#1244) --- server/handler.go | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/server/handler.go b/server/handler.go index eeea095f92a..b65d1f0d32c 100644 --- a/server/handler.go +++ b/server/handler.go @@ -115,22 +115,38 @@ func (h *Handler) GetHotReadRegions() *core.StoreHotRegionInfos { // GetHotBytesWriteStores gets all hot write stores stats. func (h *Handler) GetHotBytesWriteStores() map[uint64]uint64 { - return h.s.cluster.cachedCluster.getStoresBytesWriteStat() + cluster := h.s.GetRaftCluster() + if cluster == nil { + return nil + } + return cluster.cachedCluster.getStoresBytesWriteStat() } // GetHotBytesReadStores gets all hot write stores stats. func (h *Handler) GetHotBytesReadStores() map[uint64]uint64 { - return h.s.cluster.cachedCluster.getStoresBytesReadStat() + cluster := h.s.GetRaftCluster() + if cluster == nil { + return nil + } + return cluster.cachedCluster.getStoresBytesReadStat() } // GetHotKeysWriteStores gets all hot write stores stats. func (h *Handler) GetHotKeysWriteStores() map[uint64]uint64 { - return h.s.cluster.cachedCluster.getStoresKeysWriteStat() + cluster := h.s.GetRaftCluster() + if cluster == nil { + return nil + } + return cluster.cachedCluster.getStoresKeysWriteStat() } // GetHotKeysReadStores gets all hot write stores stats. func (h *Handler) GetHotKeysReadStores() map[uint64]uint64 { - return h.s.cluster.cachedCluster.getStoresKeysReadStat() + cluster := h.s.GetRaftCluster() + if cluster == nil { + return nil + } + return cluster.cachedCluster.getStoresKeysReadStat() } // AddScheduler adds a scheduler.