From b3c3e68c84ae59e7c1d06861c0fc46a35ee6120d Mon Sep 17 00:00:00 2001 From: mornyx Date: Thu, 12 Dec 2024 11:15:21 +0800 Subject: [PATCH] remove 2 mis-added files in utils/topology Signed-off-by: mornyx --- pkg/utils/topology/scheduling.go | 64 -------------------------------- pkg/utils/topology/tso.go | 64 -------------------------------- 2 files changed, 128 deletions(-) delete mode 100644 pkg/utils/topology/scheduling.go delete mode 100644 pkg/utils/topology/tso.go diff --git a/pkg/utils/topology/scheduling.go b/pkg/utils/topology/scheduling.go deleted file mode 100644 index db3c940f6..000000000 --- a/pkg/utils/topology/scheduling.go +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2024 PingCAP, Inc. Licensed under Apache-2.0. - -package topology - -import ( - "context" - "encoding/json" - "sort" - - "github.com/pingcap/tidb-dashboard/pkg/pd" - "github.com/pingcap/tidb-dashboard/util/distro" - "github.com/pingcap/tidb-dashboard/util/netutil" -) - -func FetchSchedulingTopology(_ context.Context, pdClient *pd.Client) ([]SchedulingInfo, error) { - nodes := make([]SchedulingInfo, 0) - data, err := pdClient.WithoutPrefix().SendGetRequest("/pd/api/v2/ms/members/scheduling") - if err != nil { - return nil, err - } - - ds := []struct { - ServiceAddr string `json:"service-addr"` - Version string `json:"version"` - GitHash string `json:"git-hash"` - DeployPath string `json:"deploy-path"` - StartTimestamp int64 `json:"start-timestamp"` - }{} - - err = json.Unmarshal(data, &ds) - if err != nil { - return nil, ErrInvalidTopologyData.Wrap(err, "%s members API unmarshal failed", distro.R().Scheduling) - } - - for _, ds := range ds { - u := ds.ServiceAddr - hostname, port, err := netutil.ParseHostAndPortFromAddressURL(u) - if err != nil { - continue - } - - nodes = append(nodes, SchedulingInfo{ - GitHash: ds.GitHash, - Version: ds.Version, - IP: hostname, - Port: port, - DeployPath: ds.DeployPath, - Status: ComponentStatusUp, - StartTimestamp: ds.StartTimestamp, - }) - } - - sort.Slice(nodes, func(i, j int) bool { - if nodes[i].IP < nodes[j].IP { - return true - } - if nodes[i].IP > nodes[j].IP { - return false - } - return nodes[i].Port < nodes[j].Port - }) - - return nodes, nil -} diff --git a/pkg/utils/topology/tso.go b/pkg/utils/topology/tso.go deleted file mode 100644 index 35d79c5a8..000000000 --- a/pkg/utils/topology/tso.go +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2024 PingCAP, Inc. Licensed under Apache-2.0. - -package topology - -import ( - "context" - "encoding/json" - "sort" - - "github.com/pingcap/tidb-dashboard/pkg/pd" - "github.com/pingcap/tidb-dashboard/util/distro" - "github.com/pingcap/tidb-dashboard/util/netutil" -) - -func FetchTSOTopology(_ context.Context, pdClient *pd.Client) ([]TSOInfo, error) { - nodes := make([]TSOInfo, 0) - data, err := pdClient.WithoutPrefix().SendGetRequest("/pd/api/v2/ms/members/tso") - if err != nil { - return nil, err - } - - ds := []struct { - ServiceAddr string `json:"service-addr"` - Version string `json:"version"` - GitHash string `json:"git-hash"` - DeployPath string `json:"deploy-path"` - StartTimestamp int64 `json:"start-timestamp"` - }{} - - err = json.Unmarshal(data, &ds) - if err != nil { - return nil, ErrInvalidTopologyData.Wrap(err, "%s members API unmarshal failed", distro.R().TSO) - } - - for _, ds := range ds { - u := ds.ServiceAddr - hostname, port, err := netutil.ParseHostAndPortFromAddressURL(u) - if err != nil { - continue - } - - nodes = append(nodes, TSOInfo{ - GitHash: ds.GitHash, - Version: ds.Version, - IP: hostname, - Port: port, - DeployPath: ds.DeployPath, - Status: ComponentStatusUp, - StartTimestamp: ds.StartTimestamp, - }) - } - - sort.Slice(nodes, func(i, j int) bool { - if nodes[i].IP < nodes[j].IP { - return true - } - if nodes[i].IP > nodes[j].IP { - return false - } - return nodes[i].Port < nodes[j].Port - }) - - return nodes, nil -}