Skip to content

Commit 474b2aa

Browse files
authored
Merge branch 'master' into disksing/placement-cansync
2 parents 2f6f6fd + fa92039 commit 474b2aa

File tree

36 files changed

+882
-696
lines changed

36 files changed

+882
-696
lines changed

client/go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ require (
3333
github.com/prometheus/procfs v0.6.0 // indirect
3434
go.uber.org/atomic v1.10.0 // indirect
3535
go.uber.org/multierr v1.11.0 // indirect
36-
golang.org/x/net v0.10.0 // indirect
37-
golang.org/x/sys v0.8.0 // indirect
38-
golang.org/x/text v0.9.0 // indirect
36+
golang.org/x/net v0.17.0 // indirect
37+
golang.org/x/sys v0.13.0 // indirect
38+
golang.org/x/text v0.13.0 // indirect
3939
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
4040
google.golang.org/protobuf v1.30.0 // indirect
4141
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect

client/go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLL
176176
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
177177
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
178178
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
179-
golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=
180-
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
179+
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
180+
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
181181
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
182182
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
183183
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -201,14 +201,14 @@ golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7w
201201
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
202202
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
203203
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
204-
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
205-
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
204+
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
205+
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
206206
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
207207
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
208208
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
209209
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
210-
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
211-
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
210+
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
211+
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
212212
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
213213
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
214214
golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=

go.mod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ require (
5656
go.uber.org/goleak v1.1.12
5757
go.uber.org/zap v1.24.0
5858
golang.org/x/exp v0.0.0-20230108222341-4b8118a2686a
59-
golang.org/x/text v0.9.0
59+
golang.org/x/text v0.13.0
6060
golang.org/x/time v0.1.0
6161
golang.org/x/tools v0.6.0
6262
google.golang.org/grpc v1.54.0
@@ -177,14 +177,14 @@ require (
177177
go.uber.org/dig v1.9.0 // indirect
178178
go.uber.org/fx v1.12.0 // indirect
179179
go.uber.org/multierr v1.11.0 // indirect
180-
golang.org/x/crypto v0.1.0 // indirect
180+
golang.org/x/crypto v0.14.0 // indirect
181181
golang.org/x/image v0.5.0 // indirect
182182
golang.org/x/mod v0.8.0 // indirect
183-
golang.org/x/net v0.10.0 // indirect
183+
golang.org/x/net v0.17.0 // indirect
184184
golang.org/x/oauth2 v0.4.0 // indirect
185185
golang.org/x/sync v0.1.0 // indirect
186-
golang.org/x/sys v0.8.0 // indirect
187-
golang.org/x/term v0.8.0 // indirect
186+
golang.org/x/sys v0.13.0 // indirect
187+
golang.org/x/term v0.13.0 // indirect
188188
google.golang.org/appengine v1.6.7 // indirect
189189
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
190190
google.golang.org/protobuf v1.30.0 // indirect

go.sum

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -652,8 +652,8 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
652652
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
653653
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
654654
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
655-
golang.org/x/crypto v0.1.0 h1:MDRAIl0xIo9Io2xV565hzXHw3zVseKrJKodhohM5CjU=
656-
golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw=
655+
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
656+
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
657657
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
658658
golang.org/x/exp v0.0.0-20230108222341-4b8118a2686a h1:tlXy25amD5A7gOfbXdqCGN5k8ESEed/Ee1E5RcrYnqU=
659659
golang.org/x/exp v0.0.0-20230108222341-4b8118a2686a/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
@@ -699,8 +699,8 @@ golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1
699699
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
700700
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
701701
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
702-
golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=
703-
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
702+
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
703+
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
704704
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
705705
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
706706
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -759,20 +759,20 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
759759
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
760760
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
761761
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
762-
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
763-
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
762+
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
763+
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
764764
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
765765
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
766-
golang.org/x/term v0.8.0 h1:n5xxQn2i3PC0yLAbjTpNT85q/Kgzcr2gIoX9OrJUols=
767-
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
766+
golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek=
767+
golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=
768768
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
769769
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
770770
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
771771
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
772772
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
773773
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
774-
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
775-
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
774+
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
775+
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
776776
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
777777
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
778778
golang.org/x/time v0.1.0 h1:xYY+Bajn2a7VBmTM5GikTmnK8ZuX8YgnQCqZpbBNtmA=

pkg/mcs/scheduling/server/apis/v1/api.go

Lines changed: 134 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package apis
1616

1717
import (
18+
"fmt"
1819
"net/http"
1920
"strconv"
2021
"sync"
@@ -26,11 +27,12 @@ import (
2627
"github.com/joho/godotenv"
2728
"github.com/pingcap/log"
2829
scheserver "github.com/tikv/pd/pkg/mcs/scheduling/server"
29-
"github.com/tikv/pd/pkg/mcs/utils"
30-
"github.com/tikv/pd/pkg/schedule"
30+
mcsutils "github.com/tikv/pd/pkg/mcs/utils"
3131
sche "github.com/tikv/pd/pkg/schedule/core"
3232
"github.com/tikv/pd/pkg/schedule/handler"
3333
"github.com/tikv/pd/pkg/schedule/operator"
34+
"github.com/tikv/pd/pkg/statistics/utils"
35+
"github.com/tikv/pd/pkg/storage"
3436
"github.com/tikv/pd/pkg/utils/apiutil"
3537
"github.com/tikv/pd/pkg/utils/apiutil/multiservicesapi"
3638
"github.com/tikv/pd/pkg/utils/logutil"
@@ -68,15 +70,11 @@ type Service struct {
6870
}
6971

7072
type server struct {
71-
server *scheserver.Server
73+
*scheserver.Server
7274
}
7375

74-
func (s *server) GetCoordinator() *schedule.Coordinator {
75-
return s.server.GetCoordinator()
76-
}
77-
78-
func (s *server) GetCluster() sche.SharedCluster {
79-
return s.server.GetCluster()
76+
func (s *server) GetCluster() sche.SchedulerCluster {
77+
return s.Server.GetCluster()
8078
}
8179

8280
func createIndentRender() *render.Render {
@@ -98,11 +96,11 @@ func NewService(srv *scheserver.Service) *Service {
9896
apiHandlerEngine.Use(gzip.Gzip(gzip.DefaultCompression))
9997
apiHandlerEngine.Use(func(c *gin.Context) {
10098
c.Set(multiservicesapi.ServiceContextKey, srv.Server)
101-
c.Set(handlerKey, handler.NewHandler(&server{server: srv.Server}))
99+
c.Set(handlerKey, handler.NewHandler(&server{srv.Server}))
102100
c.Next()
103101
})
104102
apiHandlerEngine.Use(multiservicesapi.ServiceRedirector())
105-
apiHandlerEngine.GET("metrics", utils.PromHandler())
103+
apiHandlerEngine.GET("metrics", mcsutils.PromHandler())
106104
pprof.Register(apiHandlerEngine)
107105
root := apiHandlerEngine.Group(APIPathPrefix)
108106
s := &Service{
@@ -115,6 +113,7 @@ func NewService(srv *scheserver.Service) *Service {
115113
s.RegisterOperatorsRouter()
116114
s.RegisterSchedulersRouter()
117115
s.RegisterCheckersRouter()
116+
s.RegisterHotspotRouter()
118117
return s
119118
}
120119

@@ -141,6 +140,16 @@ func (s *Service) RegisterCheckersRouter() {
141140
router.POST("/:name", pauseOrResumeChecker)
142141
}
143142

143+
// RegisterHotspotRouter registers the router of the hotspot handler.
144+
func (s *Service) RegisterHotspotRouter() {
145+
router := s.root.Group("hotspot")
146+
router.GET("/regions/write", getHotWriteRegions)
147+
router.GET("/regions/read", getHotReadRegions)
148+
router.GET("/regions/history", getHistoryHotRegions)
149+
router.GET("/stores", getHotStores)
150+
router.GET("/buckets", getHotBuckets)
151+
}
152+
144153
// RegisterOperatorsRouter registers the router of the operators handler.
145154
func (s *Service) RegisterOperatorsRouter() {
146155
router := s.root.Group("operators")
@@ -425,3 +434,117 @@ func pauseOrResumeScheduler(c *gin.Context) {
425434
}
426435
c.String(http.StatusOK, "Pause or resume the scheduler successfully.")
427436
}
437+
438+
// @Tags hotspot
439+
// @Summary List the hot write regions.
440+
// @Produce json
441+
// @Success 200 {object} statistics.StoreHotPeersInfos
442+
// @Failure 400 {string} string "The request is invalid."
443+
// @Failure 500 {string} string "PD server failed to proceed the request."
444+
// @Router /hotspot/regions/write [get]
445+
func getHotWriteRegions(c *gin.Context) {
446+
getHotRegions(utils.Write, c)
447+
}
448+
449+
// @Tags hotspot
450+
// @Summary List the hot read regions.
451+
// @Produce json
452+
// @Success 200 {object} statistics.StoreHotPeersInfos
453+
// @Failure 400 {string} string "The request is invalid."
454+
// @Failure 500 {string} string "PD server failed to proceed the request."
455+
// @Router /hotspot/regions/read [get]
456+
func getHotReadRegions(c *gin.Context) {
457+
getHotRegions(utils.Read, c)
458+
}
459+
460+
func getHotRegions(typ utils.RWType, c *gin.Context) {
461+
handler := c.MustGet(handlerKey).(*handler.Handler)
462+
463+
storeIDs := c.QueryArray("store_id")
464+
if len(storeIDs) < 1 {
465+
hotRegions, err := handler.GetHotRegions(typ)
466+
if err != nil {
467+
c.String(http.StatusInternalServerError, err.Error())
468+
return
469+
}
470+
c.IndentedJSON(http.StatusOK, hotRegions)
471+
return
472+
}
473+
474+
var ids []uint64
475+
for _, storeID := range storeIDs {
476+
id, err := strconv.ParseUint(storeID, 10, 64)
477+
if err != nil {
478+
c.String(http.StatusBadRequest, fmt.Sprintf("invalid store id: %s", storeID))
479+
return
480+
}
481+
_, err = handler.GetStore(id)
482+
if err != nil {
483+
c.String(http.StatusInternalServerError, err.Error())
484+
return
485+
}
486+
ids = append(ids, id)
487+
}
488+
489+
hotRegions, err := handler.GetHotRegions(typ, ids...)
490+
if err != nil {
491+
c.String(http.StatusInternalServerError, err.Error())
492+
return
493+
}
494+
c.IndentedJSON(http.StatusOK, hotRegions)
495+
}
496+
497+
// @Tags hotspot
498+
// @Summary List the hot stores.
499+
// @Produce json
500+
// @Success 200 {object} handler.HotStoreStats
501+
// @Failure 500 {string} string "PD server failed to proceed the request."
502+
// @Router /hotspot/stores [get]
503+
func getHotStores(c *gin.Context) {
504+
handler := c.MustGet(handlerKey).(*handler.Handler)
505+
stores, err := handler.GetHotStores()
506+
if err != nil {
507+
c.String(http.StatusInternalServerError, err.Error())
508+
return
509+
}
510+
c.IndentedJSON(http.StatusOK, stores)
511+
}
512+
513+
// @Tags hotspot
514+
// @Summary List the hot buckets.
515+
// @Produce json
516+
// @Success 200 {object} handler.HotBucketsResponse
517+
// @Failure 500 {string} string "PD server failed to proceed the request."
518+
// @Router /hotspot/buckets [get]
519+
func getHotBuckets(c *gin.Context) {
520+
handler := c.MustGet(handlerKey).(*handler.Handler)
521+
522+
regionIDs := c.QueryArray("region_id")
523+
ids := make([]uint64, len(regionIDs))
524+
for i, regionID := range regionIDs {
525+
if id, err := strconv.ParseUint(regionID, 10, 64); err == nil {
526+
ids[i] = id
527+
}
528+
}
529+
ret, err := handler.GetHotBuckets(ids...)
530+
if err != nil {
531+
c.String(http.StatusInternalServerError, err.Error())
532+
return
533+
}
534+
c.IndentedJSON(http.StatusOK, ret)
535+
}
536+
537+
// @Tags hotspot
538+
// @Summary List the history hot regions.
539+
// @Accept json
540+
// @Produce json
541+
// @Success 200 {object} storage.HistoryHotRegions
542+
// @Failure 400 {string} string "The input is invalid."
543+
// @Failure 500 {string} string "PD server failed to proceed the request."
544+
// @Router /hotspot/regions/history [get]
545+
func getHistoryHotRegions(c *gin.Context) {
546+
// TODO: support history hotspot in scheduling server with stateless in the future.
547+
// Ref: https://github.com/tikv/pd/pull/7183
548+
var res storage.HistoryHotRegions
549+
c.IndentedJSON(http.StatusOK, res)
550+
}

pkg/mcs/scheduling/server/cluster.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ func (c *Cluster) GetHotStat() *statistics.HotStat {
9494
return c.hotStat
9595
}
9696

97+
// GetStoresStats returns stores' statistics from cluster.
98+
// And it will be unnecessary to filter unhealthy store, because it has been solved in process heartbeat
99+
func (c *Cluster) GetStoresStats() *statistics.StoresStats {
100+
return c.hotStat.StoresStats
101+
}
102+
97103
// GetRegionStats gets region statistics.
98104
func (c *Cluster) GetRegionStats() *statistics.RegionStatistics {
99105
return c.regionStats

0 commit comments

Comments
 (0)