Skip to content

Commit

Permalink
add a new flag '--numa' to show numa in display command (#2295)
Browse files Browse the repository at this point in the history
  • Loading branch information
KanShiori authored Oct 31, 2023
1 parent 79d3011 commit bdf6f26
Show file tree
Hide file tree
Showing 17 changed files with 58 additions and 0 deletions.
1 change: 1 addition & 0 deletions components/cluster/command/display.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ func newDisplayCmd() *cobra.Command {
cmd.Flags().BoolVar(&showTiKVLabels, "labels", false, "Only display labels of specified TiKV role or nodes")
cmd.Flags().BoolVar(&dopt.ShowProcess, "process", false, "display cpu and memory usage of nodes")
cmd.Flags().BoolVar(&dopt.ShowManageHost, "manage-host", false, "display manage host of nodes")
cmd.Flags().BoolVar(&dopt.ShowNuma, "numa", false, "display numa information of nodes")
cmd.Flags().Uint64Var(&statusTimeout, "status-timeout", 10, "Timeout in seconds when getting node status")

return cmd
Expand Down
13 changes: 13 additions & 0 deletions pkg/cluster/manager/display.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ type DisplayOption struct {
ShowUptime bool
ShowProcess bool
ShowManageHost bool
ShowNuma bool
}

// InstInfo represents an instance info
Expand All @@ -67,6 +68,8 @@ type InstInfo struct {
Since string `json:"since"`
DataDir string `json:"data_dir"`
DeployDir string `json:"deploy_dir"`
NumaNode string `json:"numa_node"`
NumaCores string `json:"numa_cores"`

ComponentName string
Port int
Expand Down Expand Up @@ -199,6 +202,10 @@ func (m *Manager) Display(dopt DisplayOption, opt operator.Options) error {
if dopt.ShowUptime {
rowHead = append(rowHead, "Since")
}
if dopt.ShowNuma {
rowHead = append(rowHead, "Numa Node", "Numd Cores")
}

rowHead = append(rowHead, "Data Dir", "Deploy Dir")
clusterTable = append(clusterTable, rowHead)

Expand All @@ -225,6 +232,10 @@ func (m *Manager) Display(dopt DisplayOption, opt operator.Options) error {
if dopt.ShowUptime {
row = append(row, v.Since)
}
if dopt.ShowNuma {
row = append(row, v.NumaNode, v.NumaCores)
}

row = append(row, v.DataDir, v.DeployDir)
clusterTable = append(clusterTable, row)

Expand Down Expand Up @@ -654,6 +665,8 @@ func (m *Manager) GetClusterTopology(dopt DisplayOption, opt operator.Options) (
ComponentName: ins.ComponentName(),
Port: ins.GetPort(),
Since: since,
NumaNode: utils.Ternary(ins.GetNumaNode() == "", "-", ins.GetNumaNode()).(string),
NumaCores: utils.Ternary(ins.GetNumaCores() == "", "-", ins.GetNumaCores()).(string),
})
mu.Unlock()
}, opt.Concurrency)
Expand Down
2 changes: 2 additions & 0 deletions pkg/cluster/spec/alertmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ func (c *AlertManagerComponent) Instances() []Instance {
ListenHost: s.ListenHost,
Port: s.WebPort,
SSHP: s.SSHPort,
NumaNode: s.NumaNode,
NumaCores: "",

Ports: []int{
s.WebPort,
Expand Down
2 changes: 2 additions & 0 deletions pkg/cluster/spec/cdc.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ func (c *CDCComponent) Instances() []Instance {
Port: s.Port,
SSHP: s.SSHPort,
Source: s.GetSource(),
NumaNode: s.NumaNode,
NumaCores: "",

Ports: []int{
s.Port,
Expand Down
2 changes: 2 additions & 0 deletions pkg/cluster/spec/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ func (c *DashboardComponent) Instances() []Instance {
Port: s.Port,
SSHP: s.SSHPort,
Source: s.Source,
NumaNode: s.NumaNode,
NumaCores: "",

Ports: []int{
s.Port,
Expand Down
2 changes: 2 additions & 0 deletions pkg/cluster/spec/drainer.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ func (c *DrainerComponent) Instances() []Instance {
Port: s.Port,
SSHP: s.SSHPort,
Source: s.GetSource(),
NumaNode: s.NumaNode,
NumaCores: "",

Ports: []int{
s.Port,
Expand Down
2 changes: 2 additions & 0 deletions pkg/cluster/spec/grafana.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ func (c *GrafanaComponent) Instances() []Instance {
ManageHost: s.ManageHost,
Port: s.Port,
SSHP: s.SSHPort,
NumaNode: "",
NumaCores: "",

Ports: []int{
s.Port,
Expand Down
14 changes: 14 additions & 0 deletions pkg/cluster/spec/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ type Instance interface {
GetManageHost() string
GetPort() int
GetSSHPort() int
GetNumaNode() string
GetNumaCores() string
DeployDir() string
UsedPorts() []int
UsedDirs() []string
Expand Down Expand Up @@ -145,6 +147,8 @@ type BaseInstance struct {
Port int
SSHP int
Source string
NumaNode string
NumaCores string

Ports []int
Dirs []string
Expand Down Expand Up @@ -366,6 +370,16 @@ func (i *BaseInstance) GetSSHPort() int {
return i.SSHP
}

// GetNumaNode implements Instance interface
func (i *BaseInstance) GetNumaNode() string {
return i.NumaNode
}

// GetNumaCores implements Instance interface
func (i *BaseInstance) GetNumaCores() string {
return i.NumaCores
}

// DeployDir implements Instance interface
func (i *BaseInstance) DeployDir() string {
return reflect.Indirect(reflect.ValueOf(i.InstanceSpec)).FieldByName("DeployDir").String()
Expand Down
2 changes: 2 additions & 0 deletions pkg/cluster/spec/monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ func (c *MonitorComponent) Instances() []Instance {
ManageHost: s.ManageHost,
Port: s.Port,
SSHP: s.SSHPort,
NumaNode: s.NumaNode,
NumaCores: "",

Ports: []int{
s.Port,
Expand Down
2 changes: 2 additions & 0 deletions pkg/cluster/spec/pd.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ func (c *PDComponent) Instances() []Instance {
Port: s.ClientPort,
SSHP: s.SSHPort,
Source: s.GetSource(),
NumaNode: s.NumaNode,
NumaCores: "",

Ports: []int{
s.ClientPort,
Expand Down
2 changes: 2 additions & 0 deletions pkg/cluster/spec/pump.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ func (c *PumpComponent) Instances() []Instance {
Port: s.Port,
SSHP: s.SSHPort,
Source: s.GetSource(),
NumaNode: s.NumaNode,
NumaCores: "",

Ports: []int{
s.Port,
Expand Down
2 changes: 2 additions & 0 deletions pkg/cluster/spec/tidb.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ func (c *TiDBComponent) Instances() []Instance {
Port: s.Port,
SSHP: s.SSHPort,
Source: s.Source,
NumaNode: s.NumaNode,
NumaCores: s.NumaCores,

Ports: []int{
s.Port,
Expand Down
2 changes: 2 additions & 0 deletions pkg/cluster/spec/tiflash.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,8 @@ func (c *TiFlashComponent) Instances() []Instance {
Port: s.GetMainPort(),
SSHP: s.SSHPort,
Source: s.GetSource(),
NumaNode: s.NumaNode,
NumaCores: s.NumaCores,

Ports: []int{
s.TCPPort,
Expand Down
2 changes: 2 additions & 0 deletions pkg/cluster/spec/tikv.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ func (c *TiKVComponent) Instances() []Instance {
Port: s.Port,
SSHP: s.SSHPort,
Source: s.Source,
NumaNode: s.NumaNode,
NumaCores: s.NumaCores,

Ports: []int{
s.Port,
Expand Down
2 changes: 2 additions & 0 deletions pkg/cluster/spec/tikv_cdc.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ func (c *TiKVCDCComponent) Instances() []Instance {
Port: s.Port,
SSHP: s.SSHPort,
Source: s.GetSource(),
NumaNode: s.NumaNode,
NumaCores: "",

Ports: []int{
s.Port,
Expand Down
2 changes: 2 additions & 0 deletions pkg/cluster/spec/tiproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ func (c *TiProxyComponent) Instances() []Instance {
Port: s.Port,
SSHP: s.SSHPort,
Source: ComponentTiProxy,
NumaNode: s.NumaNode,
NumaCores: "",
Ports: []int{
s.Port,
s.StatusPort,
Expand Down
4 changes: 4 additions & 0 deletions pkg/cluster/spec/tispark.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ func (c *TiSparkMasterComponent) Instances() []Instance {
Host: s.Host,
Port: s.Port,
SSHP: s.SSHPort,
NumaNode: "",
NumaCores: "",

Ports: []int{
s.Port,
Expand Down Expand Up @@ -333,6 +335,8 @@ func (c *TiSparkWorkerComponent) Instances() []Instance {
Host: s.Host,
Port: s.Port,
SSHP: s.SSHPort,
NumaNode: "",
NumaCores: "",

Ports: []int{
s.Port,
Expand Down

0 comments on commit bdf6f26

Please sign in to comment.