diff --git a/.all-contributorsrc b/.all-contributorsrc index b4369bf267..7b5586aa72 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -136,7 +136,7 @@ "contributorsSortAlphabetically": true, "contributorTemplate": "\">\" width=\"<%= options.imageSize %>px;\" alt=\"\"/>", "projectName": "tidb-dashboard", - "projectOwner": "pingcap-incubator", + "projectOwner": "pingcap", "repoType": "github", "repoHost": "https://github.com", "skipCi": true, diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md index 985aaf3d57..cfb2092af4 100644 --- a/.github/ISSUE_TEMPLATE/question.md +++ b/.github/ISSUE_TEMPLATE/question.md @@ -11,7 +11,7 @@ label: "type/question" Thanks for using TiDB Dashboard! Before asking a question, please take a look in the following places: - GitHub issues - https://github.com/pingcap-incubator/tidb-dashboard/issues?q=is%3Aissue + https://github.com/pingcap/tidb-dashboard/issues?q=is%3Aissue - Documentation (English) https://docs.pingcap.com/tidb/stable/dashboard-intro - Documentation (Chinese) diff --git a/.golangci.yml b/.golangci.yml index 77cb249793..aa206df8ad 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -6,7 +6,7 @@ run: linters-settings: goimports: - local-prefixes: github.com/pingcap-incubator/tidb-dashboard + local-prefixes: github.com/pingcap/tidb-dashboard golint: min-confidence: 0 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 34f20d3806..51ffdd1731 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -160,7 +160,7 @@ Thanks for your contributions! ### Finding something to work on -For beginners, we have prepared many suitable tasks for you. Checkout our [help wanted issues](https://github.com/pingcap-incubator/tidb-dashboard/issues?q=is%3Aopen+label%3Astatus%2Fhelp-wanted+sort%3Aupdated-desc) for a list, in which we have also marked the difficulty level. +For beginners, we have prepared many suitable tasks for you. Checkout our [help wanted issues](https://github.com/pingcap/tidb-dashboard/issues?q=is%3Aopen+label%3Astatus%2Fhelp-wanted+sort%3Aupdated-desc) for a list, in which we have also marked the difficulty level. If you are planning something big, for example, relates to multiple components or changes current behaviors, make sure to open an issue to discuss with us before going on. @@ -196,5 +196,5 @@ The body of the commit message should describe why the change was made and at a [tidb]: https://github.com/pingcap/tidb [tikv]: https://github.com/tikv/tikv [tiup]: https://tiup.io -[Swagger]: https://swagger.io -[React Storybook]: https://storybook.js.org \ No newline at end of file +[swagger]: https://swagger.io +[react storybook]: https://storybook.js.org diff --git a/Makefile b/Makefile index 7ee85030a8..aa5acb1bf0 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ .PHONY: install_tools lint dev yarn_dependencies ui server run -DASHBOARD_PKG := github.com/pingcap-incubator/tidb-dashboard +DASHBOARD_PKG := github.com/pingcap/tidb-dashboard BUILD_TAGS ?= diff --git a/README.md b/README.md index 7761d82ca6..c3a50e736a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # TiDB Dashboard -[![GitHub license](https://img.shields.io/github/license/pingcap-incubator/tidb-dashboard?style=flat-square)](https://github.com/pingcap-incubator/tidb-dashboard/blob/master/LICENSE) +[![GitHub license](https://img.shields.io/github/license/pingcap/tidb-dashboard?style=flat-square)](https://github.com/pingcap/tidb-dashboard/blob/master/LICENSE) TiDB Dashboard is a Web UI for monitoring, diagnosing and managing the TiDB cluster. @@ -13,7 +13,7 @@ TiDB Dashboard is a Web UI for monitoring, diagnosing and managing the TiDB clus ## Question, Suggestion -Feel free to [open GitHub issues](https://github.com/pingcap-incubator/tidb-dashboard/issues/new/choose) +Feel free to [open GitHub issues](https://github.com/pingcap/tidb-dashboard/issues/new/choose) for questions, support and suggestions. You may also consider join our community chat in the Slack channel [#sig-diagnosis]. @@ -31,7 +31,7 @@ it from source (see next section). ## Contributing & Developing -Checkout our [help wanted issues](https://github.com/pingcap-incubator/tidb-dashboard/issues?q=is%3Aopen+label%3Astatus%2Fhelp-wanted+sort%3Aupdated-desc) +Checkout our [help wanted issues](https://github.com/pingcap/tidb-dashboard/issues?q=is%3Aopen+label%3Astatus%2Fhelp-wanted+sort%3Aupdated-desc) for a list of recommended tasks, in which we have also marked the difficulty level. See [CONTRIBUTING.md](./CONTRIBUTING.md) for a detailed step-by-step contributing guide, or steps to diff --git a/cmd/tidb-dashboard/main.go b/cmd/tidb-dashboard/main.go index bccfba6651..449c98b832 100644 --- a/cmd/tidb-dashboard/main.go +++ b/cmd/tidb-dashboard/main.go @@ -42,12 +42,12 @@ import ( "go.uber.org/zap" "go.uber.org/zap/zapcore" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver" - "github.com/pingcap-incubator/tidb-dashboard/pkg/config" - keyvisualregion "github.com/pingcap-incubator/tidb-dashboard/pkg/keyvisual/region" - "github.com/pingcap-incubator/tidb-dashboard/pkg/swaggerserver" - "github.com/pingcap-incubator/tidb-dashboard/pkg/uiserver" - "github.com/pingcap-incubator/tidb-dashboard/pkg/utils/version" + "github.com/pingcap/tidb-dashboard/pkg/apiserver" + "github.com/pingcap/tidb-dashboard/pkg/config" + keyvisualregion "github.com/pingcap/tidb-dashboard/pkg/keyvisual/region" + "github.com/pingcap/tidb-dashboard/pkg/swaggerserver" + "github.com/pingcap/tidb-dashboard/pkg/uiserver" + "github.com/pingcap/tidb-dashboard/pkg/utils/version" ) type DashboardCLIConfig struct { diff --git a/go.mod b/go.mod index 1fad317dda..1576540141 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/pingcap-incubator/tidb-dashboard +module github.com/pingcap/tidb-dashboard go 1.13 @@ -20,30 +20,28 @@ require ( github.com/jinzhu/gorm v1.9.12 github.com/joho/godotenv v1.3.0 github.com/joomcode/errorx v1.0.1 - github.com/oleiade/reflections v1.0.0 // indirect + github.com/oleiade/reflections v1.0.1 github.com/pingcap/check v0.0.0-20191216031241-8a5a85928f12 - github.com/pingcap/errors v0.11.5-0.20190809092503-95897b64e011 + github.com/pingcap/errors v0.11.5-0.20200917111840-a15ef68f753d github.com/pingcap/kvproto v0.0.0-20200411081810-b85805c9476c - github.com/pingcap/log v0.0.0-20200117041106-d28c14d3b1cd + github.com/pingcap/log v0.0.0-20200511115504-543df19646ad github.com/pingcap/sysutil v0.0.0-20200206130906-2bfa6dc40bcd - github.com/pkg/errors v0.9.1 github.com/rs/cors v1.7.0 github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749 // indirect github.com/shurcooL/httpgzip v0.0.0-20190720172056-320755c1c1b0 github.com/shurcooL/vfsgen v0.0.0-20181202132449-6a9ea43bcacd github.com/spf13/pflag v1.0.1 - github.com/stretchr/testify v1.5.1 + github.com/stretchr/testify v1.6.1 github.com/swaggo/http-swagger v0.0.0-20200308142732-58ac5e232fba github.com/swaggo/swag v1.6.6-0.20200529100950-7c765ddd0476 github.com/thoas/go-funk v0.7.0 github.com/vmihailenco/msgpack/v5 v5.0.0-beta.1 go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738 - go.uber.org/atomic v1.5.0 + go.uber.org/atomic v1.6.0 go.uber.org/fx v1.10.0 - go.uber.org/zap v1.13.0 + go.uber.org/zap v1.15.0 golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f // indirect golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2 // indirect golang.org/x/sync v0.0.0-20190423024810-112230192c58 google.golang.org/grpc v1.25.1 - gopkg.in/oleiade/reflections.v1 v1.0.0 ) diff --git a/go.sum b/go.sum index 647834bb0d..8733587968 100644 --- a/go.sum +++ b/go.sum @@ -31,7 +31,6 @@ github.com/cenkalti/backoff/v4 v4.0.2 h1:JIufpQLbh4DkbQoii76ItQIUFzevQSqOLZca4ea github.com/cenkalti/backoff/v4 v4.0.2/go.mod h1:eEew/i+1Q6OrCDZh3WiXYv3+nJwBASZ8Bog/87DQnVg= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= -github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e h1:fY5BOSpyZCqRo5OhCuC+XN+r/bBCmeuuJtjz+bCNIf8= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= @@ -61,7 +60,6 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 h1:Yzb9+7DPaBjB8zlTR87/ElzFsnQfuHnVUVqpZZIcV5Y= github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0= -github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fogleman/gg v1.3.0 h1:/7zJX8F6AaYQc57WQCyN9cAIz+4bCJGO9B+dyW29am8= github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= @@ -104,7 +102,6 @@ github.com/go-playground/locales v0.12.1/go.mod h1:IUMDtCfWo/w/mtMfIE/IG2K+Ey3yg github.com/go-playground/overalls v0.0.0-20180201144345-22ec1a223b7c/go.mod h1:UqxAgEOt89sCiXlrc/ycnx00LVvUO/eS8tMUkWX4R7w= github.com/go-playground/universal-translator v0.16.0 h1:X++omBR/4cE2MNg91AoC3rmGrCjJ8eAeUP/K/EKx4DM= github.com/go-playground/universal-translator v0.16.0/go.mod h1:1AnU7NaIRDWWzGEKwgtJRd2xk99HeFyHw3yid4rvQIY= -github.com/go-sql-driver/mysql v1.4.1 h1:g24URVg0OFbNUTx9qqY1IRZ9D9z3iPyi5zKhQZpNwpA= github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= @@ -113,7 +110,6 @@ github.com/goccy/go-graphviz v0.0.5 h1:qcjgvNiYbLyfLAq9LvyYBJ7sNMbQh9w4FoAzBDrYh github.com/goccy/go-graphviz v0.0.5/go.mod h1:wXVsXxmyMQU6TN3zGRttjNn3h+iCAS7xQFC6TlNvLhk= github.com/gogo/protobuf v0.0.0-20180717141946-636bf0302bc9/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls= github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= @@ -129,13 +125,11 @@ github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfb github.com/golang/protobuf v0.0.0-20180814211427-aa810b61a9c7/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.4 h1:87PNWwrRvUSnqS4dlcBU/ftvOIBep4sYuBLlh6rX2wk= github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20200407044318-7d83b28da2e9 h1:K+lX49/3eURCE1IjlaZN//u6c+9nfDAMnyQ9E2dsJbY= @@ -144,7 +138,6 @@ github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm4 github.com/google/shlex v0.0.0-20181106134648-c34317bd91bf/go.mod h1:RpwtwJQFrIEPstU94h88MWPXP2ektJZ8cZ0YntAmXiE= github.com/google/uuid v1.0.0 h1:b4Gk+7WdP/d3HZH8EJsZpvV7EtDOgaZLtnaNGIu1adA= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c h1:Lh2aW+HnU2Nbe1gqD9SOJLJxW1jBMmQOktN2acDyJk8= github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= @@ -152,7 +145,6 @@ github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= -github.com/grpc-ecosystem/grpc-gateway v1.9.5 h1:UImYN5qQ8tuGpGE16ZmjvcTtTw24zw1QAp/SlnNrZhI= github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.12.1 h1:zCy2xE9ablevUOrUZc3Dl72Dt+ya2FNAvC2yLYMHzi4= github.com/grpc-ecosystem/grpc-gateway v1.12.1/go.mod h1:8XEsbTttt/W+VvjtQhLACqCisSPWTxCZ7sBRjU6iH9c= @@ -162,7 +154,6 @@ github.com/hypnoglow/gormzap v0.3.0 h1:zqVHEcLN2snfwLFf2Dtam0mV+XN9s+NvcZ7XcnKHy github.com/hypnoglow/gormzap v0.3.0/go.mod h1:5Wom8B7Jl2oK0Im9hs6KQ+Kl92w4Y7gKCrj66rhyvw0= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6 h1:UDMh68UUwekSh5iP2OMhRRZJiiBccgV7axzUG8vi56c= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jinzhu/gorm v1.9.12 h1:Drgk1clyWT9t9ERbzHza6Mj/8FY/CqMyVzOiHviMo6Q= @@ -183,9 +174,7 @@ github.com/json-iterator/go v1.1.7 h1:KfgG9LzI+pYjr4xvmz/5H4FXjokeP+rlHLhv3iH62F github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= -github.com/kisielk/errcheck v1.2.0 h1:reN85Pxc5larApoH1keMBiu2GWtPqXQ1nc9gx+jOU+E= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= -github.com/kisielk/gotool v1.0.0 h1:AV2c/EiW3KqPNT9ZKl07ehoAGi4C5/01Cfbblndcapg= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -204,7 +193,6 @@ github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e h1:hB2xlXdHp/pmPZq0y3QnmWAArdw9PqbmotexnWx/FU8= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= @@ -216,11 +204,9 @@ github.com/mattn/go-sqlite3 v2.0.1+incompatible h1:xQ15muvnzGBHpIpdrNi1DA5x0+TcB github.com/mattn/go-sqlite3 v2.0.1+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= @@ -228,31 +214,29 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW github.com/nfnt/resize v0.0.0-20160724205520-891127d8d1b5 h1:BvoENQQU+fZ9uukda/RzCAL/191HHwJA5b13R6diVlY= github.com/nfnt/resize v0.0.0-20160724205520-891127d8d1b5/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8= github.com/nicksnyder/go-i18n v1.10.0/go.mod h1:HrK7VCrbOvQoUAQ7Vpy7i87N7JZZZ7R2xBGjv0j365Q= -github.com/oleiade/reflections v1.0.0 h1:0ir4pc6v8/PJ0yw5AEtMddfXpWBXg9cnG7SgSoJuCgY= -github.com/oleiade/reflections v1.0.0/go.mod h1:RbATFBbKYkVdqmSFtx13Bb/tVhR0lgOBXunWTZKeL4w= +github.com/oleiade/reflections v1.0.1 h1:D1XO3LVEYroYskEsoSiGItp9RUxG6jWnCVvrqH0HHQM= +github.com/oleiade/reflections v1.0.1/go.mod h1:rdFxbxq4QXVZWj0F+e9jqjDkc7dbp97vkRixKo2JR60= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/pelletier/go-toml v1.3.0/go.mod h1:PN7xzY2wHTK0K9p34ErDQMlFxa51Fk0OUruD3k1mMwo= -github.com/pingcap/check v0.0.0-20190102082844-67f458068fc8 h1:USx2/E1bX46VG32FIw034Au6seQ2fY9NEILmNh/UlQg= github.com/pingcap/check v0.0.0-20190102082844-67f458068fc8/go.mod h1:B1+S9LNcuMyLH/4HMTViQOJevkGiik3wW2AN9zb2fNQ= github.com/pingcap/check v0.0.0-20191107115940-caf2b9e6ccf4/go.mod h1:PYMCGwN0JHjoqGr3HrZoD+b8Tgx8bKnArhSq8YVzUMc= github.com/pingcap/check v0.0.0-20191216031241-8a5a85928f12 h1:rfD9v3+ppLPzoQBgZev0qYCpegrwyFx/BUpkApEiKdY= github.com/pingcap/check v0.0.0-20191216031241-8a5a85928f12/go.mod h1:PYMCGwN0JHjoqGr3HrZoD+b8Tgx8bKnArhSq8YVzUMc= -github.com/pingcap/errors v0.11.0 h1:DCJQB8jrHbQ1VVlMFIrbj2ApScNNotVmkSNplu2yUt4= github.com/pingcap/errors v0.11.0/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= github.com/pingcap/errors v0.11.5-0.20190809092503-95897b64e011 h1:58naV4XMEqm0hl9LcYo6cZoGBGiLtefMQMF/vo3XLgQ= github.com/pingcap/errors v0.11.5-0.20190809092503-95897b64e011/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= +github.com/pingcap/errors v0.11.5-0.20200917111840-a15ef68f753d h1:TH18wFO5Nq/zUQuWu9ms2urgZnLP69XJYiI2JZAkUGc= +github.com/pingcap/errors v0.11.5-0.20200917111840-a15ef68f753d/go.mod h1:g4vx//d6VakjJ0mk7iLBlKA8LFavV/sAVINT/1PFxeQ= github.com/pingcap/failpoint v0.0.0-20191029060244-12f4ac2fd11d/go.mod h1:DNS3Qg7bEDhU6EXNHF+XSv/PGznQaMJ5FWvctpm6pQI= github.com/pingcap/kvproto v0.0.0-20191211054548-3c6b38ea5107/go.mod h1:WWLmULLO7l8IOcQG+t+ItJ3fEcrL5FxF0Wu+HrMy26w= github.com/pingcap/kvproto v0.0.0-20200411081810-b85805c9476c h1:wO9VvZezAU4ZPZj8+P5uWfsT/ppuABjJPmHNrpCQnlc= github.com/pingcap/kvproto v0.0.0-20200411081810-b85805c9476c/go.mod h1:IOdRDPLyda8GX2hE/jO7gqaCV/PNFh8BZQCQZXfIOqI= -github.com/pingcap/log v0.0.0-20191012051959-b742a5d432e9 h1:AJD9pZYm72vMgPcQDww9rkZ1DnWfl0pXV3BOWlkYIjA= github.com/pingcap/log v0.0.0-20191012051959-b742a5d432e9/go.mod h1:4rbK1p9ILyIfb6hU7OG2CiWSqMXnp3JMbiaVJ6mvoY8= -github.com/pingcap/log v0.0.0-20200117041106-d28c14d3b1cd h1:CV3VsP3Z02MVtdpTMfEgRJ4T9NGgGTxdHpJerent7rM= -github.com/pingcap/log v0.0.0-20200117041106-d28c14d3b1cd/go.mod h1:4rbK1p9ILyIfb6hU7OG2CiWSqMXnp3JMbiaVJ6mvoY8= +github.com/pingcap/log v0.0.0-20200511115504-543df19646ad h1:SveG82rmu/GFxYanffxsSF503SiQV+2JLnWEiGiF+Tc= +github.com/pingcap/log v0.0.0-20200511115504-543df19646ad/go.mod h1:4rbK1p9ILyIfb6hU7OG2CiWSqMXnp3JMbiaVJ6mvoY8= github.com/pingcap/sysutil v0.0.0-20200206130906-2bfa6dc40bcd h1:k7CIHMFVKjHsda3PKkiN4zv++NEnexlUwiJEhryWpG0= github.com/pingcap/sysutil v0.0.0-20200206130906-2bfa6dc40bcd/go.mod h1:EB/852NMQ+aRKioCpToQ94Wl7fktV+FNnxf3CX/TTXI= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -262,7 +246,6 @@ github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXP github.com/prometheus/client_golang v1.0.0 h1:vrDKnkGzuGvhNAL56c7DBz29ZL+KxnoR0x7enabFceM= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= -github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90 h1:S/YWwWx/RA8rT8tKFRuGUZhuA90OyIBpPCXkcbwU8DE= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 h1:gQz4mCbXsO+nc9n1hCxHcGA3Zx3Eo+UHZoInFGUIXNM= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -301,17 +284,15 @@ github.com/spf13/pflag v1.0.1 h1:aCvUg6QPl3ibpQUxyLkrEkCHtPqYJL4x9AuhqVqFis4= github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/swaggo/files v0.0.0-20190704085106-630677cd5c14 h1:PyYN9JH5jY9j6av01SpfRMb+1DWg/i3MbGOKPxJ2wjM= github.com/swaggo/files v0.0.0-20190704085106-630677cd5c14/go.mod h1:gxQT6pBGRuIGunNf/+tSOB5OHvguWi8Tbt82WOkf35E= -github.com/swaggo/gin-swagger v1.2.0 h1:YskZXEiv51fjOMTsXrOetAjrMDfFaXD79PEoQBOe2W0= github.com/swaggo/gin-swagger v1.2.0/go.mod h1:qlH2+W7zXGZkczuL+r2nEBR2JTT+/lX05Nn6vPhc7OI= github.com/swaggo/http-swagger v0.0.0-20200308142732-58ac5e232fba h1:lUPlXKqgbqT2SVg2Y+eT9mu5wbqMnG+i/+Q9nK7C0Rs= github.com/swaggo/http-swagger v0.0.0-20200308142732-58ac5e232fba/go.mod h1:O1lAbCgAAX/KZ80LM/OXwtWFI/5TvZlwxSg8Cq08PV0= @@ -353,38 +334,36 @@ go.etcd.io/bbolt v1.3.3 h1:MUGmc65QhB3pIlaQ5bB4LwqSj6GIonVJXpZiaKNyaKk= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738 h1:VcrIfasaLFkyjk6KNlXQSzO+B0fZcnECiDrKJsfxka0= go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= -go.uber.org/atomic v1.3.2 h1:2Oa65PReHzfn29GpvgsYwloV9AVFHPDk8tYxt2c2tr4= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0 h1:OI5t8sDa1Or+q8AeE+yKeB/SDYioSHAgcVljj9JIETY= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= +go.uber.org/atomic v1.6.0 h1:Ezj3JGmsOnG1MoRWQkPBsKLe9DwWD9QeXzTRzzldNVk= +go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/dig v1.8.0 h1:1rR6hnL/bu1EVcjnRDN5kx1vbIjEJDTGhSQ2B3ddpcI= go.uber.org/dig v1.8.0/go.mod h1:X34SnWGr8Fyla9zQNO2GSO2D+TIuqB14OS8JhYocIyw= go.uber.org/fx v1.10.0 h1:S2K/H8oNied0Je/mLKdWzEWKZfv9jtxSDm8CnwK+5Fg= go.uber.org/fx v1.10.0/go.mod h1:vLRicqpG/qQEzno4SYU86iCwfT95EZza+Eba0ItuxqY= go.uber.org/goleak v0.10.0 h1:G3eWbSNIskeRqtsN/1uI5B+eP73y3JUuBsv9AZjehb4= go.uber.org/goleak v0.10.0/go.mod h1:VCZuO8V8mFPlL0F5J5GK1rtHV3DrFcQ1R8ryq7FK0aI= -go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= -go.uber.org/multierr v1.3.0 h1:sFPn2GLc3poCkfrpIXGhBD2X0CMIo4Q/zSULXrj/+uc= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.4.0 h1:f3WCSC2KzAcBXGATIxAB1E2XuCpNU255wNKZ505qi3E= go.uber.org/multierr v1.4.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= +go.uber.org/multierr v1.5.0 h1:KCa4XfM8CWFCpxXRGok+Q0SS/0XBhMDbHHGABQLvD2A= +go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee h1:0mgffUl7nfd+FpvXMVz4IDEaUSmT1ysygQC7qYo7sG4= go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= go.uber.org/zap v1.8.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= -go.uber.org/zap v1.9.1 h1:XCJQEf3W6eZaVwhRBof6ImoYGJSITeKWsyeh3HFu/5o= go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= -go.uber.org/zap v1.10.0 h1:ORx85nbTijNz8ljznvCMR1ZBIPKFn3jQrag10X2AsuM= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.12.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= -go.uber.org/zap v1.13.0 h1:nR6NoDBgAf67s68NhaXbsojM+2gxp3S1hWkHDl27pVU= -go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= +go.uber.org/zap v1.15.0 h1:ZZCA22JRF2gQE5FoNmhmrf7jeJJ2uhqDUNRYKm8dvmM= +go.uber.org/zap v1.15.0/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd h1:GGJVjV8waZKRHrgwvtH66z9ZGVurTD1MT0n1Bb+q4aM= golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200204104054-c9f3fb736b72 h1:+ELyKg6m8UBf0nPFSqD0mi7zUfwPyXo23HNjMnXPz7w= golang.org/x/crypto v0.0.0-20200204104054-c9f3fb736b72/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= @@ -394,7 +373,6 @@ golang.org/x/image v0.0.0-20200119044424-58c23975cae1/go.mod h1:FeLwcggjj3mMvU+o golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f h1:J5lckAjkw6qYlOZNj90mLYNTEKDvWeuc1yieZ8qUzUE= golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= @@ -413,9 +391,7 @@ golang.org/x/net v0.0.0-20190611141213-3f473d35a33a/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 h1:k7pJ2yAPLPgbskkFdhRCsA77k2fySZ1zf2zCjvQCiIM= golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191002035440-2ec189313ef0 h1:2mqDk8w/o6UmeUCu5Qiq2y7iMf6anbx+YA8d1JFoFrs= golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2 h1:eDrdRpKgkcCqKZQwyZRyeFZgfqt37SL7Kv3tok06cKE= @@ -437,11 +413,8 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190610200419-93c9922d18ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a h1:aYOabOQFp6Vj6W1F80affTUvO9UxmJRx8K0gsfABByQ= golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456 h1:ng0gs1AKnRRuEMZoTLLlbOd+C17zUDepwGQBb/n+JVg= golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e h1:9vRrk9YW2BTzLP0VCB9ZDjU4cPqkg+IDWL7XgxA1yxQ= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -459,27 +432,20 @@ golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3 golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190606050223-4d9ae51c2468/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190611222205-d73e1c7e250b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59 h1:QjA/9ArTfVTLfEhClDCG7SGrZkZixxWpwNCDiwJfh88= golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5 h1:hKsoRgsbwY1NafxrwTs+k64bikrLBkAgPir1TNCj3Zs= golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191030062658-86caa796c7ab/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191107010934-f79515f33823 h1:akkRBeitX2EZP59KdtKw310CI4WGPCNPyrLbE7WZA8Y= golang.org/x/tools v0.0.0-20191107010934-f79515f33823/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191114200427-caa0b0f7d508 h1:0FYNp0PF9kFm/ZUrvcJiQ12IUJJG7iAc6Cu01wbKrbU= golang.org/x/tools v0.0.0-20191114200427-caa0b0f7d508/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f h1:kDxGY2VmgABOe55qheT/TFqUMtcTHnomIPS1iv3G4Ms= golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.5 h1:tycE03LOZYQNhDpS27tcQdAzLCVMaj7QT2SXxebnpCM= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0NQvRW8DG4Yk3Q6T9cu9RcFQDu1tc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20181004005441-af9cb2a35e7f/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= @@ -488,7 +454,6 @@ google.golang.org/genproto v0.0.0-20190927181202-20e1ac93f88c/go.mod h1:IbNlFCBr google.golang.org/grpc v0.0.0-20180607172857-7a6a684ca69e/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.23.1 h1:q4XQuHFC6I28BKZpo6IYyb3mNO+l7lSOxRuYTCiDfXk= google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.24.0/go.mod h1:XDChyiUovWa60DnaeDeZmSW86xtLtjtZbwvSiRnRtcA= google.golang.org/grpc v1.25.1 h1:wdKvqQk7IttEw92GoRyKG2IDrUIpgpj6H6m81yfeMW0= @@ -508,16 +473,15 @@ gopkg.in/go-playground/validator.v9 v9.29.1 h1:SvGtYmN60a5CVKTOzMSyfzWDeZRxRuGvR gopkg.in/go-playground/validator.v9 v9.29.1/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ= gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= -gopkg.in/oleiade/reflections.v1 v1.0.0 h1:nV9NFaFd5bXKjilVvPvA+/V/tNQk1pOEEc9gGWDkj+s= -gopkg.in/oleiade/reflections.v1 v1.0.0/go.mod h1:SpA8pv+LUnF0FbB2hyRxc8XSng78D6iLBZ11PDb8Z5g= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo= gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM= diff --git a/pkg/apiserver/apiserver.go b/pkg/apiserver/apiserver.go index b519f5f33c..f2195a829e 100644 --- a/pkg/apiserver/apiserver.go +++ b/pkg/apiserver/apiserver.go @@ -25,28 +25,31 @@ import ( cors "github.com/rs/cors/wrapper/gin" "go.uber.org/fx" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/clusterinfo" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/configuration" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/diagnose" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/info" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/logsearch" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/metrics" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/profiling" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/queryeditor" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/slowquery" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/statement" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/user" - apiutils "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/utils" - "github.com/pingcap-incubator/tidb-dashboard/pkg/config" - "github.com/pingcap-incubator/tidb-dashboard/pkg/dbstore" - "github.com/pingcap-incubator/tidb-dashboard/pkg/httpc" - "github.com/pingcap-incubator/tidb-dashboard/pkg/keyvisual" - keyvisualregion "github.com/pingcap-incubator/tidb-dashboard/pkg/keyvisual/region" - "github.com/pingcap-incubator/tidb-dashboard/pkg/pd" - "github.com/pingcap-incubator/tidb-dashboard/pkg/tidb" - "github.com/pingcap-incubator/tidb-dashboard/pkg/tikv" - "github.com/pingcap-incubator/tidb-dashboard/pkg/utils" - "github.com/pingcap-incubator/tidb-dashboard/pkg/utils/version" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/clusterinfo" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/configuration" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/diagnose" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/info" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/logsearch" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/metrics" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/profiling" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/queryeditor" + + // "github.com/pingcap/tidb-dashboard/pkg/apiserver/__APP_NAME__" + // NOTE: Don't remove above comment line, it is a placeholder for code generator + "github.com/pingcap/tidb-dashboard/pkg/apiserver/slowquery" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/statement" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/user" + apiutils "github.com/pingcap/tidb-dashboard/pkg/apiserver/utils" + "github.com/pingcap/tidb-dashboard/pkg/config" + "github.com/pingcap/tidb-dashboard/pkg/dbstore" + "github.com/pingcap/tidb-dashboard/pkg/httpc" + "github.com/pingcap/tidb-dashboard/pkg/keyvisual" + keyvisualregion "github.com/pingcap/tidb-dashboard/pkg/keyvisual/region" + "github.com/pingcap/tidb-dashboard/pkg/pd" + "github.com/pingcap/tidb-dashboard/pkg/tidb" + "github.com/pingcap/tidb-dashboard/pkg/tikv" + "github.com/pingcap/tidb-dashboard/pkg/utils" + "github.com/pingcap/tidb-dashboard/pkg/utils/version" ) func Handler(s *Service) http.Handler { @@ -123,6 +126,8 @@ func (s *Service) Start(ctx context.Context) error { metrics.NewService, queryeditor.NewService, configuration.NewService, + // __APP_NAME__.NewService, + // NOTE: Don't remove above comment line, it is a placeholder for code generator ), fx.Populate(&s.apiHandlerEngine), fx.Invoke( @@ -138,6 +143,8 @@ func (s *Service) Start(ctx context.Context) error { metrics.RegisterRouter, queryeditor.RegisterRouter, configuration.RegisterRouter, + // __APP_NAME__.RegisterRouter, + // NOTE: Don't remove above comment line, it is a placeholder for code generator // Must be at the end s.status.Register, ), diff --git a/pkg/apiserver/clusterinfo/host.go b/pkg/apiserver/clusterinfo/host.go index 414982dd34..995d9ef922 100644 --- a/pkg/apiserver/clusterinfo/host.go +++ b/pkg/apiserver/clusterinfo/host.go @@ -21,8 +21,8 @@ import ( "github.com/thoas/go-funk" "go.uber.org/zap" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/clusterinfo/hostinfo" - "github.com/pingcap-incubator/tidb-dashboard/pkg/utils/topology" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/clusterinfo/hostinfo" + "github.com/pingcap/tidb-dashboard/pkg/utils/topology" ) // fetchAllInstanceHosts fetches all hosts in the cluster and return in ascending order. diff --git a/pkg/apiserver/clusterinfo/hostinfo/cluster_config.go b/pkg/apiserver/clusterinfo/hostinfo/cluster_config.go index fb2655de29..037c39f11a 100644 --- a/pkg/apiserver/clusterinfo/hostinfo/cluster_config.go +++ b/pkg/apiserver/clusterinfo/hostinfo/cluster_config.go @@ -18,7 +18,7 @@ import ( "github.com/jinzhu/gorm" - "github.com/pingcap-incubator/tidb-dashboard/pkg/utils/host" + "github.com/pingcap/tidb-dashboard/pkg/utils/host" ) type clusterConfigModel struct { diff --git a/pkg/apiserver/clusterinfo/hostinfo/cluster_hardware.go b/pkg/apiserver/clusterinfo/hostinfo/cluster_hardware.go index 3657a02b28..6a3f15dc4b 100644 --- a/pkg/apiserver/clusterinfo/hostinfo/cluster_hardware.go +++ b/pkg/apiserver/clusterinfo/hostinfo/cluster_hardware.go @@ -20,7 +20,7 @@ import ( "github.com/jinzhu/gorm" - "github.com/pingcap-incubator/tidb-dashboard/pkg/utils/host" + "github.com/pingcap/tidb-dashboard/pkg/utils/host" ) // Used to deserialize from JSON_VALUE diff --git a/pkg/apiserver/clusterinfo/hostinfo/cluster_load.go b/pkg/apiserver/clusterinfo/hostinfo/cluster_load.go index e30582f91a..5d7f1762b2 100644 --- a/pkg/apiserver/clusterinfo/hostinfo/cluster_load.go +++ b/pkg/apiserver/clusterinfo/hostinfo/cluster_load.go @@ -19,7 +19,7 @@ import ( "github.com/jinzhu/gorm" - "github.com/pingcap-incubator/tidb-dashboard/pkg/utils/host" + "github.com/pingcap/tidb-dashboard/pkg/utils/host" ) // Used to deserialize from JSON_VALUE diff --git a/pkg/apiserver/clusterinfo/service.go b/pkg/apiserver/clusterinfo/service.go index a8fe7506cd..59a51fbf4b 100644 --- a/pkg/apiserver/clusterinfo/service.go +++ b/pkg/apiserver/clusterinfo/service.go @@ -27,13 +27,13 @@ import ( "go.etcd.io/etcd/clientv3" "go.uber.org/fx" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/clusterinfo/hostinfo" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/user" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/utils" - "github.com/pingcap-incubator/tidb-dashboard/pkg/httpc" - "github.com/pingcap-incubator/tidb-dashboard/pkg/pd" - "github.com/pingcap-incubator/tidb-dashboard/pkg/tidb" - "github.com/pingcap-incubator/tidb-dashboard/pkg/utils/topology" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/clusterinfo/hostinfo" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/user" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/utils" + "github.com/pingcap/tidb-dashboard/pkg/httpc" + "github.com/pingcap/tidb-dashboard/pkg/pd" + "github.com/pingcap/tidb-dashboard/pkg/tidb" + "github.com/pingcap/tidb-dashboard/pkg/utils/topology" ) type ServiceParams struct { diff --git a/pkg/apiserver/clusterinfo/statistics.go b/pkg/apiserver/clusterinfo/statistics.go index a57fd40fb4..f04d6575f9 100644 --- a/pkg/apiserver/clusterinfo/statistics.go +++ b/pkg/apiserver/clusterinfo/statistics.go @@ -20,8 +20,8 @@ import ( "github.com/jinzhu/gorm" "github.com/thoas/go-funk" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/clusterinfo/hostinfo" - "github.com/pingcap-incubator/tidb-dashboard/pkg/utils/topology" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/clusterinfo/hostinfo" + "github.com/pingcap/tidb-dashboard/pkg/utils/topology" ) type ClusterStatisticsPartial struct { diff --git a/pkg/apiserver/clusterinfo/topology.go b/pkg/apiserver/clusterinfo/topology.go index d46dba7dae..5ab4476a09 100644 --- a/pkg/apiserver/clusterinfo/topology.go +++ b/pkg/apiserver/clusterinfo/topology.go @@ -7,7 +7,7 @@ import ( "io/ioutil" "net/http" - "github.com/pingcap-incubator/tidb-dashboard/pkg/httpc" + "github.com/pingcap/tidb-dashboard/pkg/httpc" ) func fetchAlertManagerCounts(ctx context.Context, alertManagerAddr string, httpClient *httpc.Client) (int, error) { diff --git a/pkg/apiserver/configuration/router.go b/pkg/apiserver/configuration/router.go index 380586ec7e..04698f5626 100644 --- a/pkg/apiserver/configuration/router.go +++ b/pkg/apiserver/configuration/router.go @@ -18,8 +18,8 @@ import ( "github.com/gin-gonic/gin" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/user" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/utils" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/user" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/utils" ) func RegisterRouter(r *gin.RouterGroup, auth *user.AuthService, s *Service) { diff --git a/pkg/apiserver/configuration/service.go b/pkg/apiserver/configuration/service.go index fdeae3880b..30ae481b3c 100644 --- a/pkg/apiserver/configuration/service.go +++ b/pkg/apiserver/configuration/service.go @@ -25,12 +25,12 @@ import ( "go.etcd.io/etcd/clientv3" "go.uber.org/fx" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/utils" - "github.com/pingcap-incubator/tidb-dashboard/pkg/config" - "github.com/pingcap-incubator/tidb-dashboard/pkg/pd" - "github.com/pingcap-incubator/tidb-dashboard/pkg/tidb" - "github.com/pingcap-incubator/tidb-dashboard/pkg/tikv" - "github.com/pingcap-incubator/tidb-dashboard/pkg/utils/topology" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/utils" + "github.com/pingcap/tidb-dashboard/pkg/config" + "github.com/pingcap/tidb-dashboard/pkg/pd" + "github.com/pingcap/tidb-dashboard/pkg/tidb" + "github.com/pingcap/tidb-dashboard/pkg/tikv" + "github.com/pingcap/tidb-dashboard/pkg/utils/topology" ) var ( diff --git a/pkg/apiserver/diagnose/compare.go b/pkg/apiserver/diagnose/compare.go index 0d5b2ccffe..cb605df46d 100644 --- a/pkg/apiserver/diagnose/compare.go +++ b/pkg/apiserver/diagnose/compare.go @@ -13,7 +13,7 @@ import ( "github.com/jinzhu/gorm" "github.com/pingcap/errors" - "github.com/pingcap-incubator/tidb-dashboard/pkg/dbstore" + "github.com/pingcap/tidb-dashboard/pkg/dbstore" ) func GetCompareReportTablesForDisplay(startTime1, endTime1, startTime2, endTime2 string, db *gorm.DB, sqliteDB *dbstore.DB, reportID string) []*TableDef { diff --git a/pkg/apiserver/diagnose/diagnose.go b/pkg/apiserver/diagnose/diagnose.go index 241b05be79..4fe80b1da8 100644 --- a/pkg/apiserver/diagnose/diagnose.go +++ b/pkg/apiserver/diagnose/diagnose.go @@ -28,13 +28,13 @@ import ( "github.com/pingcap/log" "go.uber.org/zap" - "github.com/pingcap-incubator/tidb-dashboard/pkg/uiserver" + "github.com/pingcap/tidb-dashboard/pkg/uiserver" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/user" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/utils" - "github.com/pingcap-incubator/tidb-dashboard/pkg/config" - "github.com/pingcap-incubator/tidb-dashboard/pkg/dbstore" - "github.com/pingcap-incubator/tidb-dashboard/pkg/tidb" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/user" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/utils" + "github.com/pingcap/tidb-dashboard/pkg/config" + "github.com/pingcap/tidb-dashboard/pkg/dbstore" + "github.com/pingcap/tidb-dashboard/pkg/tidb" ) const ( diff --git a/pkg/apiserver/diagnose/model.go b/pkg/apiserver/diagnose/model.go index 067efd45cc..ea31cd3bc7 100644 --- a/pkg/apiserver/diagnose/model.go +++ b/pkg/apiserver/diagnose/model.go @@ -18,7 +18,7 @@ import ( "github.com/google/uuid" - "github.com/pingcap-incubator/tidb-dashboard/pkg/dbstore" + "github.com/pingcap/tidb-dashboard/pkg/dbstore" ) type Report struct { diff --git a/pkg/apiserver/diagnose/report.go b/pkg/apiserver/diagnose/report.go index 36311d0374..5497f5d954 100644 --- a/pkg/apiserver/diagnose/report.go +++ b/pkg/apiserver/diagnose/report.go @@ -25,7 +25,7 @@ import ( "github.com/jinzhu/gorm" - "github.com/pingcap-incubator/tidb-dashboard/pkg/dbstore" + "github.com/pingcap/tidb-dashboard/pkg/dbstore" ) type TableDef struct { @@ -745,7 +745,7 @@ func GetPDConfigInfo(startTime, endTime string, db *gorm.DB) (TableDef, error) { func GetPDConfigChangeInfo(startTime, endTime string, db *gorm.DB) (TableDef, error) { sql := fmt.Sprintf(`select t1.* from (select min(time) as time,type,value from metrics_schema.pd_scheduler_config where time>='%[1]s' and time<'%[2]s' group by type,value order by type) as t1 join - (select type, count(distinct value) as count from metrics_schema.pd_scheduler_config where time>='%[1]s' and time<'%[2]s' group by type order by count desc) as t2 + (select type, count(distinct value) as count from metrics_schema.pd_scheduler_config where time>='%[1]s' and time<'%[2]s' group by type order by count desc) as t2 where t1.type=t2.type and t2.count > 1 order by t2.count desc, t1.time;`, startTime, endTime) table := TableDef{ @@ -788,7 +788,7 @@ func GetTiDBGCConfigInfo(startTime, endTime string, db *gorm.DB) (TableDef, erro func GetTiDBGCConfigChangeInfo(startTime, endTime string, db *gorm.DB) (TableDef, error) { sql := fmt.Sprintf(`select t1.* from (select min(time) as time,type,value from metrics_schema.tidb_gc_config where time>='%[1]s' and time<'%[2]s' and value > 0 group by type,value order by type) as t1 join - (select type, count(distinct value) as count from metrics_schema.tidb_gc_config where time>='%[1]s' and time<'%[2]s' and value > 0 group by type order by count desc) as t2 + (select type, count(distinct value) as count from metrics_schema.tidb_gc_config where time>='%[1]s' and time<'%[2]s' and value > 0 group by type order by count desc) as t2 where t1.type=t2.type and t2.count>1 order by t2.count desc, t1.time;`, startTime, endTime) table := TableDef{ @@ -869,7 +869,7 @@ func GetTiKVRocksDBConfigInfo(startTime, endTime string, db *gorm.DB) (TableDef, func GetTiKVRocksDBConfigChangeInfo(startTime, endTime string, db *gorm.DB) (TableDef, error) { sql := fmt.Sprintf(`select t1.* from (select min(time) as time,concat(name,' , ',cf) as name,instance,value from metrics_schema.tikv_config_rocksdb where time>='%[1]s' and time<'%[2]s' group by name,cf,instance,value order by name) as t1 join - (select concat(name,' , ',cf) as name,instance, count(distinct value) as count from metrics_schema.tikv_config_rocksdb where time>='%[1]s' and time<'%[2]s' group by name,cf,instance order by count desc) as t2 + (select concat(name,' , ',cf) as name,instance, count(distinct value) as count from metrics_schema.tikv_config_rocksdb where time>='%[1]s' and time<'%[2]s' group by name,cf,instance order by count desc) as t2 where t1.name=t2.name and t1.instance = t2.instance and t2.count>1 order by t1.name,instance, t2.count desc, t1.time;`, startTime, endTime) table := TableDef{ @@ -951,7 +951,7 @@ func GetTiKVRaftStoreConfigInfo(startTime, endTime string, db *gorm.DB) (TableDe func GetTiKVRaftStoreConfigChangeInfo(startTime, endTime string, db *gorm.DB) (TableDef, error) { sql := fmt.Sprintf(`select t1.* from (select min(time) as time,name,instance,value from metrics_schema.tikv_config_raftstore where time>='%[1]s' and time<'%[2]s' group by name,instance,value order by name) as t1 join - (select name,instance, count(distinct value) as count from metrics_schema.tikv_config_raftstore where time>='%[1]s' and time<'%[2]s' group by name,instance order by count desc) as t2 + (select name,instance, count(distinct value) as count from metrics_schema.tikv_config_raftstore where time>='%[1]s' and time<'%[2]s' group by name,instance order by count desc) as t2 where t1.name=t2.name and t1.instance = t2.instance and t2.count>1 order by t1.name,instance,t2.count desc, t1.time;`, startTime, endTime) table := TableDef{ @@ -1710,7 +1710,7 @@ func getAvgMaxMinCPUUsage(startTime, endTime string, db *gorm.DB) (*TableRowDef, func getAvgMaxMinMemoryUsage(startTime, endTime string, db *gorm.DB) (*TableRowDef, error) { condition := fmt.Sprintf("where time >= '%s' and time < '%s' ", startTime, endTime) - sql := fmt.Sprintf(`select 'node_mem_usage','', 100*(1-t1.avg_value/t2.total),100*(1-t1.min_value/t2.total), 100*(1-t1.max_value/t2.total) from + sql := fmt.Sprintf(`select 'node_mem_usage','', 100*(1-t1.avg_value/t2.total),100*(1-t1.min_value/t2.total), 100*(1-t1.max_value/t2.total) from (select avg(value) as avg_value,max(value) as max_value,min(value) as min_value from metrics_schema.node_memory_available %[1]s) as t1 join (select max(value) as total from metrics_schema.node_total_memory %[1]s) as t2;`, condition) rows, err := querySQL(db, sql) @@ -1720,7 +1720,7 @@ func getAvgMaxMinMemoryUsage(startTime, endTime string, db *gorm.DB) (*TableRowD if len(rows) == 0 { return nil, nil } - sql = fmt.Sprintf(`select 'node_mem_usage',t1.instance, 100*(1-t1.avg_value/t2.total) as avg_value, 100*(1-t1.min_value/t2.total), 100*(1-t1.max_value/t2.total) from + sql = fmt.Sprintf(`select 'node_mem_usage',t1.instance, 100*(1-t1.avg_value/t2.total) as avg_value, 100*(1-t1.min_value/t2.total), 100*(1-t1.max_value/t2.total) from (select instance, avg(value) as avg_value,max(value) as max_value,min(value) as min_value from metrics_schema.node_memory_available %[1]s GROUP BY instance) as t1 join (select instance, max(value) as total from metrics_schema.node_total_memory %[1]s GROUP BY instance) as t2 where t1.instance = t2.instance order by avg_value desc;`, condition) subRows, err := querySQL(db, sql) @@ -2123,7 +2123,7 @@ func GetClusterHardwareInfoTable(startTime, endTime string, db *gorm.DB) (TableD sql := `SELECT instance,type,NAME,VALUE FROM information_schema.CLUSTER_HARDWARE WHERE device_type='cpu' - group by instance,type,VALUE,NAME HAVING NAME = 'cpu-physical-cores' + group by instance,type,VALUE,NAME HAVING NAME = 'cpu-physical-cores' OR NAME = 'cpu-logical-cores' ORDER BY INSTANCE ` rows, err := querySQL(db, sql) if err != nil { diff --git a/pkg/apiserver/info/info.go b/pkg/apiserver/info/info.go index c298ca256c..689f4411ef 100644 --- a/pkg/apiserver/info/info.go +++ b/pkg/apiserver/info/info.go @@ -21,12 +21,12 @@ import ( "github.com/gin-gonic/gin" "go.uber.org/fx" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/user" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/utils" - "github.com/pingcap-incubator/tidb-dashboard/pkg/config" - "github.com/pingcap-incubator/tidb-dashboard/pkg/dbstore" - "github.com/pingcap-incubator/tidb-dashboard/pkg/tidb" - "github.com/pingcap-incubator/tidb-dashboard/pkg/utils/version" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/user" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/utils" + "github.com/pingcap/tidb-dashboard/pkg/config" + "github.com/pingcap/tidb-dashboard/pkg/dbstore" + "github.com/pingcap/tidb-dashboard/pkg/tidb" + "github.com/pingcap/tidb-dashboard/pkg/utils/version" ) type ServiceParams struct { diff --git a/pkg/apiserver/logsearch/models.go b/pkg/apiserver/logsearch/models.go index 82b79f027a..de16f10c67 100644 --- a/pkg/apiserver/logsearch/models.go +++ b/pkg/apiserver/logsearch/models.go @@ -20,8 +20,8 @@ import ( "github.com/pingcap/kvproto/pkg/diagnosticspb" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/model" - "github.com/pingcap-incubator/tidb-dashboard/pkg/dbstore" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/model" + "github.com/pingcap/tidb-dashboard/pkg/dbstore" ) type TaskState int diff --git a/pkg/apiserver/logsearch/pack.go b/pkg/apiserver/logsearch/pack.go index eb0e55d0ed..a4e9f9beb4 100644 --- a/pkg/apiserver/logsearch/pack.go +++ b/pkg/apiserver/logsearch/pack.go @@ -21,7 +21,7 @@ import ( "github.com/pingcap/log" "go.uber.org/zap" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/utils" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/utils" ) func serveTaskForDownload(task *TaskModel, c *gin.Context) { diff --git a/pkg/apiserver/logsearch/service.go b/pkg/apiserver/logsearch/service.go index d73c113531..92fed7a465 100644 --- a/pkg/apiserver/logsearch/service.go +++ b/pkg/apiserver/logsearch/service.go @@ -25,11 +25,11 @@ import ( "go.uber.org/fx" "go.uber.org/zap" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/model" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/user" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/utils" - "github.com/pingcap-incubator/tidb-dashboard/pkg/config" - "github.com/pingcap-incubator/tidb-dashboard/pkg/dbstore" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/model" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/user" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/utils" + "github.com/pingcap/tidb-dashboard/pkg/config" + "github.com/pingcap/tidb-dashboard/pkg/dbstore" ) type Service struct { diff --git a/pkg/apiserver/logsearch/task.go b/pkg/apiserver/logsearch/task.go index 60ddd64ac2..cb6a1f0208 100644 --- a/pkg/apiserver/logsearch/task.go +++ b/pkg/apiserver/logsearch/task.go @@ -34,7 +34,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/credentials" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/model" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/model" ) // MaxRecvMsgSize set max gRPC receive message size received from server. If any message size is larger than diff --git a/pkg/apiserver/metrics/prom_resolve.go b/pkg/apiserver/metrics/prom_resolve.go index 5c65b1762b..ec041409d3 100644 --- a/pkg/apiserver/metrics/prom_resolve.go +++ b/pkg/apiserver/metrics/prom_resolve.go @@ -21,7 +21,7 @@ import ( "strings" "time" - "github.com/pingcap-incubator/tidb-dashboard/pkg/utils/topology" + "github.com/pingcap/tidb-dashboard/pkg/utils/topology" ) const ( diff --git a/pkg/apiserver/metrics/router.go b/pkg/apiserver/metrics/router.go index 59a33611f3..1060ff9116 100644 --- a/pkg/apiserver/metrics/router.go +++ b/pkg/apiserver/metrics/router.go @@ -22,8 +22,8 @@ import ( "github.com/gin-gonic/gin" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/user" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/utils" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/user" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/utils" ) type QueryRequest struct { diff --git a/pkg/apiserver/metrics/service.go b/pkg/apiserver/metrics/service.go index 91bedfd578..7cac7bcc49 100644 --- a/pkg/apiserver/metrics/service.go +++ b/pkg/apiserver/metrics/service.go @@ -23,8 +23,8 @@ import ( "go.uber.org/fx" "golang.org/x/sync/singleflight" - "github.com/pingcap-incubator/tidb-dashboard/pkg/httpc" - "github.com/pingcap-incubator/tidb-dashboard/pkg/pd" + "github.com/pingcap/tidb-dashboard/pkg/httpc" + "github.com/pingcap/tidb-dashboard/pkg/pd" ) var ( diff --git a/pkg/apiserver/profiling/model.go b/pkg/apiserver/profiling/model.go index 57d53ff9dc..cf6569bb5e 100644 --- a/pkg/apiserver/profiling/model.go +++ b/pkg/apiserver/profiling/model.go @@ -18,9 +18,9 @@ import ( "fmt" "time" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/model" - "github.com/pingcap-incubator/tidb-dashboard/pkg/dbstore" - "github.com/pingcap-incubator/tidb-dashboard/pkg/httpc" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/model" + "github.com/pingcap/tidb-dashboard/pkg/dbstore" + "github.com/pingcap/tidb-dashboard/pkg/httpc" ) // TaskState is used to represent the task/task group state. diff --git a/pkg/apiserver/profiling/profile.go b/pkg/apiserver/profiling/profile.go index 42c9010321..336973e248 100644 --- a/pkg/apiserver/profiling/profile.go +++ b/pkg/apiserver/profiling/profile.go @@ -29,8 +29,8 @@ import ( "github.com/google/pprof/driver" "github.com/google/pprof/profile" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/model" - "github.com/pingcap-incubator/tidb-dashboard/pkg/httpc" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/model" + "github.com/pingcap/tidb-dashboard/pkg/httpc" ) var ( diff --git a/pkg/apiserver/profiling/router.go b/pkg/apiserver/profiling/router.go index a09eca5b1c..470b8577a9 100644 --- a/pkg/apiserver/profiling/router.go +++ b/pkg/apiserver/profiling/router.go @@ -24,9 +24,9 @@ import ( "github.com/pingcap/log" "go.uber.org/zap" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/user" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/utils" - "github.com/pingcap-incubator/tidb-dashboard/pkg/config" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/user" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/utils" + "github.com/pingcap/tidb-dashboard/pkg/config" ) // Register register the handlers to the service. diff --git a/pkg/apiserver/profiling/service.go b/pkg/apiserver/profiling/service.go index c03d5341a1..34e27b1f3b 100644 --- a/pkg/apiserver/profiling/service.go +++ b/pkg/apiserver/profiling/service.go @@ -23,10 +23,10 @@ import ( "go.uber.org/fx" "go.uber.org/zap" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/model" - "github.com/pingcap-incubator/tidb-dashboard/pkg/config" - "github.com/pingcap-incubator/tidb-dashboard/pkg/dbstore" - "github.com/pingcap-incubator/tidb-dashboard/pkg/httpc" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/model" + "github.com/pingcap/tidb-dashboard/pkg/config" + "github.com/pingcap/tidb-dashboard/pkg/dbstore" + "github.com/pingcap/tidb-dashboard/pkg/httpc" ) const ( diff --git a/pkg/apiserver/queryeditor/service.go b/pkg/apiserver/queryeditor/service.go index 8665fb9a09..382e5d63b4 100644 --- a/pkg/apiserver/queryeditor/service.go +++ b/pkg/apiserver/queryeditor/service.go @@ -24,10 +24,10 @@ import ( "go.uber.org/fx" "go.uber.org/zap" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/user" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/utils" - "github.com/pingcap-incubator/tidb-dashboard/pkg/config" - "github.com/pingcap-incubator/tidb-dashboard/pkg/tidb" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/user" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/utils" + "github.com/pingcap/tidb-dashboard/pkg/config" + "github.com/pingcap/tidb-dashboard/pkg/tidb" ) type ServiceParams struct { diff --git a/pkg/apiserver/slowquery/queries.go b/pkg/apiserver/slowquery/queries.go index 6b356cd4ed..402dd61c7e 100644 --- a/pkg/apiserver/slowquery/queries.go +++ b/pkg/apiserver/slowquery/queries.go @@ -233,6 +233,11 @@ func QuerySlowLogList(db *gorm.DB, req *GetListRequest) ([]SlowQuery, error) { if strings.Contains(order[0], " AS ") { order[0] = req.OrderBy } + if order[0] == "timestamp" { + // Order by column instead of expression, see related optimization in TiDB: https://github.com/pingcap/tidb/pull/20750 + order[0] = "Time" + } + if req.IsDesc { tx = tx.Order(fmt.Sprintf("%s DESC", order[0])) } else { diff --git a/pkg/apiserver/slowquery/service.go b/pkg/apiserver/slowquery/service.go index 624d57de9d..5ddf8d586d 100644 --- a/pkg/apiserver/slowquery/service.go +++ b/pkg/apiserver/slowquery/service.go @@ -24,9 +24,9 @@ import ( "github.com/gin-gonic/gin" "go.uber.org/fx" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/user" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/utils" - "github.com/pingcap-incubator/tidb-dashboard/pkg/tidb" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/user" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/utils" + "github.com/pingcap/tidb-dashboard/pkg/tidb" ) var ( diff --git a/pkg/apiserver/statement/service.go b/pkg/apiserver/statement/service.go index fce356bc85..1f586928ab 100644 --- a/pkg/apiserver/statement/service.go +++ b/pkg/apiserver/statement/service.go @@ -25,9 +25,9 @@ import ( "go.uber.org/fx" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/user" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/utils" - "github.com/pingcap-incubator/tidb-dashboard/pkg/tidb" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/user" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/utils" + "github.com/pingcap/tidb-dashboard/pkg/tidb" ) var ( diff --git a/pkg/apiserver/user/auth.go b/pkg/apiserver/user/auth.go index 39bf30757b..05b6d6f653 100644 --- a/pkg/apiserver/user/auth.go +++ b/pkg/apiserver/user/auth.go @@ -28,8 +28,8 @@ import ( "github.com/pingcap/log" "go.uber.org/zap" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/utils" - "github.com/pingcap-incubator/tidb-dashboard/pkg/tidb" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/utils" + "github.com/pingcap/tidb-dashboard/pkg/tidb" ) var ( diff --git a/pkg/apiserver/utils/auth.go b/pkg/apiserver/utils/auth.go index d4cd8d7e78..411f3c0c0b 100644 --- a/pkg/apiserver/utils/auth.go +++ b/pkg/apiserver/utils/auth.go @@ -40,7 +40,7 @@ const ( SessionUserKey = "user" // Max permitted lifetime of a shared session. - MaxSessionShareExpiry = time.Hour * 24 + MaxSessionShareExpiry = time.Hour * 24 * 30 ) // The secret is always regenerated each time starting TiDB Dashboard. diff --git a/pkg/apiserver/utils/export.go b/pkg/apiserver/utils/export.go index e255f8cba2..8af46905a9 100644 --- a/pkg/apiserver/utils/export.go +++ b/pkg/apiserver/utils/export.go @@ -13,9 +13,9 @@ import ( "github.com/Xeoncross/go-aesctr-with-hmac" "github.com/gin-gonic/gin" "github.com/gtank/cryptopasta" + "github.com/oleiade/reflections" "github.com/pingcap/log" "go.uber.org/zap" - "gopkg.in/oleiade/reflections.v1" "reflect" "time" diff --git a/pkg/apiserver/utils/tidb_conn.go b/pkg/apiserver/utils/tidb_conn.go index c6c3f1c905..c2fc0277ad 100644 --- a/pkg/apiserver/utils/tidb_conn.go +++ b/pkg/apiserver/utils/tidb_conn.go @@ -20,7 +20,7 @@ import ( "github.com/jinzhu/gorm" "github.com/joomcode/errorx" - "github.com/pingcap-incubator/tidb-dashboard/pkg/tidb" + "github.com/pingcap/tidb-dashboard/pkg/tidb" ) const ( diff --git a/pkg/config/dynamic_config.go b/pkg/config/dynamic_config.go index e376faafeb..2added6ba4 100644 --- a/pkg/config/dynamic_config.go +++ b/pkg/config/dynamic_config.go @@ -14,7 +14,7 @@ package config import ( - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/model" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/model" ) const ( diff --git a/pkg/config/dynamic_config_manager.go b/pkg/config/dynamic_config_manager.go index 3aafd73a42..1c935e172d 100644 --- a/pkg/config/dynamic_config_manager.go +++ b/pkg/config/dynamic_config_manager.go @@ -30,7 +30,8 @@ import ( const ( DynamicConfigPath = "/dashboard/dynamic_config" Timeout = time.Second - MaxCheckInterval = 5 * time.Second + MaxCheckInterval = 30 * time.Second + MaxElapsedTime = 0 // never stop if MaxElapsedTime == 0 ) var ( @@ -71,6 +72,7 @@ func (m *DynamicConfigManager) Start(ctx context.Context) error { var dc *DynamicConfig ebo := backoff.NewExponentialBackOff() ebo.MaxInterval = MaxCheckInterval + ebo.MaxElapsedTime = MaxElapsedTime bo := backoff.WithContext(ebo, ctx) if err := backoff.Retry(func() error { diff --git a/pkg/dbstore/dbstore.go b/pkg/dbstore/dbstore.go index 049ac60553..41d89d24a1 100644 --- a/pkg/dbstore/dbstore.go +++ b/pkg/dbstore/dbstore.go @@ -27,7 +27,7 @@ import ( "go.uber.org/fx" "go.uber.org/zap" - "github.com/pingcap-incubator/tidb-dashboard/pkg/config" + "github.com/pingcap/tidb-dashboard/pkg/config" ) type DB struct { diff --git a/pkg/httpc/client.go b/pkg/httpc/client.go index d30b4b330a..904573bf3a 100644 --- a/pkg/httpc/client.go +++ b/pkg/httpc/client.go @@ -27,7 +27,7 @@ import ( "go.uber.org/fx" "go.uber.org/zap" - "github.com/pingcap-incubator/tidb-dashboard/pkg/config" + "github.com/pingcap/tidb-dashboard/pkg/config" ) const ( diff --git a/pkg/keyvisual/decorator/decorator.go b/pkg/keyvisual/decorator/decorator.go index b5b9dc3530..71bb717a65 100644 --- a/pkg/keyvisual/decorator/decorator.go +++ b/pkg/keyvisual/decorator/decorator.go @@ -17,7 +17,7 @@ package decorator import ( "encoding/hex" - "github.com/pingcap-incubator/tidb-dashboard/pkg/config" + "github.com/pingcap/tidb-dashboard/pkg/config" ) // LabelKey is the decoration key. @@ -27,41 +27,49 @@ type LabelKey struct { } // LabelStrategy requires cross-border determination and key decoration scheme. +// It supports dynamic reload configuration and generation of an actuator. type LabelStrategy interface { ReloadConfig(cfg *config.KeyVisualConfig) + NewLabeler() Labeler +} + +// Labeler is an executor of LabelStrategy, and its functions should not be called concurrently. +type Labeler interface { // CrossBorder determines whether two keys not belong to the same logical range. CrossBorder(startKey, endKey string) bool - // Label returns the Label information of the key. - // Note: When the key is "", need to use LabelGlobalStart or LabelGlobalEnd. - Label(key string) LabelKey - LabelGlobalStart() LabelKey - LabelGlobalEnd() LabelKey + // Label returns the Label information of the keys. + Label(keys []string) []LabelKey } // NaiveLabelStrategy is one of the simplest LabelStrategy. -type NaiveLabelStrategy struct{} - -func (s NaiveLabelStrategy) ReloadConfig(cfg *config.KeyVisualConfig) { +func NaiveLabelStrategy() LabelStrategy { + return naiveLabelStrategy{} } -// CrossBorder always returns false. So NaiveLabelStrategy believes that there are no cross-border situations. -func (s NaiveLabelStrategy) CrossBorder(startKey, endKey string) bool { - return false -} +type naiveLabelStrategy struct{} -// Label only decodes the key. -func (s NaiveLabelStrategy) Label(key string) LabelKey { - str := hex.EncodeToString([]byte(key)) - return LabelKey{ - Key: str, - Labels: []string{str}, - } +type naiveLabeler struct{} + +func (s naiveLabelStrategy) ReloadConfig(cfg *config.KeyVisualConfig) {} + +func (s naiveLabelStrategy) NewLabeler() Labeler { + return naiveLabeler{} } -func (s NaiveLabelStrategy) LabelGlobalStart() LabelKey { - return s.Label("") +// CrossBorder always returns false. So naiveLabelStrategy believes that there are no cross-border situations. +func (e naiveLabeler) CrossBorder(startKey, endKey string) bool { + return false } -func (s NaiveLabelStrategy) LabelGlobalEnd() LabelKey { - return s.Label("") +// Label only encodes the keys. +func (e naiveLabeler) Label(keys []string) []LabelKey { + labelKeys := make([]LabelKey, len(keys)) + for i, key := range keys { + str := hex.EncodeToString([]byte(key)) + labelKeys[i] = LabelKey{ + Key: str, + Labels: []string{str}, + } + } + return labelKeys } diff --git a/pkg/keyvisual/decorator/separator.go b/pkg/keyvisual/decorator/separator.go index 499bb9f262..3a74943dc5 100644 --- a/pkg/keyvisual/decorator/separator.go +++ b/pkg/keyvisual/decorator/separator.go @@ -1,3 +1,16 @@ +// Copyright 2019 PingCAP, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// See the License for the specific language governing permissions and +// limitations under the License. + package decorator import ( @@ -7,47 +20,55 @@ import ( "github.com/pingcap/log" "go.uber.org/zap" - "github.com/pingcap-incubator/tidb-dashboard/pkg/config" + "github.com/pingcap/tidb-dashboard/pkg/config" ) -// NaiveLabelStrategy is one of the simplest LabelStrategy. -type separatorLabelStrategy struct { - Separator atomic.Value -} - +// SeparatorLabelStrategy implements the LabelStrategy interface. It obtains label information after splitting the key. func SeparatorLabelStrategy(cfg *config.KeyVisualConfig) LabelStrategy { s := &separatorLabelStrategy{} s.Separator.Store(cfg.PolicyKVSeparator) return s } +type separatorLabelStrategy struct { + Separator atomic.Value +} + +type separatorLabeler struct { + Separator string +} + // ReloadConfig reset separator func (s *separatorLabelStrategy) ReloadConfig(cfg *config.KeyVisualConfig) { s.Separator.Store(cfg.PolicyKVSeparator) log.Debug("Reload config", zap.String("separator", cfg.PolicyKVSeparator)) } +func (s *separatorLabelStrategy) NewLabeler() Labeler { + return &separatorLabeler{ + Separator: s.Separator.Load().(string), + } +} + // CrossBorder is temporarily not considering cross-border logic -func (s *separatorLabelStrategy) CrossBorder(startKey, endKey string) bool { +func (e *separatorLabeler) CrossBorder(startKey, endKey string) bool { return false } // Label uses separator to split key -func (s *separatorLabelStrategy) Label(key string) (label LabelKey) { - label.Key = key - separator := s.Separator.Load().(string) - if separator == "" { - label.Labels = []string{key} - return +func (e *separatorLabeler) Label(keys []string) []LabelKey { + labelKeys := make([]LabelKey, len(keys)) + for i, key := range keys { + var labels []string + if e.Separator == "" { + labels = []string{key} + } else { + labels = strings.Split(key, e.Separator) + } + labelKeys[i] = LabelKey{ + Key: key, + Labels: labels, + } } - label.Labels = strings.Split(key, separator) - return -} - -func (s *separatorLabelStrategy) LabelGlobalStart() LabelKey { - return s.Label("") -} - -func (s *separatorLabelStrategy) LabelGlobalEnd() LabelKey { - return s.Label("") + return labelKeys } diff --git a/pkg/keyvisual/decorator/tidb.go b/pkg/keyvisual/decorator/tidb.go index 7a5f31b505..ba0a953829 100644 --- a/pkg/keyvisual/decorator/tidb.go +++ b/pkg/keyvisual/decorator/tidb.go @@ -23,33 +23,15 @@ import ( "go.etcd.io/etcd/clientv3" "go.uber.org/fx" - "github.com/pingcap-incubator/tidb-dashboard/pkg/config" - "github.com/pingcap-incubator/tidb-dashboard/pkg/keyvisual/region" - "github.com/pingcap-incubator/tidb-dashboard/pkg/tidb" - "github.com/pingcap-incubator/tidb-dashboard/pkg/tidb/model" + "github.com/pingcap/tidb-dashboard/pkg/config" + "github.com/pingcap/tidb-dashboard/pkg/keyvisual/region" + "github.com/pingcap/tidb-dashboard/pkg/tidb" + "github.com/pingcap/tidb-dashboard/pkg/tidb/model" ) -type tableDetail struct { - Name string - DB string - ID int64 - Indices map[int64]string -} - -type tidbLabelStrategy struct { - Config *config.Config - EtcdClient *clientv3.Client - - TableMap sync.Map - tidbClient *tidb.Client - SchemaVersion int64 - TidbAddress []string -} - -// TiDBLabelStrategy implements the LabelStrategy interface. Get Label Information from TiDB. -func TiDBLabelStrategy(lc fx.Lifecycle, wg *sync.WaitGroup, cfg *config.Config, etcdClient *clientv3.Client, tidbClient *tidb.Client) LabelStrategy { +// TiDBLabelStrategy implements the LabelStrategy interface. It obtains Label Information from TiDB. +func TiDBLabelStrategy(lc fx.Lifecycle, wg *sync.WaitGroup, etcdClient *clientv3.Client, tidbClient *tidb.Client) LabelStrategy { s := &tidbLabelStrategy{ - Config: cfg, EtcdClient: etcdClient, tidbClient: tidbClient, SchemaVersion: -1, @@ -69,9 +51,30 @@ func TiDBLabelStrategy(lc fx.Lifecycle, wg *sync.WaitGroup, cfg *config.Config, return s } -func (s *tidbLabelStrategy) ReloadConfig(cfg *config.KeyVisualConfig) { +type tableDetail struct { + Name string + DB string + ID int64 + Indices map[int64]string +} + +type tidbLabelStrategy struct { + Config *config.Config + EtcdClient *clientv3.Client + + TableMap sync.Map + tidbClient *tidb.Client + SchemaVersion int64 + TidbAddress []string +} + +type tidbLabeler struct { + TableMap *sync.Map + Buffer model.KeyInfoBuffer } +func (s *tidbLabelStrategy) ReloadConfig(cfg *config.KeyVisualConfig) {} + func (s *tidbLabelStrategy) Background(ctx context.Context) { ticker := time.NewTicker(time.Minute) defer ticker.Stop() @@ -85,43 +88,78 @@ func (s *tidbLabelStrategy) Background(ctx context.Context) { } } +func (s *tidbLabelStrategy) NewLabeler() Labeler { + return &tidbLabeler{ + TableMap: &s.TableMap, + } +} + // CrossBorder does not allow cross tables or cross indexes within a table. -func (s *tidbLabelStrategy) CrossBorder(startKey, endKey string) bool { - startBytes, endBytes := model.Key(region.Bytes(startKey)), model.Key(region.Bytes(endKey)) - startIsMeta, startTableID := startBytes.MetaOrTable() - endIsMeta, endTableID := endBytes.MetaOrTable() +func (e *tidbLabeler) CrossBorder(startKey, endKey string) bool { + startInfo, _ := e.Buffer.DecodeKey(region.Bytes(startKey)) + startIsMeta, startTableID := startInfo.MetaOrTable() + startIndex := startInfo.IndexInfo() + + endInfo, _ := e.Buffer.DecodeKey(region.Bytes(endKey)) + endIsMeta, endTableID := endInfo.MetaOrTable() + endIndex := endInfo.IndexInfo() + if startIsMeta || endIsMeta { return startIsMeta != endIsMeta } if startTableID != endTableID { return true } - startIndex := startBytes.IndexID() - endIndex := endBytes.IndexID() return startIndex != endIndex } // Label will parse the ID information of the table and index. -func (s *tidbLabelStrategy) Label(key string) (label LabelKey) { +func (e *tidbLabeler) Label(keys []string) []LabelKey { + labelKeys := make([]LabelKey, len(keys)) + for i, key := range keys { + labelKeys[i] = e.label(key) + } + + if keys[0] == "" { + labelKeys[0] = globalStart + } + endIndex := len(keys) - 1 + if keys[endIndex] == "" { + labelKeys[endIndex] = globalEnd + } + + return labelKeys +} + +func (e *tidbLabeler) label(key string) (label LabelKey) { keyBytes := region.Bytes(key) label.Key = hex.EncodeToString(keyBytes) - decodeKey := model.Key(keyBytes) - isMeta, TableID := decodeKey.MetaOrTable() + keyInfo, _ := e.Buffer.DecodeKey(keyBytes) + + isMeta, tableID := keyInfo.MetaOrTable() if isMeta { label.Labels = append(label.Labels, "meta") - } else if v, ok := s.TableMap.Load(TableID); ok { - detail := v.(*tableDetail) + return + } + + var detail *tableDetail + if v, ok := e.TableMap.Load(tableID); ok { + detail = v.(*tableDetail) label.Labels = append(label.Labels, detail.DB, detail.Name) - if rowID := decodeKey.RowID(); rowID != 0 { - label.Labels = append(label.Labels, fmt.Sprintf("row_%d", rowID)) - } else if indexID := decodeKey.IndexID(); indexID != 0 { - label.Labels = append(label.Labels, detail.Indices[indexID]) - } } else { - label.Labels = append(label.Labels, fmt.Sprintf("table_%d", TableID)) - if rowID := decodeKey.RowID(); rowID != 0 { - label.Labels = append(label.Labels, fmt.Sprintf("row_%d", rowID)) - } else if indexID := decodeKey.IndexID(); indexID != 0 { + label.Labels = append(label.Labels, fmt.Sprintf("table_%d", tableID)) + } + + if isCommonHandle, rowID := keyInfo.RowInfo(); isCommonHandle { + label.Labels = append(label.Labels, "row") + } else if rowID != 0 { + label.Labels = append(label.Labels, fmt.Sprintf("row_%d", rowID)) + } else if indexID := keyInfo.IndexInfo(); indexID != 0 { + if detail == nil { + label.Labels = append(label.Labels, fmt.Sprintf("index_%d", indexID)) + } else if name, ok := detail.Indices[indexID]; ok { + label.Labels = append(label.Labels, name) + } else { label.Labels = append(label.Labels, fmt.Sprintf("index_%d", indexID)) } } @@ -137,11 +175,3 @@ var globalEnd = LabelKey{ Key: "", Labels: []string{}, } - -func (s *tidbLabelStrategy) LabelGlobalStart() LabelKey { - return globalStart -} - -func (s *tidbLabelStrategy) LabelGlobalEnd() LabelKey { - return globalEnd -} diff --git a/pkg/keyvisual/decorator/tidb_requests.go b/pkg/keyvisual/decorator/tidb_requests.go index 20a3e3f1a6..0b5d73b504 100644 --- a/pkg/keyvisual/decorator/tidb_requests.go +++ b/pkg/keyvisual/decorator/tidb_requests.go @@ -17,6 +17,7 @@ import ( "context" "encoding/json" "fmt" + "net/url" "strconv" "time" @@ -24,7 +25,7 @@ import ( "github.com/pingcap/log" "go.uber.org/zap" - "github.com/pingcap-incubator/tidb-dashboard/pkg/tidb/model" + "github.com/pingcap/tidb-dashboard/pkg/tidb/model" ) const ( @@ -73,7 +74,8 @@ func (s *tidbLabelStrategy) updateMap(ctx context.Context) { continue } var tableInfos []*model.TableInfo - if err := s.request(fmt.Sprintf("/schema/%s", db.Name.O), &tableInfos); err != nil { + encodeName := url.PathEscape(db.Name.O) + if err := s.request(fmt.Sprintf("/schema/%s", encodeName), &tableInfos); err != nil { log.Error("fail to send schema request to TiDB", zap.Error(err)) updateSuccess = false continue diff --git a/pkg/keyvisual/input/api.go b/pkg/keyvisual/input/api.go index 0c852a4f3f..3579ab4d33 100644 --- a/pkg/keyvisual/input/api.go +++ b/pkg/keyvisual/input/api.go @@ -20,8 +20,8 @@ import ( "github.com/joomcode/errorx" - regionpkg "github.com/pingcap-incubator/tidb-dashboard/pkg/keyvisual/region" - "github.com/pingcap-incubator/tidb-dashboard/pkg/pd" + regionpkg "github.com/pingcap/tidb-dashboard/pkg/keyvisual/region" + "github.com/pingcap/tidb-dashboard/pkg/pd" ) var ( diff --git a/pkg/keyvisual/input/file.go b/pkg/keyvisual/input/file.go index 93358c7999..7d7c007be9 100644 --- a/pkg/keyvisual/input/file.go +++ b/pkg/keyvisual/input/file.go @@ -22,7 +22,7 @@ import ( "github.com/pingcap/log" "go.uber.org/zap" - "github.com/pingcap-incubator/tidb-dashboard/pkg/keyvisual/storage" + "github.com/pingcap/tidb-dashboard/pkg/keyvisual/storage" ) type fileInput struct { diff --git a/pkg/keyvisual/input/input.go b/pkg/keyvisual/input/input.go index a460ba34b9..ca5a382183 100644 --- a/pkg/keyvisual/input/input.go +++ b/pkg/keyvisual/input/input.go @@ -20,8 +20,8 @@ import ( "github.com/pingcap/log" - "github.com/pingcap-incubator/tidb-dashboard/pkg/keyvisual/region" - "github.com/pingcap-incubator/tidb-dashboard/pkg/keyvisual/storage" + "github.com/pingcap/tidb-dashboard/pkg/keyvisual/region" + "github.com/pingcap/tidb-dashboard/pkg/keyvisual/storage" ) // StatInput is the interface that different data inputs need to implement. diff --git a/pkg/keyvisual/input/periodic.go b/pkg/keyvisual/input/periodic.go index b25a7fadf4..278e7fde74 100644 --- a/pkg/keyvisual/input/periodic.go +++ b/pkg/keyvisual/input/periodic.go @@ -20,8 +20,8 @@ import ( "github.com/pingcap/log" "go.uber.org/zap" - "github.com/pingcap-incubator/tidb-dashboard/pkg/keyvisual/region" - "github.com/pingcap-incubator/tidb-dashboard/pkg/keyvisual/storage" + "github.com/pingcap/tidb-dashboard/pkg/keyvisual/region" + "github.com/pingcap/tidb-dashboard/pkg/keyvisual/storage" ) type periodicInput struct { diff --git a/pkg/keyvisual/manager.go b/pkg/keyvisual/manager.go index 0784619225..de80353469 100644 --- a/pkg/keyvisual/manager.go +++ b/pkg/keyvisual/manager.go @@ -23,8 +23,8 @@ import ( "go.uber.org/fx" "go.uber.org/zap" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/utils" - "github.com/pingcap-incubator/tidb-dashboard/pkg/config" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/utils" + "github.com/pingcap/tidb-dashboard/pkg/config" ) func (s *Service) managerHook() fx.Hook { diff --git a/pkg/keyvisual/matrix/average.go b/pkg/keyvisual/matrix/average.go index 48b1ad5221..1ee1113371 100644 --- a/pkg/keyvisual/matrix/average.go +++ b/pkg/keyvisual/matrix/average.go @@ -13,29 +13,20 @@ package matrix -import ( - "github.com/pingcap-incubator/tidb-dashboard/pkg/keyvisual/decorator" -) - -type averageHelper struct { +// AverageSplitStrategy adopts the strategy of equal distribution when buckets are split. +func AverageSplitStrategy() SplitStrategy { + return averageSplitStrategy{} } -type averageStrategy struct { - decorator.LabelStrategy -} +type averageSplitStrategy struct{} -// AverageStrategy adopts the strategy of equal distribution when buckets are split. -func AverageStrategy(label decorator.LabelStrategy) Strategy { - return averageStrategy{ - LabelStrategy: label, - } -} +type averageSplitter struct{} -func (averageStrategy) GenerateHelper(chunks []chunk, compactKeys []string) interface{} { - return averageHelper{} +func (averageSplitStrategy) NewSplitter(chunks []chunk, compactKeys []string) Splitter { + return averageSplitter{} } -func (averageStrategy) Split(dst, src chunk, tag splitTag, axesIndex int, helper interface{}) { +func (averageSplitter) Split(dst, src chunk, tag splitTag, axesIndex int) { CheckPartOf(dst.Keys, src.Keys) if len(dst.Keys) == len(src.Keys) { diff --git a/pkg/keyvisual/matrix/axis.go b/pkg/keyvisual/matrix/axis.go index 379ea97fc7..a8c4896857 100644 --- a/pkg/keyvisual/matrix/axis.go +++ b/pkg/keyvisual/matrix/axis.go @@ -13,6 +13,10 @@ package matrix +import ( + "github.com/pingcap/tidb-dashboard/pkg/keyvisual/decorator" +) + // Axis stores consecutive buckets. Each bucket has StartKey, EndKey, and some statistics. The EndKey of each bucket is // the StartKey of its next bucket. The actual data structure is stored in columns. Therefore satisfies: // len(Keys) == len(ValuesList[i]) + 1. In particular, ValuesList[0] is the base column. @@ -77,13 +81,13 @@ func (axis *Axis) Range(startKey string, endKey string) Axis { // Focus uses the base column as the chunk for the Focus operation to obtain the partitioning scheme, and uses this to // reduce other columns. -func (axis *Axis) Focus(strategy Strategy, threshold uint64, ratio int, target int) Axis { +func (axis *Axis) Focus(labeler decorator.Labeler, threshold uint64, ratio int, target int) Axis { if target >= len(axis.Keys)-1 { return *axis } baseChunk := createChunk(axis.Keys, axis.ValuesList[0]) - newChunk := baseChunk.Focus(strategy, threshold, ratio, target, MergeColdLogicalRange) + newChunk := baseChunk.Focus(labeler, threshold, ratio, target, MergeColdLogicalRange) valuesListLen := len(axis.ValuesList) newValuesList := make([][]uint64, valuesListLen) newValuesList[0] = newChunk.Values @@ -96,13 +100,13 @@ func (axis *Axis) Focus(strategy Strategy, threshold uint64, ratio int, target i // Divide uses the base column as the chunk for the Divide operation to obtain the partitioning scheme, and uses this to // reduce other columns. -func (axis *Axis) Divide(strategy Strategy, target int) Axis { +func (axis *Axis) Divide(labeler decorator.Labeler, target int) Axis { if target >= len(axis.Keys)-1 { return *axis } baseChunk := createChunk(axis.Keys, axis.ValuesList[0]) - newChunk := baseChunk.Divide(strategy, target, MergeColdLogicalRange) + newChunk := baseChunk.Divide(labeler, target, MergeColdLogicalRange) valuesListLen := len(axis.ValuesList) newValuesList := make([][]uint64, valuesListLen) newValuesList[0] = newChunk.Values @@ -216,7 +220,7 @@ func (c *chunk) GetFocusRows(threshold uint64) (count int) { // Given a `threshold`, merge the rows with less traffic, // and merge the most `ratio` rows at a time. // `target` is the estimated final number of rows. -func (c *chunk) Focus(strategy Strategy, threshold uint64, ratio int, target int, mode FocusMode) chunk { +func (c *chunk) Focus(labeler decorator.Labeler, threshold uint64, ratio int, target int, mode FocusMode) chunk { newKeys := make([]string, 0, target) newValues := make([]uint64, 0, target) newKeys = append(newKeys, c.Keys[0]) @@ -236,7 +240,7 @@ func (c *chunk) Focus(strategy Strategy, threshold uint64, ratio int, target int if value >= threshold || bucketSum >= threshold || i-start >= ratio || - strategy.CrossBorder(c.Keys[start], c.Keys[i]) { + labeler.CrossBorder(c.Keys[start], c.Keys[i]) { generateBucket(i) } bucketSum += value @@ -245,12 +249,12 @@ func (c *chunk) Focus(strategy Strategy, threshold uint64, ratio int, target int newChunk := createChunk(newKeys, newValues) if mode == MergeColdLogicalRange && len(newValues) >= target { - newChunk = newChunk.MergeColdLogicalRange(strategy, threshold, target) + newChunk = newChunk.MergeColdLogicalRange(labeler, threshold, target) } return newChunk } -func (c *chunk) MergeColdLogicalRange(strategy Strategy, threshold uint64, target int) chunk { +func (c *chunk) MergeColdLogicalRange(labeler decorator.Labeler, threshold uint64, target int) chunk { threshold /= 4 // TODO: This var can be adjusted newKeys := make([]string, 0, target) @@ -291,7 +295,7 @@ func (c *chunk) MergeColdLogicalRange(strategy Strategy, threshold uint64, targe } for i := range c.Values { - if strategy.CrossBorder(c.Keys[i], c.Keys[i+1]) { + if labeler.CrossBorder(c.Keys[i], c.Keys[i+1]) { generateRange(i + 1) } } @@ -302,7 +306,7 @@ func (c *chunk) MergeColdLogicalRange(strategy Strategy, threshold uint64, targe } // Divide uses binary search to find a suitable threshold, which can reduce the number of buckets of Axis to near the target. -func (c *chunk) Divide(strategy Strategy, target int, mode FocusMode) chunk { +func (c *chunk) Divide(labeler decorator.Labeler, target int, mode FocusMode) chunk { if target >= len(c.Values) { return *c } @@ -326,5 +330,5 @@ func (c *chunk) Divide(strategy Strategy, target int, mode FocusMode) chunk { threshold := lowerThreshold focusRows := c.GetFocusRows(threshold) ratio := len(c.Values)/(target-focusRows) + 1 - return c.Focus(strategy, threshold, ratio, target, mode) + return c.Focus(labeler, threshold, ratio, target, mode) } diff --git a/pkg/keyvisual/matrix/distance.go b/pkg/keyvisual/matrix/distance.go index 7383fd3eb8..0021570cf9 100644 --- a/pkg/keyvisual/matrix/distance.go +++ b/pkg/keyvisual/matrix/distance.go @@ -21,39 +21,18 @@ import ( "sync" "go.uber.org/fx" - - "github.com/pingcap-incubator/tidb-dashboard/pkg/keyvisual/decorator" ) // TODO: // * Multiplexing data between requests // * Limit memory usage -type distanceHelper struct { - Scale [][]float64 -} - -type distanceStrategy struct { - decorator.LabelStrategy - - SplitRatio float64 - SplitLevel int - SplitCount int - - SplitRatioPow []float64 - - ScaleWorkerCh chan *scaleTask -} - -// DistanceStrategy adopts the strategy that the closer the split time is to the current time, the more traffic is -// allocated, when buckets are split. -func DistanceStrategy(lc fx.Lifecycle, wg *sync.WaitGroup, label decorator.LabelStrategy, ratio float64, level int, count int) Strategy { +func DistanceSplitStrategy(lc fx.Lifecycle, wg *sync.WaitGroup, ratio float64, level int, count int) SplitStrategy { pow := make([]float64, level) for i := range pow { pow[i] = math.Pow(ratio, float64(i)) } - s := &distanceStrategy{ - LabelStrategy: label, + s := &distanceSplitStrategy{ SplitRatio: ratio, SplitLevel: level, SplitCount: count, @@ -74,7 +53,21 @@ func DistanceStrategy(lc fx.Lifecycle, wg *sync.WaitGroup, label decorator.Label return s } -func (s *distanceStrategy) GenerateHelper(chunks []chunk, compactKeys []string) interface{} { +type distanceSplitStrategy struct { + SplitRatio float64 + SplitLevel int + SplitCount int + + SplitRatioPow []float64 + + ScaleWorkerCh chan *scaleTask +} + +type distanceSplitter struct { + Scale [][]float64 +} + +func (s *distanceSplitStrategy) NewSplitter(chunks []chunk, compactKeys []string) Splitter { axesLen := len(chunks) keysLen := len(compactKeys) @@ -100,12 +93,12 @@ func (s *distanceStrategy) GenerateHelper(chunks []chunk, compactKeys []string) updateRightDis(dis[i], dis[i+1], chunks[i].Keys, compactKeys) } - return distanceHelper{ + return &distanceSplitter{ Scale: s.GenerateScale(chunks, compactKeys, dis), } } -func (s *distanceStrategy) Split(dst, src chunk, tag splitTag, axesIndex int, helper interface{}) { +func (e *distanceSplitter) Split(dst, src chunk, tag splitTag, axesIndex int) { CheckPartOf(dst.Keys, src.Keys) if len(dst.Keys) == len(src.Keys) { @@ -127,7 +120,6 @@ func (s *distanceStrategy) Split(dst, src chunk, tag splitTag, axesIndex int, he start++ } end := start + 1 - scale := helper.(distanceHelper).Scale switch tag { case splitTo: @@ -137,7 +129,7 @@ func (s *distanceStrategy) Split(dst, src chunk, tag splitTag, axesIndex int, he } value := src.Values[i] for ; start < end; start++ { - dst.Values[start] = uint64(float64(value) * scale[axesIndex][start]) + dst.Values[start] = uint64(float64(value) * e.Scale[axesIndex][start]) } end++ } @@ -148,7 +140,7 @@ func (s *distanceStrategy) Split(dst, src chunk, tag splitTag, axesIndex int, he } value := src.Values[i] for ; start < end; start++ { - dst.Values[start] += uint64(float64(value) * scale[axesIndex][start]) + dst.Values[start] += uint64(float64(value) * e.Scale[axesIndex][start]) } end++ } @@ -175,7 +167,7 @@ type scaleTask struct { Scale *[]float64 } -func (s *distanceStrategy) StartWorkers(ctx context.Context, wg *sync.WaitGroup) { +func (s *distanceSplitStrategy) StartWorkers(ctx context.Context, wg *sync.WaitGroup) { s.ScaleWorkerCh = make(chan *scaleTask, workerCount*100) wg.Add(workerCount) for i := 0; i < workerCount; i++ { @@ -186,11 +178,11 @@ func (s *distanceStrategy) StartWorkers(ctx context.Context, wg *sync.WaitGroup) } } -func (s *distanceStrategy) StopWorkers() { +func (s *distanceSplitStrategy) StopWorkers() { close(s.ScaleWorkerCh) } -func (s *distanceStrategy) GenerateScale(chunks []chunk, compactKeys []string, dis [][]int) [][]float64 { +func (s *distanceSplitStrategy) GenerateScale(chunks []chunk, compactKeys []string, dis [][]int) [][]float64 { var wg sync.WaitGroup axesLen := len(chunks) scale := make([][]float64, axesLen) @@ -208,7 +200,7 @@ func (s *distanceStrategy) GenerateScale(chunks []chunk, compactKeys []string, d return scale } -func (s *distanceStrategy) GenerateScaleColumnWork(ctx context.Context, ch <-chan *scaleTask) { +func (s *distanceSplitStrategy) GenerateScaleColumnWork(ctx context.Context, ch <-chan *scaleTask) { var maxDis int // Each split interval needs to be sorted after copying to tempDis var tempDis []int diff --git a/pkg/keyvisual/matrix/distance_test.go b/pkg/keyvisual/matrix/distance_test.go index 3f62f71c84..da46c1c3ce 100644 --- a/pkg/keyvisual/matrix/distance_test.go +++ b/pkg/keyvisual/matrix/distance_test.go @@ -25,8 +25,6 @@ import ( . "github.com/pingcap/check" "go.uber.org/fx" - - "github.com/pingcap-incubator/tidb-dashboard/pkg/keyvisual/decorator" ) var _ = Suite(&testDistanceSuite{}) @@ -80,21 +78,22 @@ func BenchmarkGenerateScale(b *testing.B) { keymap.SaveKeys(compactKeys) keymap.SaveKeys(data.Keys) - var strategy *distanceStrategy + var strategy SplitStrategy wg := &sync.WaitGroup{} app := fx.New( - fx.Provide(func(lc fx.Lifecycle) Strategy { - return DistanceStrategy(lc, wg, decorator.NaiveLabelStrategy{}, 1.0/math.Phi, 15, 50).(*distanceStrategy) + fx.Provide(func(lc fx.Lifecycle) SplitStrategy { + return DistanceSplitStrategy(lc, wg, 1.0/math.Phi, 15, 50) }), fx.Populate(&strategy), ) _ = app.Start(context.Background()) + s := strategy.(*distanceSplitStrategy) b.ResetTimer() for i := 0; i < b.N; i++ { b.StopTimer() rollbackDis() b.StartTimer() - _ = strategy.GenerateScale(chunks, compactKeys, dis) + _ = s.GenerateScale(chunks, compactKeys, dis) } b.StopTimer() _ = app.Stop(context.Background()) diff --git a/pkg/keyvisual/matrix/interface.go b/pkg/keyvisual/matrix/interface.go index e2d2d2d89f..9a66dc3485 100644 --- a/pkg/keyvisual/matrix/interface.go +++ b/pkg/keyvisual/matrix/interface.go @@ -14,7 +14,7 @@ package matrix import ( - "github.com/pingcap-incubator/tidb-dashboard/pkg/keyvisual/decorator" + "github.com/pingcap/tidb-dashboard/pkg/keyvisual/decorator" ) type splitTag int @@ -24,15 +24,18 @@ const ( splitAdd // Add to original value after split ) -// splitStrategy is an allocation scheme. GenerateHelper is used to generate a helper for a Plane. Split uses this -// helper to split a chunk of columns. -type splitStrategy interface { - GenerateHelper(chunks []chunk, compactKeys []string) interface{} - Split(dst, src chunk, tag splitTag, axesIndex int, helper interface{}) +// SplitStrategy is an allocation scheme. It is used to generate a Splitter for a plane to split a chunk of columns. +type SplitStrategy interface { + NewSplitter(chunks []chunk, compactKeys []string) Splitter +} + +type Splitter interface { + // Split a chunk of columns. + Split(dst, src chunk, tag splitTag, axesIndex int) } // Strategy is part of the customizable strategy in Matrix generation. -type Strategy interface { - splitStrategy +type Strategy struct { decorator.LabelStrategy + SplitStrategy } diff --git a/pkg/keyvisual/matrix/matrix.go b/pkg/keyvisual/matrix/matrix.go index 1868d150a1..89e6ca9886 100644 --- a/pkg/keyvisual/matrix/matrix.go +++ b/pkg/keyvisual/matrix/matrix.go @@ -17,7 +17,7 @@ package matrix import ( "time" - "github.com/pingcap-incubator/tidb-dashboard/pkg/keyvisual/decorator" + "github.com/pingcap/tidb-dashboard/pkg/keyvisual/decorator" ) // Matrix is the front end displays the required data. @@ -29,22 +29,10 @@ type Matrix struct { } // CreateMatrix uses the specified times and keys to build an initial matrix with no data. -func CreateMatrix(strategy Strategy, times []time.Time, keys []string, valuesListLen int) Matrix { +func CreateMatrix(labeler decorator.Labeler, times []time.Time, keys []string, valuesListLen int) Matrix { dataMap := make(map[string][][]uint64, valuesListLen) // collect label keys - keyAxis := make([]decorator.LabelKey, len(keys)) - for i, key := range keys { - keyAxis[i] = strategy.Label(key) - } - - if keys[0] == "" { - keyAxis[0] = strategy.LabelGlobalStart() - } - endIndex := len(keys) - 1 - if keys[endIndex] == "" { - keyAxis[endIndex] = strategy.LabelGlobalEnd() - } - + keyAxis := labeler.Label(keys) // collect unix times timeAxis := make([]int64, len(times)) for i, t := range times { diff --git a/pkg/keyvisual/matrix/plane.go b/pkg/keyvisual/matrix/plane.go index 3e3f2e91cb..7da589767b 100644 --- a/pkg/keyvisual/matrix/plane.go +++ b/pkg/keyvisual/matrix/plane.go @@ -43,12 +43,12 @@ func CreateEmptyPlane(startTime, endTime time.Time, startKey, endKey string, val } // Compact compacts Plane into an axis. -func (plane *Plane) Compact(strategy Strategy) Axis { +func (plane *Plane) Compact(strategy SplitStrategy) Axis { chunks := make([]chunk, len(plane.Axes)) for i, axis := range plane.Axes { chunks[i] = createChunk(axis.Keys, axis.ValuesList[0]) } - compactChunk, helper := compact(strategy, chunks) + compactChunk, splitter := compact(strategy, chunks) valuesListLen := len(plane.Axes[0].ValuesList) valuesList := make([][]uint64, valuesListLen) valuesList[0] = compactChunk.Values @@ -56,7 +56,7 @@ func (plane *Plane) Compact(strategy Strategy) Axis { compactChunk.SetZeroValues() for i, axis := range plane.Axes { chunks[i].SetValues(axis.ValuesList[j]) - strategy.Split(compactChunk, chunks[i], splitAdd, i, helper) + splitter.Split(compactChunk, chunks[i], splitAdd, i) } valuesList[j] = compactChunk.Values } @@ -64,7 +64,7 @@ func (plane *Plane) Compact(strategy Strategy) Axis { } // Pixel pixelates Plane into a matrix with a number of rows close to the target. -func (plane *Plane) Pixel(strategy Strategy, target int, displayTags []string) Matrix { +func (plane *Plane) Pixel(strategy *Strategy, target int, displayTags []string) Matrix { valuesListLen := len(plane.Axes[0].ValuesList) if valuesListLen != len(displayTags) { panic("the length of displayTags and valuesList should be equal") @@ -74,9 +74,10 @@ func (plane *Plane) Pixel(strategy Strategy, target int, displayTags []string) M for i, axis := range plane.Axes { chunks[i] = createChunk(axis.Keys, axis.ValuesList[0]) } - compactChunk, helper := compact(strategy, chunks) - baseKeys := compactChunk.Divide(strategy, target, NotMergeLogicalRange).Keys - matrix := CreateMatrix(strategy, plane.Times, baseKeys, valuesListLen) + compactChunk, splitter := compact(strategy, chunks) + labeler := strategy.NewLabeler() + baseKeys := compactChunk.Divide(labeler, target, NotMergeLogicalRange).Keys + matrix := CreateMatrix(labeler, plane.Times, baseKeys, valuesListLen) var wg sync.WaitGroup var mutex sync.Mutex @@ -86,7 +87,7 @@ func (plane *Plane) Pixel(strategy Strategy, target int, displayTags []string) M goCompactChunk := createZeroChunk(compactChunk.Keys) for i, axis := range plane.Axes { goCompactChunk.Clear() - strategy.Split(goCompactChunk, createChunk(chunks[i].Keys, axis.ValuesList[j]), splitTo, i, helper) + splitter.Split(goCompactChunk, createChunk(chunks[i].Keys, axis.ValuesList[j]), splitTo, i) data[i] = goCompactChunk.Reduce(baseKeys).Values } mutex.Lock() @@ -103,7 +104,7 @@ func (plane *Plane) Pixel(strategy Strategy, target int, displayTags []string) M return matrix } -func compact(strategy Strategy, chunks []chunk) (compactChunk chunk, helper interface{}) { +func compact(strategy SplitStrategy, chunks []chunk) (compactChunk chunk, splitter Splitter) { // get compact chunk keys keySet := make(map[string]struct{}) unlimitedEnd := false @@ -128,9 +129,9 @@ func compact(strategy Strategy, chunks []chunk) (compactChunk chunk, helper inte } compactChunk = createZeroChunk(compactKeys) - helper = strategy.GenerateHelper(chunks, compactChunk.Keys) + splitter = strategy.NewSplitter(chunks, compactChunk.Keys) for i, c := range chunks { - strategy.Split(compactChunk, c, splitAdd, i, helper) + splitter.Split(compactChunk, c, splitAdd, i) } return } diff --git a/pkg/keyvisual/service.go b/pkg/keyvisual/service.go index aeb4e4fb53..b08d9f15b5 100644 --- a/pkg/keyvisual/service.go +++ b/pkg/keyvisual/service.go @@ -29,17 +29,17 @@ import ( "go.uber.org/fx" "go.uber.org/zap" - "github.com/pingcap-incubator/tidb-dashboard/pkg/apiserver/user" - "github.com/pingcap-incubator/tidb-dashboard/pkg/config" - "github.com/pingcap-incubator/tidb-dashboard/pkg/dbstore" - "github.com/pingcap-incubator/tidb-dashboard/pkg/keyvisual/decorator" - "github.com/pingcap-incubator/tidb-dashboard/pkg/keyvisual/input" - "github.com/pingcap-incubator/tidb-dashboard/pkg/keyvisual/matrix" - "github.com/pingcap-incubator/tidb-dashboard/pkg/keyvisual/region" - "github.com/pingcap-incubator/tidb-dashboard/pkg/keyvisual/storage" - "github.com/pingcap-incubator/tidb-dashboard/pkg/pd" - "github.com/pingcap-incubator/tidb-dashboard/pkg/tidb" - "github.com/pingcap-incubator/tidb-dashboard/pkg/utils" + "github.com/pingcap/tidb-dashboard/pkg/apiserver/user" + "github.com/pingcap/tidb-dashboard/pkg/config" + "github.com/pingcap/tidb-dashboard/pkg/dbstore" + "github.com/pingcap/tidb-dashboard/pkg/keyvisual/decorator" + "github.com/pingcap/tidb-dashboard/pkg/keyvisual/input" + "github.com/pingcap/tidb-dashboard/pkg/keyvisual/matrix" + "github.com/pingcap/tidb-dashboard/pkg/keyvisual/region" + "github.com/pingcap/tidb-dashboard/pkg/keyvisual/storage" + "github.com/pingcap/tidb-dashboard/pkg/pd" + "github.com/pingcap/tidb-dashboard/pkg/tidb" + "github.com/pingcap/tidb-dashboard/pkg/utils" ) const ( @@ -82,7 +82,7 @@ type Service struct { tidbClient *tidb.Client stat *storage.Stat - strategy matrix.Strategy + strategy *matrix.Strategy labelStrategy decorator.LabelStrategy } @@ -164,14 +164,13 @@ func (s *Service) Start(ctx context.Context) error { func (s *Service) newLabelStrategy( lc fx.Lifecycle, wg *sync.WaitGroup, - cfg *config.Config, etcdClient *clientv3.Client, tidbClient *tidb.Client, ) decorator.LabelStrategy { switch s.keyVisualCfg.Policy { case config.KeyVisualDBPolicy: log.Debug("New LabelStrategy", zap.String("policy", s.keyVisualCfg.Policy)) - return decorator.TiDBLabelStrategy(lc, wg, cfg, etcdClient, tidbClient) + return decorator.TiDBLabelStrategy(lc, wg, etcdClient, tidbClient) case config.KeyVisualKVPolicy: log.Debug("New LabelStrategy", zap.String("policy", s.keyVisualCfg.Policy), zap.String("separator", s.keyVisualCfg.PolicyKVSeparator)) @@ -318,11 +317,26 @@ func newWaitGroup(lc fx.Lifecycle) *sync.WaitGroup { return wg } -func newStrategy(lc fx.Lifecycle, wg *sync.WaitGroup, labelStrategy decorator.LabelStrategy) matrix.Strategy { - return matrix.DistanceStrategy(lc, wg, labelStrategy, distanceStrategyRatio, distanceStrategyLevel, distanceStrategyCount) +func newStrategy(lc fx.Lifecycle, wg *sync.WaitGroup, labelStrategy decorator.LabelStrategy) *matrix.Strategy { + return &matrix.Strategy{ + LabelStrategy: labelStrategy, + SplitStrategy: matrix.DistanceSplitStrategy( + lc, wg, + distanceStrategyRatio, + distanceStrategyLevel, + distanceStrategyCount, + ), + } } -func newStat(lc fx.Lifecycle, wg *sync.WaitGroup, etcdClient *clientv3.Client, db *dbstore.DB, in input.StatInput, strategy matrix.Strategy) *storage.Stat { +func newStat( + lc fx.Lifecycle, + wg *sync.WaitGroup, + etcdClient *clientv3.Client, + db *dbstore.DB, + in input.StatInput, + strategy *matrix.Strategy, +) *storage.Stat { stat := storage.NewStat(lc, wg, db, defaultStatConfig, strategy, in.GetStartTime()) lc.Append(fx.Hook{ diff --git a/pkg/keyvisual/storage/model.go b/pkg/keyvisual/storage/model.go index 04eec6f7f7..08442ff7a7 100644 --- a/pkg/keyvisual/storage/model.go +++ b/pkg/keyvisual/storage/model.go @@ -1,3 +1,16 @@ +// Copyright 2020 PingCAP, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// See the License for the specific language governing permissions and +// limitations under the License. + package storage import ( @@ -5,8 +18,8 @@ import ( "encoding/gob" "time" - "github.com/pingcap-incubator/tidb-dashboard/pkg/dbstore" - "github.com/pingcap-incubator/tidb-dashboard/pkg/keyvisual/matrix" + "github.com/pingcap/tidb-dashboard/pkg/dbstore" + "github.com/pingcap/tidb-dashboard/pkg/keyvisual/matrix" ) const tableAxisModelName = "keyviz_axis" diff --git a/pkg/keyvisual/storage/model_test.go b/pkg/keyvisual/storage/model_test.go index ebb662b269..1c3a60681d 100644 --- a/pkg/keyvisual/storage/model_test.go +++ b/pkg/keyvisual/storage/model_test.go @@ -1,3 +1,16 @@ +// Copyright 2020 PingCAP, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// See the License for the specific language governing permissions and +// limitations under the License. + package storage import ( @@ -8,8 +21,8 @@ import ( "github.com/jinzhu/gorm" . "github.com/pingcap/check" - "github.com/pingcap-incubator/tidb-dashboard/pkg/dbstore" - "github.com/pingcap-incubator/tidb-dashboard/pkg/keyvisual/matrix" + "github.com/pingcap/tidb-dashboard/pkg/dbstore" + "github.com/pingcap/tidb-dashboard/pkg/keyvisual/matrix" ) func TestDbstore(t *testing.T) { diff --git a/pkg/keyvisual/storage/region.go b/pkg/keyvisual/storage/region.go index aa48c55bc8..7f0cede362 100644 --- a/pkg/keyvisual/storage/region.go +++ b/pkg/keyvisual/storage/region.go @@ -17,8 +17,9 @@ import ( "github.com/pingcap/log" "go.uber.org/zap" - "github.com/pingcap-incubator/tidb-dashboard/pkg/keyvisual/matrix" - "github.com/pingcap-incubator/tidb-dashboard/pkg/keyvisual/region" + "github.com/pingcap/tidb-dashboard/pkg/keyvisual/decorator" + "github.com/pingcap/tidb-dashboard/pkg/keyvisual/matrix" + "github.com/pingcap/tidb-dashboard/pkg/keyvisual/region" ) // Source data pre processing parameters. @@ -27,11 +28,11 @@ const ( // preRatioTarget = 512 preTarget = 3072 - dirtyWrittenBytes = 1 << 32 + dirtyWrittenBytes uint64 = 1 << 32 ) // CreateStorageAxis converts the RegionsInfo to a StorageAxis. -func CreateStorageAxis(regions region.RegionsInfo, strategy matrix.Strategy) matrix.Axis { +func CreateStorageAxis(regions region.RegionsInfo, labeler decorator.Labeler) matrix.Axis { regionsLen := regions.Len() if regionsLen <= 0 { panic("At least one RegionInfo") @@ -46,15 +47,15 @@ func CreateStorageAxis(regions region.RegionsInfo, strategy matrix.Strategy) mat preAxis := matrix.CreateAxis(keys, valuesList) wash(&preAxis) - axis := IntoStorageAxis(preAxis, strategy) + axis := IntoStorageAxis(preAxis, labeler) log.Debug("New StorageAxis", zap.Int("region length", regionsLen), zap.Int("focus keys length", len(axis.Keys))) return axis } // IntoStorageAxis converts ResponseAxis to StorageAxis. -func IntoStorageAxis(responseAxis matrix.Axis, strategy matrix.Strategy) matrix.Axis { +func IntoStorageAxis(responseAxis matrix.Axis, labeler decorator.Labeler) matrix.Axis { // axis := preAxis.Focus(strategy, preThreshold, len(keys)/preRatioTarget, preTarget) - axis := responseAxis.Divide(strategy, preTarget) + axis := responseAxis.Divide(labeler, preTarget) var storageValuesList [][]uint64 storageValuesList = append(storageValuesList, axis.ValuesList[1:]...) return matrix.CreateAxis(axis.Keys, storageValuesList) diff --git a/pkg/keyvisual/storage/stat.go b/pkg/keyvisual/storage/stat.go index ccff547788..c73690f988 100644 --- a/pkg/keyvisual/storage/stat.go +++ b/pkg/keyvisual/storage/stat.go @@ -22,9 +22,10 @@ import ( "go.uber.org/fx" - "github.com/pingcap-incubator/tidb-dashboard/pkg/dbstore" - "github.com/pingcap-incubator/tidb-dashboard/pkg/keyvisual/matrix" - "github.com/pingcap-incubator/tidb-dashboard/pkg/keyvisual/region" + "github.com/pingcap/tidb-dashboard/pkg/dbstore" + "github.com/pingcap/tidb-dashboard/pkg/keyvisual/decorator" + "github.com/pingcap/tidb-dashboard/pkg/keyvisual/matrix" + "github.com/pingcap/tidb-dashboard/pkg/keyvisual/region" ) // LayerConfig is the configuration of layerStat. @@ -49,31 +50,37 @@ type layerStat struct { Db *dbstore.DB // Hierarchical mechanism - Strategy matrix.Strategy - Ratio int - Next *layerStat + SplitStrategy matrix.SplitStrategy + Ratio int + Next *layerStat } -func newLayerStat(layerNum uint8, conf LayerConfig, strategy matrix.Strategy, startTime time.Time, db *dbstore.DB) *layerStat { +func newLayerStat( + layerNum uint8, + conf LayerConfig, + splitStrategy matrix.SplitStrategy, + startTime time.Time, + db *dbstore.DB, +) *layerStat { return &layerStat{ - StartTime: startTime, - EndTime: startTime, - RingAxes: make([]matrix.Axis, conf.Len), - RingTimes: make([]time.Time, conf.Len), - LayerNum: layerNum, - Head: 0, - Tail: 0, - Empty: true, - Len: conf.Len, - Db: db, - Strategy: strategy, - Ratio: conf.Ratio, - Next: nil, + StartTime: startTime, + EndTime: startTime, + RingAxes: make([]matrix.Axis, conf.Len), + RingTimes: make([]time.Time, conf.Len), + LayerNum: layerNum, + Head: 0, + Tail: 0, + Empty: true, + Len: conf.Len, + Db: db, + SplitStrategy: splitStrategy, + Ratio: conf.Ratio, + Next: nil, } } // Reduce merges ratio axes and append to next layerStat -func (s *layerStat) Reduce() { +func (s *layerStat) Reduce(labeler decorator.Labeler) { if s.Ratio == 0 || s.Next == nil { _ = s.DeleteFirstAxisFromDb() @@ -98,17 +105,17 @@ func (s *layerStat) Reduce() { } plane := matrix.CreatePlane(times, axes) - newAxis := plane.Compact(s.Strategy) + newAxis := plane.Compact(s.SplitStrategy) newAxis = IntoResponseAxis(newAxis, region.Integration) - newAxis = IntoStorageAxis(newAxis, s.Strategy) + newAxis = IntoStorageAxis(newAxis, labeler) newAxis.Shrink(uint64(s.Ratio)) - s.Next.Append(newAxis, s.StartTime) + s.Next.Append(newAxis, s.StartTime, labeler) } // Append appends a key axis to layerStat. -func (s *layerStat) Append(axis matrix.Axis, endTime time.Time) { +func (s *layerStat) Append(axis matrix.Axis, endTime time.Time, labeler decorator.Labeler) { if s.Head == s.Tail && !s.Empty { - s.Reduce() + s.Reduce(labeler) } _ = s.InsertLastAxisToDb(axis, endTime) @@ -181,13 +188,20 @@ type Stat struct { layers []*layerStat keyMap matrix.KeyMap - strategy matrix.Strategy + strategy *matrix.Strategy db *dbstore.DB } // NewStat generates a Stat based on the configuration. -func NewStat(lc fx.Lifecycle, wg *sync.WaitGroup, db *dbstore.DB, cfg StatConfig, strategy matrix.Strategy, startTime time.Time) *Stat { +func NewStat( + lc fx.Lifecycle, + wg *sync.WaitGroup, + db *dbstore.DB, + cfg StatConfig, + strategy *matrix.Strategy, + startTime time.Time, +) *Stat { layers := make([]*layerStat, len(cfg.LayersConfig)) for i, c := range cfg.LayersConfig { layers[i] = newLayerStat(uint8(i), c, strategy, startTime, db) @@ -253,7 +267,8 @@ func (s *Stat) Append(regions region.RegionsInfo, endTime time.Time) { if regions.Len() == 0 { return } - axis := CreateStorageAxis(regions, s.strategy) + labeler := s.strategy.NewLabeler() + axis := CreateStorageAxis(regions, labeler) s.keyMap.RLock() defer s.keyMap.RUnlock() @@ -261,7 +276,7 @@ func (s *Stat) Append(regions region.RegionsInfo, endTime time.Time) { s.mutex.Lock() defer s.mutex.Unlock() - s.layers[0].Append(axis, endTime) + s.layers[0].Append(axis, endTime, labeler) } func (s *Stat) rangeRoot(startTime, endTime time.Time) ([]time.Time, []matrix.Axis) { diff --git a/pkg/keyvisual/storage/stat_persist.go b/pkg/keyvisual/storage/stat_persist.go index 06ef0c40aa..00785bc8ec 100644 --- a/pkg/keyvisual/storage/stat_persist.go +++ b/pkg/keyvisual/storage/stat_persist.go @@ -1,3 +1,16 @@ +// Copyright 2020 PingCAP, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// See the License for the specific language governing permissions and +// limitations under the License. + package storage import ( @@ -6,7 +19,7 @@ import ( "github.com/pingcap/log" "go.uber.org/zap" - "github.com/pingcap-incubator/tidb-dashboard/pkg/keyvisual/matrix" + "github.com/pingcap/tidb-dashboard/pkg/keyvisual/matrix" ) func (s *layerStat) InsertLastAxisToDb(axis matrix.Axis, endTime time.Time) error { diff --git a/pkg/pd/client.go b/pkg/pd/client.go index 9986f26425..3d93dd72cd 100644 --- a/pkg/pd/client.go +++ b/pkg/pd/client.go @@ -21,8 +21,8 @@ import ( "go.uber.org/fx" - "github.com/pingcap-incubator/tidb-dashboard/pkg/config" - "github.com/pingcap-incubator/tidb-dashboard/pkg/httpc" + "github.com/pingcap/tidb-dashboard/pkg/config" + "github.com/pingcap/tidb-dashboard/pkg/httpc" ) var ( diff --git a/pkg/pd/etcd.go b/pkg/pd/etcd.go index 2a59d19e15..95d29537a1 100644 --- a/pkg/pd/etcd.go +++ b/pkg/pd/etcd.go @@ -23,8 +23,8 @@ import ( "go.uber.org/zap" "go.uber.org/zap/zapcore" - "github.com/pingcap-incubator/tidb-dashboard/pkg/config" - "github.com/pingcap-incubator/tidb-dashboard/pkg/utils" + "github.com/pingcap/tidb-dashboard/pkg/config" + "github.com/pingcap/tidb-dashboard/pkg/utils" ) func newZapEncoder(zapcore.EncoderConfig) (zapcore.Encoder, error) { diff --git a/pkg/swaggerserver/handler.go b/pkg/swaggerserver/handler.go index e6bdf494ea..9ab12215b3 100644 --- a/pkg/swaggerserver/handler.go +++ b/pkg/swaggerserver/handler.go @@ -18,7 +18,7 @@ import ( httpSwagger "github.com/swaggo/http-swagger" // Swagger doc - _ "github.com/pingcap-incubator/tidb-dashboard/swaggerspec" + _ "github.com/pingcap/tidb-dashboard/swaggerspec" ) func Handler() http.Handler { diff --git a/pkg/tidb/client.go b/pkg/tidb/client.go index f481ec3d7f..22bf2573b9 100644 --- a/pkg/tidb/client.go +++ b/pkg/tidb/client.go @@ -20,8 +20,8 @@ import ( // MySQL driver used by gorm _ "github.com/jinzhu/gorm/dialects/mysql" - "github.com/pingcap-incubator/tidb-dashboard/pkg/config" - "github.com/pingcap-incubator/tidb-dashboard/pkg/httpc" + "github.com/pingcap/tidb-dashboard/pkg/config" + "github.com/pingcap/tidb-dashboard/pkg/httpc" ) var ( diff --git a/pkg/tidb/forwarder.go b/pkg/tidb/forwarder.go index b6345cbe45..f77690e2ef 100644 --- a/pkg/tidb/forwarder.go +++ b/pkg/tidb/forwarder.go @@ -24,7 +24,7 @@ import ( "go.etcd.io/etcd/clientv3" "go.uber.org/fx" - "github.com/pingcap-incubator/tidb-dashboard/pkg/utils/topology" + "github.com/pingcap/tidb-dashboard/pkg/utils/topology" ) var ( diff --git a/pkg/tidb/model/codec.go b/pkg/tidb/model/codec.go index a341acadf8..6414d4bb28 100644 --- a/pkg/tidb/model/codec.go +++ b/pkg/tidb/model/codec.go @@ -17,7 +17,7 @@ import ( "bytes" "encoding/binary" - "github.com/pkg/errors" + "github.com/pingcap/errors" ) var ( @@ -34,85 +34,135 @@ const ( encPad = byte(0x0) ) -// Key represents high-level Key type. +// Key represents high-level TiDB Key type. type Key []byte -// TableID returns the table ID of the key, if the key is not table key, returns 0. -func (k Key) TableID() int64 { - _, key, err := DecodeBytes(k) +// KeyInfoBuffer can obtain the meta information of the TiDB Key. +// It can be reused, thereby reducing memory applications. +type KeyInfoBuffer []byte + +// DecodeKey obtains the KeyInfoBuffer from a TiDB Key +func (buf *KeyInfoBuffer) DecodeKey(key Key) (KeyInfoBuffer, error) { + _, result, err := decodeBytes(key, *buf) + if err != nil { - // should never happen - return 0 + *buf = (*buf)[:0] + return nil, err } - if !bytes.HasPrefix(key, tablePrefix) { - return 0 - } - key = key[len(tablePrefix):] - _, tableID, _ := DecodeInt(key) - return tableID + *buf = result + return result, nil } -// RowID returns the row ID of the key, if the key is not table key, returns 0. -func (k Key) RowID() int64 { - _, key, err := DecodeBytes(k) - if err != nil { - // should never happen - return 0 - } - if !bytes.HasPrefix(key, tablePrefix) { - return 0 +// MetaOrTable checks if the key is a meta key or table key. +// If the key is a meta key, it returns true and 0. +// If the key is a table key, it returns false and table ID. +// Otherwise, it returns false and 0. +func (buf KeyInfoBuffer) MetaOrTable() (isMeta bool, tableID int64) { + if bytes.HasPrefix(buf, metaPrefix) { + return true, 0 } - if len(key) < 19 || !(key[9] == '_' && key[10] == 'r') { - return 0 + if bytes.HasPrefix(buf, tablePrefix) { + _, tableID, _ := decodeInt(buf[len(tablePrefix):]) + return false, tableID } - key = key[11:19] - - _, rowID, _ := DecodeInt(key) - return rowID + return false, 0 } -// IndexID returns the row ID of the key, if the key is not table key, returns 0. -func (k Key) IndexID() int64 { - _, key, err := DecodeBytes(k) - if err != nil { - // should never happen - return 0 +// RowInfo returns the row ID of the key, if the key is not table key, returns 0. +func (buf KeyInfoBuffer) RowInfo() (isCommonHandle bool, rowID int64) { + if !bytes.HasPrefix(buf, tablePrefix) || len(buf) < 19 || !(buf[9] == '_' && buf[10] == 'r') { + return } - if !bytes.HasPrefix(key, tablePrefix) { - return 0 + isCommonHandle = len(buf) != 19 + if !isCommonHandle { + _, rowID, _ = decodeInt(buf[11:19]) } - if len(key) < 19 || !(key[9] == '_' && key[10] == 'i') { - return 0 + return +} + +// IndexInfo returns the row ID of the key, if the key is not table key, returns 0. +func (buf KeyInfoBuffer) IndexInfo() (indexID int64) { + if !bytes.HasPrefix(buf, tablePrefix) || len(buf) < 19 || !(buf[9] == '_' && buf[10] == 'i') { + return } - key = key[11:19] - _, indexID, _ := DecodeInt(key) - return indexID + _, indexID, _ = decodeInt(buf[11:19]) + return } -// MetaOrTable checks if the key is a meta key or table key. -// If the key is a meta key, it returns true and 0. -// If the key is a table key, it returns false and table ID. -// Otherwise, it returns false and 0. -func (k Key) MetaOrTable() (bool, int64) { - _, key, err := DecodeBytes(k) - if err != nil { - return false, 0 +// GenerateTableKey generates a table split key. +func (buf *KeyInfoBuffer) GenerateKey(tableID, rowID int64) Key { + if tableID == 0 { + return nil } - if bytes.HasPrefix(key, metaPrefix) { - return true, 0 + + data := *buf + if data == nil { + length := len(tablePrefix) + 8 + if rowID != 0 { + length = len(tablePrefix) + len(recordPrefix) + 8*2 + } + data = make([]byte, 0, length) + } else { + data = data[:0] } - if bytes.HasPrefix(key, tablePrefix) { - key = key[len(tablePrefix):] - _, tableID, _ := DecodeInt(key) - return false, tableID + + data = append(data, tablePrefix...) + data = encodeInt(data, tableID) + if rowID != 0 { + data = append(data, recordPrefix...) + data = encodeInt(data, rowID) } - return false, 0 + + *buf = data + + return encodeBytes(data) } var pads = make([]byte, encGroupSize) -// EncodeBytes guarantees the encoded value is in ascending order for comparison, +// decodeBytes decodes bytes which is encoded by encodeBytes before, +// returns the leftover bytes and decoded value if no error. +func decodeBytes(b []byte, buf []byte) (rest []byte, result []byte, err error) { + if buf == nil { + buf = make([]byte, 0, len(b)) + } + buf = buf[:0] + + for { + if len(b) < encGroupSize+1 { + return nil, nil, errors.New("insufficient bytes to decode value") + } + + groupBytes := b[:encGroupSize+1] + + group := groupBytes[:encGroupSize] + marker := groupBytes[encGroupSize] + + padCount := encMarker - marker + if padCount > encGroupSize { + return nil, nil, errors.Errorf("invalid marker byte, group bytes %q", groupBytes) + } + + realGroupSize := encGroupSize - padCount + buf = append(buf, group[:realGroupSize]...) + b = b[encGroupSize+1:] + + if padCount != 0 { + // Check validity of padding bytes. + for _, v := range group[realGroupSize:] { + if v != encPad { + return nil, nil, errors.Errorf("invalid padding byte, group bytes %q", groupBytes) + } + } + break + } + } + + return b, buf, nil +} + +// encodeBytes guarantees the encoded value is in ascending order for comparison, // encoding with the following rule: // [group1][marker1]...[groupN][markerN] // group is 8 bytes slice which is padding with 0. @@ -123,7 +173,7 @@ var pads = make([]byte, encGroupSize) // [1, 2, 3, 0] -> [1, 2, 3, 0, 0, 0, 0, 0, 251] // [1, 2, 3, 4, 5, 6, 7, 8] -> [1, 2, 3, 4, 5, 6, 7, 8, 255, 0, 0, 0, 0, 0, 0, 0, 0, 247] // Refer: https://github.com/facebook/mysql-5.6/wiki/MyRocks-record-format#memcomparable-format -func EncodeBytes(data []byte) Key { +func encodeBytes(data []byte) []byte { // Allocate more space to avoid unnecessary slice growing. // Assume that the byte slice size is about `(len(data) / encGroupSize + 1) * (encGroupSize + 1)` bytes, // that is `(len(data) / 8 + 1) * 9` in our implement. @@ -146,18 +196,9 @@ func EncodeBytes(data []byte) Key { return result } -// EncodeInt appends the encoded value to slice b and returns the appended slice. -// EncodeInt guarantees that the encoded value is in ascending order for comparison. -func EncodeInt(b []byte, v int64) []byte { - var data [8]byte - u := encodeIntToCmpUint(v) - binary.BigEndian.PutUint64(data[:], u) - return append(b, data[:]...) -} - -// DecodeInt decodes value encoded by EncodeInt before. +// decodeInt decodes value encoded by EncodeInt before. // It returns the leftover un-decoded slice, decoded value if no error. -func DecodeInt(b []byte) ([]byte, int64, error) { +func decodeInt(b []byte) ([]byte, int64, error) { if len(b) < 8 { return nil, 0, errors.New("insufficient bytes to decode value") } @@ -168,65 +209,19 @@ func DecodeInt(b []byte) ([]byte, int64, error) { return b, v, nil } -func encodeIntToCmpUint(v int64) uint64 { - return uint64(v) ^ signMask +// encodeInt appends the encoded value to slice b and returns the appended slice. +// encodeInt guarantees that the encoded value is in ascending order for comparison. +func encodeInt(b []byte, v int64) []byte { + var data [8]byte + u := encodeIntToCmpUint(v) + binary.BigEndian.PutUint64(data[:], u) + return append(b, data[:]...) } func decodeCmpUintToInt(u uint64) int64 { return int64(u ^ signMask) } -// DecodeBytes decodes bytes which is encoded by EncodeBytes before, -// returns the leftover bytes and decoded value if no error. -func DecodeBytes(b []byte) ([]byte, []byte, error) { - data := make([]byte, 0, len(b)) - for { - if len(b) < encGroupSize+1 { - return nil, nil, errors.New("insufficient bytes to decode value") - } - - groupBytes := b[:encGroupSize+1] - - group := groupBytes[:encGroupSize] - marker := groupBytes[encGroupSize] - - padCount := encMarker - marker - if padCount > encGroupSize { - return nil, nil, errors.Errorf("invalid marker byte, group bytes %q", groupBytes) - } - - realGroupSize := encGroupSize - padCount - data = append(data, group[:realGroupSize]...) - b = b[encGroupSize+1:] - - if padCount != 0 { - var padByte = encPad - // Check validity of padding bytes. - for _, v := range group[realGroupSize:] { - if v != padByte { - return nil, nil, errors.Errorf("invalid padding byte, group bytes %q", groupBytes) - } - } - break - } - } - return b, data, nil -} - -// GenerateTableKey generates a table split key. -func GenerateTableKey(tableID int64) []byte { - buf := make([]byte, 0, len(tablePrefix)+8) - buf = append(buf, tablePrefix...) - buf = EncodeInt(buf, tableID) - return buf -} - -// GenerateRowKey generates a row key. -func GenerateRowKey(tableID, rowID int64) []byte { - buf := make([]byte, 0, len(tablePrefix)+len(recordPrefix)+8*2) - buf = append(buf, tablePrefix...) - buf = EncodeInt(buf, tableID) - buf = append(buf, recordPrefix...) - buf = EncodeInt(buf, rowID) - return buf +func encodeIntToCmpUint(v int64) uint64 { + return uint64(v) ^ signMask } diff --git a/pkg/tidb/model/codec_test.go b/pkg/tidb/model/codec_test.go index acf682bb0c..bf365a442d 100644 --- a/pkg/tidb/model/codec_test.go +++ b/pkg/tidb/model/codec_test.go @@ -30,25 +30,96 @@ type testCodecSuite struct{} func (s *testCodecSuite) TestDecodeBytes(c *C) { key := "abcdefghijklmnopqrstuvwxyz" for i := 0; i < len(key); i++ { - _, k, err := DecodeBytes(EncodeBytes([]byte(key[:i]))) + _, k, err := decodeBytes(encodeBytes([]byte(key[:i])), nil) c.Assert(err, IsNil) c.Assert(string(k), Equals, key[:i]) } } -func (s *testCodecSuite) TestTableID(c *C) { - key := EncodeBytes([]byte("t\x80\x00\x00\x00\x00\x00\x00\xff")) - c.Assert(key.TableID(), Equals, int64(0xff)) +func (s *testCodecSuite) TestTiDBInfo(c *C) { + buf := new(KeyInfoBuffer) - key = EncodeBytes([]byte("t\x80\x00\x00\x00\x00\x00\x00\xff_i\x01\x02")) - c.Assert(key.TableID(), Equals, int64(0xff)) + // no encode + _, err := buf.DecodeKey([]byte("t\x80\x00\x00\x00\x00\x00\x00\xff")) + c.Assert(err, NotNil) - key = []byte("t\x80\x00\x00\x00\x00\x00\x00\xff") - c.Assert(key.TableID(), Equals, int64(0)) - - key = EncodeBytes([]byte("T\x00\x00\x00\x00\x00\x00\x00\xff")) - c.Assert(key.TableID(), Equals, int64(0)) + testcases := []struct { + Key string + IsMeta bool + TableID int64 + IsCommonHandle bool + RowID int64 + IndexID int64 + }{ + { + "T\x00\x00\x00\x00\x00\x00\x00\xff", + false, + 0, + false, + 0, + 0, + }, + { + "t\x80\x00\x00\x00\x00\x00\xff", + false, + 0, + false, + 0, + 0, + }, + { + "t\x80\x00\x00\x00\x00\x00\x00\xff", + false, + 0xff, + false, + 0, + 0, + }, + { + "t\x80\x00\x00\x00\x00\x00\x00\xff_i\x01\x02", + false, + 0xff, + false, + 0, + 0, + }, + { + "t\x80\x00\x00\x00\x00\x00\x00\xff_i\x80\x00\x00\x00\x00\x00\x00\x02", + false, + 0xff, + false, + 0, + 2, + }, + { + "t\x80\x00\x00\x00\x00\x00\x00\xff_r\x80\x00\x00\x00\x00\x00\x00\x02", + false, + 0xff, + false, + 2, + 0, + }, + { + "t\x80\x00\x00\x00\x00\x00\x00\xff_r\x03\x80\x00\x00\x00\x00\x02\r\xaf\x03\x80\x00\x00\x00\x00\x00\x00\x03\x03\x80\x00\x00\x00\x00\x00\b%", + false, + 0xff, + true, + 0, + 0, + }, + } - key = EncodeBytes([]byte("t\x80\x00\x00\x00\x00\x00\xff")) - c.Assert(key.TableID(), Equals, int64(0)) + for _, t := range testcases { + key := encodeBytes([]byte(t.Key)) + _, err := buf.DecodeKey(key) + c.Assert(err, IsNil) + isMeta, tableID := buf.MetaOrTable() + c.Assert(isMeta, Equals, t.IsMeta) + c.Assert(tableID, Equals, t.TableID) + isCommonHandle, rowID := buf.RowInfo() + c.Assert(isCommonHandle, Equals, t.IsCommonHandle) + c.Assert(rowID, Equals, t.RowID) + indexID := buf.IndexInfo() + c.Assert(indexID, Equals, t.IndexID) + } } diff --git a/pkg/tikv/client.go b/pkg/tikv/client.go index 145bd34ea0..fa91894ce5 100644 --- a/pkg/tikv/client.go +++ b/pkg/tikv/client.go @@ -21,8 +21,8 @@ import ( "go.uber.org/fx" - "github.com/pingcap-incubator/tidb-dashboard/pkg/config" - "github.com/pingcap-incubator/tidb-dashboard/pkg/httpc" + "github.com/pingcap/tidb-dashboard/pkg/config" + "github.com/pingcap/tidb-dashboard/pkg/httpc" ) var ( diff --git a/pkg/uiserver/embedded_assets_rewriter.go b/pkg/uiserver/embedded_assets_rewriter.go index ac7f782846..a00d583b6e 100644 --- a/pkg/uiserver/embedded_assets_rewriter.go +++ b/pkg/uiserver/embedded_assets_rewriter.go @@ -20,7 +20,7 @@ import ( "sync" "time" - "github.com/pingcap-incubator/tidb-dashboard/pkg/config" + "github.com/pingcap/tidb-dashboard/pkg/config" ) var once sync.Once diff --git a/pkg/uiserver/empty_assets_handler.go b/pkg/uiserver/empty_assets_handler.go index 6e45e6dcd6..4a7c0b997e 100644 --- a/pkg/uiserver/empty_assets_handler.go +++ b/pkg/uiserver/empty_assets_handler.go @@ -17,7 +17,7 @@ package uiserver import ( "net/http" - "github.com/pingcap-incubator/tidb-dashboard/pkg/config" + "github.com/pingcap/tidb-dashboard/pkg/config" ) func Assets(*config.Config) http.FileSystem { diff --git a/pkg/uiserver/uiserver.go b/pkg/uiserver/uiserver.go index 0dbace569f..2e683b8245 100644 --- a/pkg/uiserver/uiserver.go +++ b/pkg/uiserver/uiserver.go @@ -26,7 +26,7 @@ import ( "github.com/shurcooL/httpgzip" "go.uber.org/zap" - "github.com/pingcap-incubator/tidb-dashboard/pkg/config" + "github.com/pingcap/tidb-dashboard/pkg/config" ) type UpdateContentFunc func(fs http.FileSystem, oldFile http.File, path, newContent string, zippedBytes []byte) diff --git a/pkg/utils/topology/pd.go b/pkg/utils/topology/pd.go index 94a38abb6c..40d99cab86 100644 --- a/pkg/utils/topology/pd.go +++ b/pkg/utils/topology/pd.go @@ -21,8 +21,8 @@ import ( "github.com/pingcap/log" "go.uber.org/zap" - "github.com/pingcap-incubator/tidb-dashboard/pkg/pd" - "github.com/pingcap-incubator/tidb-dashboard/pkg/utils/host" + "github.com/pingcap/tidb-dashboard/pkg/pd" + "github.com/pingcap/tidb-dashboard/pkg/utils/host" ) func FetchPDTopology(pdClient *pd.Client) ([]PDInfo, error) { diff --git a/pkg/utils/topology/store.go b/pkg/utils/topology/store.go index 9d700736f4..5ecf502e4f 100644 --- a/pkg/utils/topology/store.go +++ b/pkg/utils/topology/store.go @@ -21,8 +21,8 @@ import ( "github.com/pingcap/log" "go.uber.org/zap" - "github.com/pingcap-incubator/tidb-dashboard/pkg/pd" - "github.com/pingcap-incubator/tidb-dashboard/pkg/utils/host" + "github.com/pingcap/tidb-dashboard/pkg/pd" + "github.com/pingcap/tidb-dashboard/pkg/utils/host" ) // FetchStoreTopology returns TiKV info and TiFlash info. diff --git a/pkg/utils/topology/tidb.go b/pkg/utils/topology/tidb.go index ebab743d8d..304aaf8071 100644 --- a/pkg/utils/topology/tidb.go +++ b/pkg/utils/topology/tidb.go @@ -25,7 +25,7 @@ import ( "go.etcd.io/etcd/clientv3" "go.uber.org/zap" - "github.com/pingcap-incubator/tidb-dashboard/pkg/utils/host" + "github.com/pingcap/tidb-dashboard/pkg/utils/host" ) const tidbTopologyKeyPrefix = "/topology/tidb/" diff --git a/release-version b/release-version index 7fd6dc4fcb..bdd39da90e 100644 --- a/release-version +++ b/release-version @@ -1,3 +1,3 @@ # This file specifies the TiDB Dashboard internal version, which will be printed in `--version` # and UI. In release branch, changing this file will result in publishing a new version and tag. -2021.01.04.1 +2021.03.12.1 diff --git a/scripts/lint.sh b/scripts/lint.sh index 70335a2ecd..63091c6686 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -32,4 +32,4 @@ echo "+ Clean up go mod" go mod tidy echo "+ Run lints for docs" -npx markdownlint-cli docs/**/*.md +npm_config_yes=true npx markdownlint-cli docs/**/*.md diff --git a/ui/dashboardApp/index.ts b/ui/dashboardApp/index.ts index 79cbf76666..47d4e819ce 100644 --- a/ui/dashboardApp/index.ts +++ b/ui/dashboardApp/index.ts @@ -28,6 +28,8 @@ import AppSearchLogs from '@lib/apps/SearchLogs/index.meta' import AppInstanceProfiling from '@lib/apps/InstanceProfiling/index.meta' import AppQueryEditor from '@lib/apps/QueryEditor/index.meta' import AppConfiguration from '@lib/apps/Configuration/index.meta' +// import __APP_NAME__ from '@lib/apps/__APP_NAME__/index.meta' +// NOTE: Don't remove above comment line, it is a placeholder for code generator function removeSpinner() { const spinner = document.getElementById('dashboard_page_spinner') @@ -107,6 +109,8 @@ async function main() { .register(AppInstanceProfiling) .register(AppQueryEditor) .register(AppConfiguration) + // .register(__APP_NAME__) + // NOTE: Don't remove above comment line, it is a placeholder for code generator if (routing.isLocationMatch('/')) { singleSpa.navigateToUrl('#' + registry.getDefaultRouter()) @@ -120,14 +124,18 @@ async function main() { } }) - window.addEventListener('single-spa:before-routing-event', () => {}) - + let preRoute = '' window.addEventListener('single-spa:routing-event', () => { removeSpinner() - telemetry.mixpanel.register({ - $current_url: routing.getPathInLocationHash(), - }) - telemetry.mixpanel.track('PageChange') + + const curRoute = routing.getPathInLocationHash() + if (curRoute !== preRoute) { + telemetry.mixpanel.register({ + $current_url: curRoute, + }) + telemetry.mixpanel.track('PageChange') + preRoute = curRoute + } }) singleSpa.start() diff --git a/ui/dashboardApp/layout/main/Sider/index.tsx b/ui/dashboardApp/layout/main/Sider/index.tsx index ec0ed7fe76..3c264f7eec 100644 --- a/ui/dashboardApp/layout/main/Sider/index.tsx +++ b/ui/dashboardApp/layout/main/Sider/index.tsx @@ -98,6 +98,8 @@ function Sider({ useAppMenuItem(registry, 'keyviz'), useAppMenuItem(registry, 'diagnose'), useAppMenuItem(registry, 'search_logs'), + // useAppMenuItem(registry, '__APP_NAME__'), + // NOTE: Don't remove above comment line, it is a placeholder for code generator debugSubMenu, ] diff --git a/ui/lib/apps/ClusterInfo/components/Statistics.tsx b/ui/lib/apps/ClusterInfo/components/Statistics.tsx index 0d8c99693a..f709bd3e5d 100644 --- a/ui/lib/apps/ClusterInfo/components/Statistics.tsx +++ b/ui/lib/apps/ClusterInfo/components/Statistics.tsx @@ -90,7 +90,7 @@ export default function Statistics() { {InstanceKinds.map((ik) => { return ( - + ) diff --git a/ui/lib/apps/ClusterInfo/index.tsx b/ui/lib/apps/ClusterInfo/index.tsx index d238e07e14..7fc65495e9 100644 --- a/ui/lib/apps/ClusterInfo/index.tsx +++ b/ui/lib/apps/ClusterInfo/index.tsx @@ -1,6 +1,7 @@ -import { Root } from '@lib/components' import React from 'react' -import { HashRouter as Router, Navigate, Route, Routes } from 'react-router-dom' +import { HashRouter as Router, Route, Routes, Navigate } from 'react-router-dom' + +import { Root } from '@lib/components' import ListPage from './pages/List' const App = () => { diff --git a/ui/lib/apps/KeyViz/heatmap/axis/label-axis.ts b/ui/lib/apps/KeyViz/heatmap/axis/label-axis.ts index 138ae92eec..d0e4143d8b 100644 --- a/ui/lib/apps/KeyViz/heatmap/axis/label-axis.ts +++ b/ui/lib/apps/KeyViz/heatmap/axis/label-axis.ts @@ -62,7 +62,7 @@ export function labelAxisGroup(keyAxis: KeyAxisEntry[]) { ctx.stroke() ctx.closePath() - if (shouleShowLabelText(label)) { + if (shouldShowLabelText(label)) { ctx.font = label.focus ? focusFont : font ctx.fillStyle = label.focus ? textFillFocus : textFill ctx.translate( @@ -81,7 +81,7 @@ export function labelAxisGroup(keyAxis: KeyAxisEntry[]) { return labelAxisGroup } -function shouleShowLabelText(label: DisplayLabel): boolean { +function shouldShowLabelText(label: DisplayLabel): boolean { return ( label.endPos - label.startPos >= minTextHeight && label.val?.length !== 0 ) diff --git a/ui/lib/apps/Overview/components/Instances.tsx b/ui/lib/apps/Overview/components/Instances.tsx index 793921f133..8f558ce963 100644 --- a/ui/lib/apps/Overview/components/Instances.tsx +++ b/ui/lib/apps/Overview/components/Instances.tsx @@ -92,7 +92,7 @@ export default function Nodes() { } noMarginLeft > - + diff --git a/ui/lib/apps/Overview/components/MonitorAlert.tsx b/ui/lib/apps/Overview/components/MonitorAlert.tsx index 7f907dedcb..622b5d5387 100644 --- a/ui/lib/apps/Overview/components/MonitorAlert.tsx +++ b/ui/lib/apps/Overview/components/MonitorAlert.tsx @@ -40,7 +40,7 @@ export default function MonitorAlert() { return ( - + { controller: ISlowQueryTableController @@ -17,16 +19,23 @@ function SlowQueriesTable({ controller, ...restProps }: Props) { changeOrder, errors, visibleColumnKeys, + + saveClickedItemIndex, + getClickedItemIndex, } = controller - const handleRowClick = usePersistFn((rec) => { - const qs = DetailPage.buildQuery({ - digest: rec.digest, - connectId: rec.connection_id, - timestamp: rec.timestamp, - }) - window.open(`#/slow_query/detail?${qs}`, '_blank') - }) + const navigate = useNavigate() + const handleRowClick = usePersistFn( + (rec, idx, ev: React.MouseEvent) => { + saveClickedItemIndex(idx) + const qs = DetailPage.buildQuery({ + digest: rec.digest, + connectId: rec.connection_id, + timestamp: rec.timestamp, + }) + openLink(`/slow_query/detail?${qs}`, ev, navigate) + } + ) const getKey = useCallback((row) => `${row.digest}_${row.timestamp}`, []) @@ -42,6 +51,7 @@ function SlowQueriesTable({ controller, ...restProps }: Props) { errors={errors} visibleColumnKeys={visibleColumnKeys} onRowClicked={handleRowClick} + clickedRowIndex={getClickedItemIndex()} getKey={getKey} /> ) diff --git a/ui/lib/apps/SlowQuery/index.tsx b/ui/lib/apps/SlowQuery/index.tsx index f9c706edf9..f3565c41f0 100644 --- a/ui/lib/apps/SlowQuery/index.tsx +++ b/ui/lib/apps/SlowQuery/index.tsx @@ -1,17 +1,23 @@ import React from 'react' import { Root } from '@lib/components' import { HashRouter as Router, Route, Routes } from 'react-router-dom' +import useCache, { CacheContext } from '@lib/utils/useCache' + import { List, Detail } from './pages' export default function () { + const slowQueryCacheMgr = useCache(2) + return ( - - - } /> - } /> - - + + + + } /> + } /> + + + ) } diff --git a/ui/lib/apps/SlowQuery/pages/Detail/index.tsx b/ui/lib/apps/SlowQuery/pages/Detail/index.tsx index eb0f090f32..0b913871da 100644 --- a/ui/lib/apps/SlowQuery/pages/Detail/index.tsx +++ b/ui/lib/apps/SlowQuery/pages/Detail/index.tsx @@ -1,8 +1,9 @@ import React from 'react' import { Space } from 'antd' import { useTranslation } from 'react-i18next' -import { useLocation } from 'react-router-dom' +import { Link, useLocation } from 'react-router-dom' import { useLocalStorageState } from 'ahooks' +import { ArrowLeftOutlined } from '@ant-design/icons' import client from '@lib/client' import { useClientRequest } from '@lib/utils/useClientRequest' @@ -90,7 +91,14 @@ function DetailPage() { return (
- + + {t('slow_query.detail.head.back')} + + } + > {error && } {!!data && ( diff --git a/ui/lib/apps/SlowQuery/pages/List/index.tsx b/ui/lib/apps/SlowQuery/pages/List/index.tsx index e05ec09c23..2951e7687d 100644 --- a/ui/lib/apps/SlowQuery/pages/List/index.tsx +++ b/ui/lib/apps/SlowQuery/pages/List/index.tsx @@ -1,4 +1,4 @@ -import React from 'react' +import React, { useContext } from 'react' import { useTranslation } from 'react-i18next' import { Select, @@ -26,6 +26,7 @@ import { Toolbar, MultiSelect, } from '@lib/components' +import { CacheContext } from '@lib/utils/useCache' import SlowQueriesTable from '../../components/SlowQueriesTable' import useSlowQueryTableController, { @@ -42,6 +43,8 @@ const LIMITS = [100, 200, 500, 1000] function List() { const { t } = useTranslation() + const slowQueryCacheMgr = useContext(CacheContext) + const [visibleColumnKeys, setVisibleColumnKeys] = useLocalStorageState( SLOW_QUERY_VISIBLE_COLUMN_KEYS, DEF_SLOW_QUERY_COLUMN_KEYS @@ -51,7 +54,11 @@ function List() { false ) - const controller = useSlowQueryTableController(visibleColumnKeys, showFullSQL) + const controller = useSlowQueryTableController( + slowQueryCacheMgr, + visibleColumnKeys, + showFullSQL + ) const { queryOptions, setQueryOptions, diff --git a/ui/lib/apps/SlowQuery/utils/useSlowQueryTableController.ts b/ui/lib/apps/SlowQuery/utils/useSlowQueryTableController.ts index 48aa0bfb1f..3a15b80629 100644 --- a/ui/lib/apps/SlowQuery/utils/useSlowQueryTableController.ts +++ b/ui/lib/apps/SlowQuery/utils/useSlowQueryTableController.ts @@ -3,11 +3,19 @@ import { useSessionStorageState } from 'ahooks' import { IColumn } from 'office-ui-fabric-react/lib/DetailsList' import client, { ErrorStrategy, SlowquerySlowQuery } from '@lib/client' -import { calcTimeRange, TimeRange, IColumnKeys } from '@lib/components' +import { + calcTimeRange, + TimeRange, + IColumnKeys, + stringifyTimeRange, +} from '@lib/components' import useOrderState, { IOrderOptions } from '@lib/utils/useOrderState' -import { derivedFields, slowQueryColumns } from './tableColumns' import { getSelectedFields } from '@lib/utils/tableColumnFactory' +import { CacheMgr } from '@lib/utils/useCache' +import useCacheItemIndex from '@lib/utils/useCacheItemIndex' + +import { derivedFields, slowQueryColumns } from './tableColumns' export const DEF_SLOW_QUERY_COLUMN_KEYS: IColumnKeys = { query: true, @@ -62,9 +70,13 @@ export interface ISlowQueryTableController { downloadCSV: () => Promise downloading: boolean + + saveClickedItemIndex: (idx: number) => void + getClickedItemIndex: () => number } export default function useSlowQueryTableController( + cacheMgr: CacheMgr | null, visibleColumnKeys: IColumnKeys, showFullSQL: boolean, options?: ISlowQueryOptions, @@ -93,7 +105,7 @@ export default function useSlowQueryTableController( }, [queryOptions]) const [allSchemas, setAllSchemas] = useState([]) - const [loadingSlowQueries, setLoadingSlowQueries] = useState(true) + const [loadingSlowQueries, setLoadingSlowQueries] = useState(false) const [slowQueries, setSlowQueries] = useState([]) const [refreshTimes, setRefreshTimes] = useState(0) @@ -107,7 +119,32 @@ export default function useSlowQueryTableController( const [errors, setErrors] = useState([]) + const selectedFields = useMemo( + () => getSelectedFields(visibleColumnKeys, derivedFields).join(','), + [visibleColumnKeys] + ) + + const cacheKey = useMemo(() => { + const { + schemas, + digest, + limit, + plans, + searchText, + timeRange, + } = queryOptions + const { desc, orderBy } = orderOptions + const cacheKey = `${schemas.join(',')}_${digest}_${limit}_${plans.join( + ',' + )}_${searchText}_${stringifyTimeRange( + timeRange + )}_${desc}_${orderBy}_${selectedFields}` + return cacheKey + }, [queryOptions, orderOptions, selectedFields]) + function refresh() { + cacheMgr?.remove(cacheKey) + setErrors([]) setRefreshTimes((prev) => prev + 1) } @@ -127,11 +164,6 @@ export default function useSlowQueryTableController( querySchemas() }, []) - const selectedFields = useMemo( - () => getSelectedFields(visibleColumnKeys, derivedFields).join(','), - [visibleColumnKeys] - ) - const tableColumns = useMemo( () => slowQueryColumns(slowQueries, showFullSQL), [slowQueries, showFullSQL] @@ -139,6 +171,12 @@ export default function useSlowQueryTableController( useEffect(() => { async function getSlowQueryList() { + const cacheItem = cacheMgr?.get(cacheKey) + if (cacheItem) { + setSlowQueries(cacheItem) + return + } + setLoadingSlowQueries(true) try { const res = await client @@ -159,15 +197,23 @@ export default function useSlowQueryTableController( } ) setSlowQueries(res.data || []) + cacheMgr?.set(cacheKey, res.data || []) setErrors([]) } catch (e) { setErrors((prev) => prev.concat(e)) } setLoadingSlowQueries(false) } - getSlowQueryList() - }, [queryOptions, orderOptions, queryTimeRange, refreshTimes, selectedFields]) + }, [ + queryOptions, + orderOptions, + queryTimeRange, + selectedFields, + refreshTimes, + cacheKey, + cacheMgr, + ]) const [downloading, setDownloading] = useState(false) @@ -194,6 +240,10 @@ export default function useSlowQueryTableController( } } + const { saveClickedItemIndex, getClickedItemIndex } = useCacheItemIndex( + cacheMgr + ) + return { queryOptions, setQueryOptions, @@ -213,5 +263,8 @@ export default function useSlowQueryTableController( downloading, downloadCSV, + + saveClickedItemIndex, + getClickedItemIndex, } } diff --git a/ui/lib/apps/Statement/components/StatementsTable.tsx b/ui/lib/apps/Statement/components/StatementsTable.tsx index 38c10716e5..43f44f969c 100644 --- a/ui/lib/apps/Statement/components/StatementsTable.tsx +++ b/ui/lib/apps/Statement/components/StatementsTable.tsx @@ -1,6 +1,10 @@ import { usePersistFn } from 'ahooks' import React, { useCallback } from 'react' +import { useNavigate } from 'react-router-dom' + +import openLink from '@lib/utils/openLink' import { CardTable, ICardTableProps } from '@lib/components' + import DetailPage from '../pages/Detail' import { IStatementTableController } from '../utils/useStatementTableController' @@ -18,17 +22,24 @@ export default function StatementsTable({ controller, ...restPrpos }: Props) { errors, tableColumns, visibleColumnKeys, + + getClickedItemIndex, + saveClickedItemIndex, } = controller - const handleRowClick = usePersistFn((rec) => { - const qs = DetailPage.buildQuery({ - digest: rec.digest, - schema: rec.schema_name, - beginTime: begin_time, - endTime: end_time, - }) - window.open(`#/statement/detail?${qs}`, '_blank') - }) + const navigate = useNavigate() + const handleRowClick = usePersistFn( + (rec, idx, ev: React.MouseEvent) => { + saveClickedItemIndex(idx) + const qs = DetailPage.buildQuery({ + digest: rec.digest, + schema: rec.schema_name, + beginTime: begin_time, + endTime: end_time, + }) + openLink(`/statement/detail?${qs}`, ev, navigate) + } + ) const getKey = useCallback((row) => `${row.digest}_${row.schema_name}`, []) @@ -45,6 +56,7 @@ export default function StatementsTable({ controller, ...restPrpos }: Props) { visibleColumnKeys={visibleColumnKeys} onRowClicked={handleRowClick} getKey={getKey} + clickedRowIndex={getClickedItemIndex()} /> ) } diff --git a/ui/lib/apps/Statement/index.tsx b/ui/lib/apps/Statement/index.tsx index 792f4e7e57..d4af59a6c4 100644 --- a/ui/lib/apps/Statement/index.tsx +++ b/ui/lib/apps/Statement/index.tsx @@ -2,17 +2,23 @@ import React from 'react' import { HashRouter as Router, Routes, Route } from 'react-router-dom' import { Root } from '@lib/components' -import { List, Detail } from './pages' +import useCache, { CacheContext } from '@lib/utils/useCache' + +import { Detail, List } from './pages' export default function () { + const statementCacheMgr = useCache(2) + return ( - - - } /> - } /> - - + + + + } /> + } /> + + + ) } diff --git a/ui/lib/apps/Statement/pages/Detail/SlowQueryTab.tsx b/ui/lib/apps/Statement/pages/Detail/SlowQueryTab.tsx index c84b48d279..5b5fbfe3c5 100644 --- a/ui/lib/apps/Statement/pages/Detail/SlowQueryTab.tsx +++ b/ui/lib/apps/Statement/pages/Detail/SlowQueryTab.tsx @@ -12,6 +12,7 @@ export interface ISlowQueryTabProps { export default function SlowQueryTab({ query }: ISlowQueryTabProps) { const controller = useSlowQueryTableController( + null, DEF_SLOW_QUERY_COLUMN_KEYS, false, { diff --git a/ui/lib/apps/Statement/pages/Detail/index.tsx b/ui/lib/apps/Statement/pages/Detail/index.tsx index 9621d5752d..12e1ce214b 100644 --- a/ui/lib/apps/Statement/pages/Detail/index.tsx +++ b/ui/lib/apps/Statement/pages/Detail/index.tsx @@ -3,8 +3,9 @@ import { SelectionMode } from 'office-ui-fabric-react/lib/DetailsList' import { Selection } from 'office-ui-fabric-react/lib/Selection' import React, { useEffect, useMemo, useRef, useState } from 'react' import { useTranslation } from 'react-i18next' -import { useLocation } from 'react-router-dom' +import { Link, useLocation } from 'react-router-dom' import { useLocalStorageState } from 'ahooks' +import { ArrowLeftOutlined } from '@ant-design/icons' import client, { StatementModel } from '@lib/client' import { @@ -75,7 +76,14 @@ function DetailPage() { return (
- + + {t('statement.pages.detail.head.back')} + + } + > {error && } {plans && plans.length > 0 && ( diff --git a/ui/lib/apps/Statement/pages/List/TimeRangeSelector.tsx b/ui/lib/apps/Statement/pages/List/TimeRangeSelector.tsx index b6cb3255d4..2cf760603c 100644 --- a/ui/lib/apps/Statement/pages/List/TimeRangeSelector.tsx +++ b/ui/lib/apps/Statement/pages/List/TimeRangeSelector.tsx @@ -48,6 +48,15 @@ export const DEFAULT_TIME_RANGE: TimeRange = { value: 30 * 60, } +export function stringifyTimeRange(timeRange?: TimeRange): string { + let t2 = timeRange ?? DEFAULT_TIME_RANGE + if (t2.type === 'absolute') { + return `${t2.type}_${t2.value[0]}_${t2.value[1]}` + } else { + return `${t2.type}_${t2.value}` + } +} + // timePoints are descent array function findNearTimePoint(timePoint: number, timePoints: number[]): number { if (timePoints.length === 0) { diff --git a/ui/lib/apps/Statement/pages/List/index.tsx b/ui/lib/apps/Statement/pages/List/index.tsx index 28368a8c9c..4316f40d0e 100644 --- a/ui/lib/apps/Statement/pages/List/index.tsx +++ b/ui/lib/apps/Statement/pages/List/index.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react' +import React, { useState, useContext } from 'react' import { Space, Tooltip, @@ -22,6 +22,7 @@ import { import { ScrollablePane } from 'office-ui-fabric-react/lib/ScrollablePane' import { useTranslation } from 'react-i18next' +import { CacheContext } from '@lib/utils/useCache' import { Card, ColumnsSelector, Toolbar, MultiSelect } from '@lib/components' import { StatementsTable } from '../../components' @@ -39,6 +40,8 @@ const STMT_SHOW_FULL_SQL = 'statement.show_full_sql' export default function StatementsOverview() { const { t } = useTranslation() + const statementCacheMgr = useContext(CacheContext) + const [showSettings, setShowSettings] = useState(false) const [visibleColumnKeys, setVisibleColumnKeys] = useLocalStorageState( STMT_VISIBLE_COLUMN_KEYS, @@ -49,7 +52,11 @@ export default function StatementsOverview() { false ) - const controller = useStatementTableController(visibleColumnKeys, showFullSQL) + const controller = useStatementTableController( + statementCacheMgr, + visibleColumnKeys, + showFullSQL + ) const { queryOptions, setQueryOptions, diff --git a/ui/lib/apps/Statement/utils/useStatementTableController.ts b/ui/lib/apps/Statement/utils/useStatementTableController.ts index afb26a33e7..dae7e097f2 100644 --- a/ui/lib/apps/Statement/utils/useStatementTableController.ts +++ b/ui/lib/apps/Statement/utils/useStatementTableController.ts @@ -7,8 +7,11 @@ import client, { StatementModel, StatementTimeRange, } from '@lib/client' -import { IColumnKeys } from '@lib/components' +import { IColumnKeys, stringifyTimeRange } from '@lib/components' +import { getSelectedFields } from '@lib/utils/tableColumnFactory' +import { CacheMgr } from '@lib/utils/useCache' import useOrderState, { IOrderOptions } from '@lib/utils/useOrderState' +import useCacheItemIndex from '@lib/utils/useCacheItemIndex' import { calcValidStatementTimeRange, @@ -16,7 +19,6 @@ import { TimeRange, } from '../pages/List/TimeRangeSelector' import { derivedFields, statementColumns } from './tableColumns' -import { getSelectedFields } from '@lib/utils/tableColumnFactory' export const DEF_STMT_COLUMN_KEYS: IColumnKeys = { digest_text: true, @@ -70,9 +72,13 @@ export interface IStatementTableController { downloadCSV: () => Promise downloading: boolean + + saveClickedItemIndex: (idx: number) => void + getClickedItemIndex: () => number } export default function useStatementTableController( + cacheMgr: CacheMgr | null, visibleColumnKeys: IColumnKeys, showFullSQL: boolean, options?: IStatementQueryOptions, @@ -121,8 +127,28 @@ export default function useStatementTableController( const [errors, setErrors] = useState([]) + useEffect(() => { + errors.length && setLoadingStatements(false) + }, [errors]) + + const selectedFields = useMemo( + () => getSelectedFields(visibleColumnKeys, derivedFields).join(','), + [visibleColumnKeys] + ) + + const cacheKey = useMemo(() => { + const { schemas, stmtTypes, searchText, timeRange } = queryOptions + const cacheKey = `${schemas.join(',')}_${stmtTypes.join( + ',' + )}_${searchText}_${stringifyTimeRange(timeRange)}_${selectedFields}` + return cacheKey + }, [queryOptions, selectedFields]) + function refresh() { + cacheMgr?.remove(cacheKey) + setErrors([]) + setLoadingStatements(true) setRefreshTimes((prev) => prev + 1) } @@ -177,11 +203,6 @@ export default function useStatementTableController( queryStmtTypes() }, [refreshTimes]) - const selectedFields = useMemo( - () => getSelectedFields(visibleColumnKeys, derivedFields).join(','), - [visibleColumnKeys] - ) - const tableColumns = useMemo( () => statementColumns(statements, showFullSQL), [statements, showFullSQL] @@ -189,12 +210,16 @@ export default function useStatementTableController( useEffect(() => { async function queryStatementList() { - if (allTimeRanges.length === 0) { - setStatements([]) + const cacheItem = cacheMgr?.get(cacheKey) + if (cacheItem) { + setStatements(cacheItem) setLoadingStatements(false) return } + if (allTimeRanges.length === 0) { + return + } setLoadingStatements(true) try { const res = await client @@ -211,6 +236,7 @@ export default function useStatementTableController( } ) setStatements(res?.data || []) + cacheMgr?.set(cacheKey, res?.data || []) setErrors([]) } catch (e) { setErrors((prev) => prev.concat(e)) @@ -219,7 +245,14 @@ export default function useStatementTableController( } queryStatementList() - }, [queryOptions, allTimeRanges, validTimeRange, selectedFields]) + }, [ + queryOptions, + allTimeRanges, + validTimeRange, + selectedFields, + cacheKey, + cacheMgr, + ]) const [downloading, setDownloading] = useState(false) @@ -243,6 +276,10 @@ export default function useStatementTableController( } } + const { saveClickedItemIndex, getClickedItemIndex } = useCacheItemIndex( + cacheMgr + ) + return { queryOptions, setQueryOptions, @@ -265,5 +302,8 @@ export default function useStatementTableController( downloadCSV, downloading, + + saveClickedItemIndex, + getClickedItemIndex, } } diff --git a/ui/lib/apps/UserProfile/index.tsx b/ui/lib/apps/UserProfile/index.tsx index 03b8f0b38b..07d9d525ff 100644 --- a/ui/lib/apps/UserProfile/index.tsx +++ b/ui/lib/apps/UserProfile/index.tsx @@ -42,7 +42,19 @@ import { getValueFormat } from '@baurine/grafana-value-formats' import ReactMarkdown from 'react-markdown' const DEFAULT_FORM_ITEM_STYLE = { width: 200 } -const SHARE_SESSION_EXPIRY_HOURS = [0.25, 0.5, 1, 2, 3, 6, 12, 24] +const SHARE_SESSION_EXPIRY_HOURS = [ + 0.25, + 0.5, + 1, + 2, + 3, + 6, + 12, + 24, + 24 * 3, + 24 * 7, + 24 * 30, +] function ShareSessionButton() { const { t } = useTranslation() diff --git a/ui/lib/components/CardTable/index.module.less b/ui/lib/components/CardTable/index.module.less index 8c57c451f3..af3857d6a5 100644 --- a/ui/lib/components/CardTable/index.module.less +++ b/ui/lib/components/CardTable/index.module.less @@ -51,6 +51,10 @@ cursor: pointer; } +.highlightRow { + border: 1px solid; +} + .cardTableContent { margin-left: -@padding-page; margin-right: -@padding-page; diff --git a/ui/lib/components/CardTable/index.tsx b/ui/lib/components/CardTable/index.tsx index 0073f11c4c..6272c876f5 100644 --- a/ui/lib/components/CardTable/index.tsx +++ b/ui/lib/components/CardTable/index.tsx @@ -7,11 +7,12 @@ import { DetailsList, DetailsListLayoutMode, IColumn, + IDetailsList, IDetailsListProps, SelectionMode, } from 'office-ui-fabric-react/lib/DetailsList' import { Sticky, StickyPositionType } from 'office-ui-fabric-react/lib/Sticky' -import React, { useCallback, useMemo } from 'react' +import React, { useCallback, useEffect, useMemo, useRef } from 'react' import AnimatedSkeleton from '../AnimatedSkeleton' import Card from '../Card' @@ -96,9 +97,10 @@ export interface ICardTableProps extends IDetailsListProps { itemIndex: number, ev: React.MouseEvent ) => void + clickedRowIndex?: number } -function useRenderClickableRow(onRowClicked) { +function useRenderClickableRow(onRowClicked, clickedRowIdx) { return useCallback( (props, defaultRender) => { if (!props) { @@ -106,14 +108,16 @@ function useRenderClickableRow(onRowClicked) { } return (
onRowClicked?.(props.item, props.itemIndex, ev)} > {defaultRender!(props)}
) }, - [onRowClicked] + [onRowClicked, clickedRowIdx] ) } @@ -146,11 +150,15 @@ export default function CardTable(props: ICardTableProps) { desc = true, onChangeOrder, onRowClicked, + clickedRowIndex, columns, items, ...restProps } = props - const renderClickableRow = useRenderClickableRow(onRowClicked) + const renderClickableRow = useRenderClickableRow( + onRowClicked, + clickedRowIndex || -1 + ) const onColumnClick = usePersistFn( (_ev: React.MouseEvent, column: IColumn) => { @@ -207,6 +215,13 @@ export default function CardTable(props: ICardTableProps) { return newItems }, [visibleItemsCount, items, orderBy, finalColumns]) + const tableRef = useRef(null) + useEffect(() => { + if ((clickedRowIndex ?? -1) > 0) { + tableRef.current?.scrollToIndex(clickedRowIndex!) + } + }) + return (
diff --git a/ui/lib/components/TimeRangeSelector/index.tsx b/ui/lib/components/TimeRangeSelector/index.tsx index dba1292bd6..d811bbae5a 100644 --- a/ui/lib/components/TimeRangeSelector/index.tsx +++ b/ui/lib/components/TimeRangeSelector/index.tsx @@ -56,6 +56,15 @@ export function calcTimeRange(timeRange?: TimeRange): [number, number] { } } +export function stringifyTimeRange(timeRange?: TimeRange): string { + let t2 = timeRange ?? DEFAULT_TIME_RANGE + if (t2.type === 'absolute') { + return `${t2.type}_${t2.value[0]}_${t2.value[1]}` + } else { + return `${t2.type}_${t2.value}` + } +} + export interface ITimeRangeSelectorProps { value?: TimeRange onChange?: (val: TimeRange) => void diff --git a/ui/lib/utils/useCache.ts b/ui/lib/utils/useCache.ts new file mode 100644 index 0000000000..a3506edd20 --- /dev/null +++ b/ui/lib/utils/useCache.ts @@ -0,0 +1,69 @@ +import { useRef, createContext } from 'react' + +type CacheItem = { + expireAt: number + data: any +} + +type Cache = Record + +const ONE_HOUR_TIME = 1 * 60 * 60 * 1000 + +export type CacheMgr = { + get: (key: string) => any + set: (key: string, val: any, expire?: number) => void + remove: (key: string) => void +} + +export const CacheContext = createContext(null) + +export default function useCache( + capacity: number = 1, + globalExpire: number = ONE_HOUR_TIME +): CacheMgr { + const cache = useRef({}) + const cacheItemKeys = useRef([]) + + function get(key: string): any { + const item = cache.current[key] + if (item === undefined) { + return undefined + } + if (item.expireAt < new Date().valueOf()) { + remove(key) + return undefined + } + return item.data + } + + function set(key: string, val: any, expire?: number) { + const curTime = new Date().valueOf() + let expireAt: number + if (expire) { + expireAt = curTime + expire + } else { + expireAt = curTime + globalExpire + } + cache.current[key] = { + expireAt, + data: val, + } + + // put the latest key in the end of cacheItemKeys + cacheItemKeys.current = cacheItemKeys.current + .filter((k) => k !== key) + .concat(key) + // if size beyonds the capacity + // remove the old ones + while (capacity > 0 && cacheItemKeys.current.length > capacity) { + remove(cacheItemKeys.current[0]) + } + } + + function remove(key: string) { + delete cache.current[key] + cacheItemKeys.current = cacheItemKeys.current.filter((k) => k !== key) + } + + return { get, set, remove } +} diff --git a/ui/lib/utils/useCacheItemIndex.ts b/ui/lib/utils/useCacheItemIndex.ts new file mode 100644 index 0000000000..cde12ccff0 --- /dev/null +++ b/ui/lib/utils/useCacheItemIndex.ts @@ -0,0 +1,16 @@ +import { CacheMgr } from './useCache' + +export default function useCacheItemIndex(cacheMgr: CacheMgr | null) { + const CLICKED_ITEM_INDEX = 'clicked_item_index' + function saveClickedItemIndex(idx: number) { + cacheMgr?.set(CLICKED_ITEM_INDEX, idx) + } + function getClickedItemIndex(): number { + return cacheMgr?.get(CLICKED_ITEM_INDEX) || -1 + } + + return { + saveClickedItemIndex, + getClickedItemIndex, + } +} diff --git a/ui/package.json b/ui/package.json index 1d61c590de..78f7e10cce 100644 --- a/ui/package.json +++ b/ui/package.json @@ -14,7 +14,7 @@ "ace-builds": "^1.4.12", "ahooks": "^2.9.2", "antd": "~4.8.5", - "axios": "^0.19.0", + "axios": "^0.21.1", "bulma": "^0.9.0", "classnames": "^2.2.6", "d3": "^5.16.0", diff --git a/ui/public/compat.js b/ui/public/compat.js index ba54664c7a..e3639d22cf 100644 --- a/ui/public/compat.js +++ b/ui/public/compat.js @@ -49,16 +49,15 @@ checkBrowser() // Dealing with compatibility issues manually for special cases // Object.entries -// see https://github.com/pingcap-incubator/tidb-dashboard/issues/770 +// see https://github.com/pingcap/tidb-dashboard/issues/770 // polyfill from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries if (!Object.entries) { - Object.entries = function( obj ){ - var ownProps = Object.keys( obj ), + Object.entries = function (obj) { + var ownProps = Object.keys(obj), i = ownProps.length, - resArray = new Array(i); // preallocate the Array - while (i--) - resArray[i] = [ownProps[i], obj[ownProps[i]]]; + resArray = new Array(i) // preallocate the Array + while (i--) resArray[i] = [ownProps[i], obj[ownProps[i]]] - return resArray; - }; + return resArray + } } diff --git a/ui/yarn.lock b/ui/yarn.lock index 57d0280775..c50cfba180 100644 --- a/ui/yarn.lock +++ b/ui/yarn.lock @@ -4764,12 +4764,12 @@ aws4@^1.8.0: resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.10.0.tgz#a17b3a8ea811060e74d47d306122400ad4497ae2" integrity sha512-3YDiu347mtVtjpyV3u5kVqQLP242c06zwDOgpeRnybmXlYYsLbtTrUBUm8i8srONt+FWobl5aibnU1030PeeuA== -axios@^0.19.0: - version "0.19.2" - resolved "https://registry.yarnpkg.com/axios/-/axios-0.19.2.tgz#3ea36c5d8818d0d5f8a8a97a6d36b86cdc00cb27" - integrity sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA== +axios@^0.21.1: + version "0.21.1" + resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.1.tgz#22563481962f4d6bde9a76d516ef0e5d3c09b2b8" + integrity sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA== dependencies: - follow-redirects "1.5.10" + follow-redirects "^1.10.0" axobject-query@^2.0.2: version "2.1.2" @@ -7009,13 +7009,6 @@ debug@2.6.9, debug@^2.2.0, debug@^2.3.3, debug@^2.6.0, debug@^2.6.9: dependencies: ms "2.0.0" -debug@=3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" - integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g== - dependencies: - ms "2.0.0" - debug@^3.0.0, debug@^3.1.1, debug@^3.2.5: version "3.2.6" resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b" @@ -8487,19 +8480,10 @@ flush-write-stream@^1.0.0, flush-write-stream@^1.0.2: inherits "^2.0.3" readable-stream "^2.3.6" -follow-redirects@1.5.10: - version "1.5.10" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.5.10.tgz#7b7a9f9aea2fdff36786a94ff643ed07f4ff5e2a" - integrity sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ== - dependencies: - debug "=3.1.0" - -follow-redirects@^1.0.0: - version "1.11.0" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.11.0.tgz#afa14f08ba12a52963140fe43212658897bc0ecb" - integrity sha512-KZm0V+ll8PfBrKwMzdo5D13b1bur9Iq9Zd/RMmAoQQcl2PxxFml8cxXPaaPYVbV0RjNjq1CU7zIzAOqtUPudmA== - dependencies: - debug "^3.0.0" +follow-redirects@^1.0.0, follow-redirects@^1.10.0: + version "1.13.1" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.13.1.tgz#5f69b813376cee4fd0474a3aba835df04ab763b7" + integrity sha512-SSG5xmZh1mkPGyKzjZP8zLjltIfpW32Y5QpdNJyjcfGxK3qo3NDDkZOZSFiGn1A6SclQxY9GzEwAHQ3dmYRWpg== for-in@^0.1.3: version "0.1.8"