instance

package
v1.16.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2025 License: Apache-2.0 Imports: 26 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SysProcAttr = &syscall.SysProcAttr{
	Pdeathsig: syscall.SIGKILL,
	Setpgid:   true,
}

SysProcAttr to be use for every Process we start.

Functions

func AdvertiseHost added in v1.3.3

func AdvertiseHost(listen string) string

AdvertiseHost returns the interface's ip addr if listen host is 0.0.0.0

func CompVersion added in v1.0.5

func CompVersion(comp string, version utils.Version) string

CompVersion return the format to run specified version of a component.

func GenTiProxySessionCerts added in v1.15.0

func GenTiProxySessionCerts(dir string) error

GenTiProxySessionCerts will create a self-signed certs for TiProxy session migration. NOTE that this cert is directly used by TiDB.

func PrepareCommand added in v1.9.0

func PrepareCommand(ctx context.Context, binPath string, args, envs []string, workDir string) *exec.Cmd

PrepareCommand return command for playground

Types

type CSEOptions added in v1.15.0

type CSEOptions struct {
	S3Endpoint string `yaml:"s3_endpoint"`
	Bucket     string `yaml:"bucket"`
	AccessKey  string `yaml:"access_key"`
	SecretKey  string `yaml:"secret_key"`
}

CSEOptions contains configs to run TiDB cluster in CSE mode.

type Config

type Config struct {
	ConfigPath string `yaml:"config_path"`
	BinPath    string `yaml:"bin_path"`
	Num        int    `yaml:"num"`
	Host       string `yaml:"host"`
	Port       int    `yaml:"port"`
	UpTimeout  int    `yaml:"up_timeout"`
	Version    string `yaml:"version"`
}

Config of the instance.

type DMMaster added in v1.16.1

type DMMaster struct {
	Process
	// contains filtered or unexported fields
}

DMMaster represent a DM master instance.

func NewDMMaster added in v1.16.1

func NewDMMaster(shOpt SharedOptions, binPath string, dir, host, configPath string, id int, port int) *DMMaster

NewDMMaster create a new DMMaster instance.

func (*DMMaster) Addr added in v1.16.1

func (m *DMMaster) Addr() string

Addr return the address of the instance.

func (*DMMaster) Component added in v1.16.1

func (m *DMMaster) Component() string

Component return the component of the instance.

func (*DMMaster) LogFile added in v1.16.1

func (m *DMMaster) LogFile() string

LogFile return the log file path of the instance.

func (*DMMaster) MetricAddr added in v1.16.1

func (inst *DMMaster) MetricAddr() (r MetricAddr)

func (*DMMaster) Name added in v1.16.1

func (m *DMMaster) Name() string

Name return the name of the instance.

func (*DMMaster) PrepareBinary added in v1.16.1

func (inst *DMMaster) PrepareBinary(binaryName string, componentName string, version utils.Version) error

func (*DMMaster) SetInitEndpoints added in v1.16.1

func (m *DMMaster) SetInitEndpoints(endpoints []*DMMaster)

SetInitEndpoints set the initial endpoints for the DM master.

func (*DMMaster) Start added in v1.16.1

func (m *DMMaster) Start(ctx context.Context) error

Start starts the instance.

type DMWorker added in v1.16.1

type DMWorker struct {
	Process
	// contains filtered or unexported fields
}

DMWorker represent a DM worker instance.

func NewDMWorker added in v1.16.1

func NewDMWorker(shOpt SharedOptions, binPath string, dir, host, configPath string, id int, port int, masters []*DMMaster) *DMWorker

NewDMWorker create a DMWorker instance.

func (*DMWorker) Component added in v1.16.1

func (w *DMWorker) Component() string

Component return the component of the instance.

func (*DMWorker) LogFile added in v1.16.1

func (w *DMWorker) LogFile() string

LogFile return the log file of the instance.

func (*DMWorker) MasterAddrs added in v1.16.1

func (w *DMWorker) MasterAddrs() []string

MasterAddrs return the master addresses.

func (*DMWorker) MetricAddr added in v1.16.1

func (inst *DMWorker) MetricAddr() (r MetricAddr)

func (*DMWorker) Name added in v1.16.1

func (w *DMWorker) Name() string

Name return the name of the instance.

func (*DMWorker) PrepareBinary added in v1.16.1

func (inst *DMWorker) PrepareBinary(binaryName string, componentName string, version utils.Version) error

func (*DMWorker) Start added in v1.16.1

func (w *DMWorker) Start(ctx context.Context) error

Start starts the instance.

type Drainer added in v1.0.5

type Drainer struct {
	Process
	// contains filtered or unexported fields
}

Drainer represent a drainer instance.

func NewDrainer added in v1.0.5

func NewDrainer(shOpt SharedOptions, binPath string, dir, host, configPath string, id int, pds []*PDInstance) *Drainer

NewDrainer create a Drainer instance.

func (*Drainer) Addr added in v1.0.5

func (d *Drainer) Addr() string

Addr return the address of Drainer.

func (*Drainer) Component added in v1.0.7

func (d *Drainer) Component() string

Component return component name.

func (*Drainer) LogFile added in v1.0.7

func (d *Drainer) LogFile() string

LogFile return the log file name.

func (*Drainer) MetricAddr added in v1.14.0

func (inst *Drainer) MetricAddr() (r MetricAddr)

func (*Drainer) NodeID added in v1.0.5

func (d *Drainer) NodeID() string

NodeID return the node id of drainer.

func (*Drainer) PrepareBinary added in v1.16.1

func (inst *Drainer) PrepareBinary(binaryName string, componentName string, version utils.Version) error

func (*Drainer) Start added in v1.0.5

func (d *Drainer) Start(ctx context.Context) error

Start implements Instance interface.

type Instance

type Instance interface {
	Pid() int
	// Start the instance process.
	// Will kill the process once the context is done.
	Start(ctx context.Context) error
	// Component Return the component name.
	Component() string
	// LogFile return the log file name
	LogFile() string
	// Uptime show uptime.
	Uptime() string
	// MetricAddr return the address to pull metrics.
	MetricAddr() MetricAddr
	// Wait Should only call this if the instance is started successfully.
	// The implementation should be safe to call Wait multi times.
	Wait() error
	// PrepareBinary use given binpath or download from tiup mirrors.
	PrepareBinary(binaryName string, componentName string, version utils.Version) error
}

Instance represent running component

type MetricAddr added in v1.14.0

type MetricAddr struct {
	Targets []string          `json:"targets"`
	Labels  map[string]string `json:"labels"`
}

MetricAddr will be used by prometheus scrape_configs.

type PDInstance

type PDInstance struct {
	Process
	// contains filtered or unexported fields
}

PDInstance represent a running pd-server

func NewPDInstance

func NewPDInstance(role PDRole, shOpt SharedOptions, binPath, dir, host, configPath string, id int, pds []*PDInstance, port int, kvIsSingleReplica bool) *PDInstance

NewPDInstance return a PDInstance

func (*PDInstance) Addr

func (inst *PDInstance) Addr() string

Addr return the listen address of PD

func (*PDInstance) Component added in v1.0.7

func (inst *PDInstance) Component() string

Component return the component name.

func (*PDInstance) InitCluster added in v1.0.3

func (inst *PDInstance) InitCluster(pds []*PDInstance) *PDInstance

InitCluster set the init cluster instance.

func (*PDInstance) Join

func (inst *PDInstance) Join(pds []*PDInstance) *PDInstance

Join set endpoints field of PDInstance

func (*PDInstance) LogFile added in v1.0.7

func (inst *PDInstance) LogFile() string

LogFile return the log file.

func (*PDInstance) MetricAddr added in v1.14.0

func (inst *PDInstance) MetricAddr() (r MetricAddr)

func (*PDInstance) Name added in v1.0.5

func (inst *PDInstance) Name() string

Name return the name of pd.

func (*PDInstance) PrepareBinary added in v1.16.1

func (inst *PDInstance) PrepareBinary(binaryName string, componentName string, version utils.Version) error

func (*PDInstance) Start

func (inst *PDInstance) Start(ctx context.Context) error

Start calls set inst.cmd and Start

type PDRole added in v1.13.0

type PDRole string

PDRole is the role of PD.

const (
	// PDRoleNormal is the default role of PD
	PDRoleNormal PDRole = "pd"
	// PDRoleAPI is the role of PD API
	PDRoleAPI PDRole = "api"
	// PDRoleTSO is the role of PD TSO
	PDRoleTSO PDRole = "tso"
	// PDRoleScheduling is the role of PD scheduling
	PDRoleScheduling PDRole = "scheduling"
)

type Process added in v1.0.7

type Process interface {
	Start() error
	Wait() error
	Pid() int
	Uptime() string
	SetOutputFile(fname string) error
	Cmd() *exec.Cmd
}

Process represent process to be run by playground

type Pump added in v1.0.5

type Pump struct {
	Process
	// contains filtered or unexported fields
}

Pump represent a pump instance.

func NewPump added in v1.0.5

func NewPump(shOpt SharedOptions, binPath string, dir, host, configPath string, id int, pds []*PDInstance) *Pump

NewPump create a Pump instance.

func (*Pump) Addr added in v1.0.5

func (p *Pump) Addr() string

Addr return the address of Pump.

func (*Pump) Component added in v1.0.7

func (p *Pump) Component() string

Component return component name.

func (*Pump) LogFile added in v1.0.7

func (p *Pump) LogFile() string

LogFile return the log file.

func (*Pump) MetricAddr added in v1.14.0

func (inst *Pump) MetricAddr() (r MetricAddr)

func (*Pump) NodeID added in v1.0.5

func (p *Pump) NodeID() string

NodeID return the node id of pump.

func (*Pump) PrepareBinary added in v1.16.1

func (inst *Pump) PrepareBinary(binaryName string, componentName string, version utils.Version) error

func (*Pump) Ready added in v1.0.5

func (p *Pump) Ready(ctx context.Context) error

Ready return nil when pump is ready to serve.

func (*Pump) Start added in v1.0.5

func (p *Pump) Start(ctx context.Context) error

Start implements Instance interface.

type SharedOptions added in v1.16.3

type SharedOptions struct {
	/// Whether or not to tune the cluster in order to run faster (instead of easier to debug).
	HighPerf           bool       `yaml:"high_perf"`
	CSE                CSEOptions `yaml:"cse"` // Only available when mode == tidb-cse or tiflash-disagg
	PDMode             string     `yaml:"pd_mode"`
	Mode               string     `yaml:"mode"`
	PortOffset         int        `yaml:"port_offset"`
	EnableTiKVColumnar bool       `yaml:"enable_tikv_columnar"` // Only available when mode == tidb-cse
}

SharedOptions contains some commonly used, tunable options for most components. Unlike Config, these options are shared for all instances of all components.

type TiCDC added in v1.2.0

type TiCDC struct {
	Process
	// contains filtered or unexported fields
}

TiCDC represent a ticdc instance.

func NewTiCDC added in v1.2.0

func NewTiCDC(shOpt SharedOptions, binPath string, dir, host, configPath string, id int, port int, pds []*PDInstance) *TiCDC

NewTiCDC create a TiCDC instance.

func (*TiCDC) Component added in v1.2.0

func (c *TiCDC) Component() string

Component return component name.

func (*TiCDC) LogFile added in v1.2.0

func (c *TiCDC) LogFile() string

LogFile return the log file.

func (*TiCDC) MetricAddr added in v1.14.0

func (inst *TiCDC) MetricAddr() (r MetricAddr)

func (*TiCDC) PrepareBinary added in v1.16.1

func (inst *TiCDC) PrepareBinary(binaryName string, componentName string, version utils.Version) error

func (*TiCDC) Start added in v1.2.0

func (c *TiCDC) Start(ctx context.Context) error

Start implements Instance interface.

type TiDBInstance

type TiDBInstance struct {
	Process
	// contains filtered or unexported fields
}

TiDBInstance represent a running tidb-server

func NewTiDBInstance

func NewTiDBInstance(shOpt SharedOptions, binPath string, dir, host, configPath string, id, port int, pds []*PDInstance, tiproxyCertDir string, enableBinlog bool) *TiDBInstance

NewTiDBInstance return a TiDBInstance

func (*TiDBInstance) Addr

func (inst *TiDBInstance) Addr() string

Addr return the listen address of TiDB

func (*TiDBInstance) Component added in v1.0.7

func (inst *TiDBInstance) Component() string

Component return the component name.

func (*TiDBInstance) LogFile added in v1.0.7

func (inst *TiDBInstance) LogFile() string

LogFile return the log file name.

func (*TiDBInstance) MetricAddr added in v1.14.0

func (inst *TiDBInstance) MetricAddr() (r MetricAddr)

func (*TiDBInstance) PrepareBinary added in v1.16.1

func (inst *TiDBInstance) PrepareBinary(binaryName string, componentName string, version utils.Version) error

func (*TiDBInstance) Start

func (inst *TiDBInstance) Start(ctx context.Context) error

Start calls set inst.cmd and Start

type TiFlashInstance

type TiFlashInstance struct {
	Role TiFlashRole // Used in wait routine, so it is public

	Process
	// contains filtered or unexported fields
}

TiFlashInstance represent a running TiFlash

func NewTiFlashInstance

func NewTiFlashInstance(role TiFlashRole, shOpt SharedOptions, binPath, dir, host, configPath string, id int, pds []*PDInstance, dbs []*TiDBInstance, version string) *TiFlashInstance

NewTiFlashInstance return a TiFlashInstance

func (*TiFlashInstance) Addr added in v1.0.5

func (inst *TiFlashInstance) Addr() string

Addr return the address of tiflash

func (*TiFlashInstance) Cmd added in v1.0.4

func (inst *TiFlashInstance) Cmd() *exec.Cmd

Cmd returns the internal Cmd instance

func (*TiFlashInstance) Component added in v1.0.7

func (inst *TiFlashInstance) Component() string

Component return the component name.

func (*TiFlashInstance) LogFile added in v1.0.7

func (inst *TiFlashInstance) LogFile() string

LogFile return the log file name.

func (*TiFlashInstance) MetricAddr added in v1.14.0

func (inst *TiFlashInstance) MetricAddr() (r MetricAddr)

MetricAddr implements Instance interface.

func (*TiFlashInstance) PrepareBinary added in v1.16.1

func (inst *TiFlashInstance) PrepareBinary(binaryName string, componentName string, version utils.Version) error

func (*TiFlashInstance) Start

func (inst *TiFlashInstance) Start(ctx context.Context) error

Start calls set inst.cmd and Start

func (*TiFlashInstance) StoreAddr

func (inst *TiFlashInstance) StoreAddr() string

StoreAddr return the store address of TiFlash

type TiFlashRole added in v1.12.2

type TiFlashRole string

TiFlashRole is the role of TiFlash.

const (
	// TiFlashRoleNormal is used when TiFlash is not in disaggregated mode.
	TiFlashRoleNormal TiFlashRole = "normal"

	// TiFlashRoleDisaggWrite is used when TiFlash is in disaggregated mode and is the write node.
	TiFlashRoleDisaggWrite TiFlashRole = "write"
	// TiFlashRoleDisaggCompute is used when TiFlash is in disaggregated mode and is the compute node.
	TiFlashRoleDisaggCompute TiFlashRole = "compute"
)

type TiKVCDC added in v1.11.0

type TiKVCDC struct {
	Process
	// contains filtered or unexported fields
}

TiKVCDC represent a TiKV-CDC instance.

func NewTiKVCDC added in v1.11.0

func NewTiKVCDC(shOpt SharedOptions, binPath string, dir, host, configPath string, id int, pds []*PDInstance) *TiKVCDC

NewTiKVCDC create a TiKVCDC instance.

func (*TiKVCDC) Component added in v1.11.0

func (c *TiKVCDC) Component() string

Component return component name.

func (*TiKVCDC) LogFile added in v1.11.0

func (c *TiKVCDC) LogFile() string

LogFile return the log file.

func (*TiKVCDC) MetricAddr added in v1.14.0

func (inst *TiKVCDC) MetricAddr() (r MetricAddr)

func (*TiKVCDC) PrepareBinary added in v1.16.1

func (inst *TiKVCDC) PrepareBinary(binaryName string, componentName string, version utils.Version) error

func (*TiKVCDC) Start added in v1.11.0

func (c *TiKVCDC) Start(ctx context.Context) error

Start implements Instance interface.

type TiKVInstance

type TiKVInstance struct {
	Process
	// contains filtered or unexported fields
}

TiKVInstance represent a running tikv-server

func NewTiKVInstance

func NewTiKVInstance(shOpt SharedOptions, binPath string, dir, host, configPath string, id int, port int, pds []*PDInstance, tsos []*PDInstance) *TiKVInstance

NewTiKVInstance return a TiKVInstance

func (*TiKVInstance) Addr added in v1.0.5

func (inst *TiKVInstance) Addr() string

Addr return the address of tikv.

func (*TiKVInstance) Component added in v1.0.7

func (inst *TiKVInstance) Component() string

Component return the component name.

func (*TiKVInstance) LogFile added in v1.0.7

func (inst *TiKVInstance) LogFile() string

LogFile return the log file name.

func (*TiKVInstance) MetricAddr added in v1.14.0

func (inst *TiKVInstance) MetricAddr() (r MetricAddr)

func (*TiKVInstance) PrepareBinary added in v1.16.1

func (inst *TiKVInstance) PrepareBinary(binaryName string, componentName string, version utils.Version) error

func (*TiKVInstance) Start

func (inst *TiKVInstance) Start(ctx context.Context) error

Start calls set inst.cmd and Start

func (*TiKVInstance) StoreAddr

func (inst *TiKVInstance) StoreAddr() string

StoreAddr return the store address of TiKV

type TiKVWorkerInstance added in v1.16.3

type TiKVWorkerInstance struct {
	Process
	// contains filtered or unexported fields
}

TiKVWorkerInstance represent a running TiKVWorker instance.

func NewTiKVWorkerInstance added in v1.16.3

func NewTiKVWorkerInstance(shOpt SharedOptions, binPath string, dir, host, configPath string, id int, port int, pds []*PDInstance) *TiKVWorkerInstance

NewTiKVWorkerInstance creates a new TiKVWorker instance.

func (*TiKVWorkerInstance) Addr added in v1.16.3

func (inst *TiKVWorkerInstance) Addr() string

Addr return the address of TiKVWorker.

func (*TiKVWorkerInstance) Component added in v1.16.3

func (inst *TiKVWorkerInstance) Component() string

Component return the component name.

func (*TiKVWorkerInstance) LogFile added in v1.16.3

func (inst *TiKVWorkerInstance) LogFile() string

LogFile return the log file name.

func (*TiKVWorkerInstance) MetricAddr added in v1.16.3

func (inst *TiKVWorkerInstance) MetricAddr() (r MetricAddr)

func (*TiKVWorkerInstance) PrepareBinary added in v1.16.3

func (inst *TiKVWorkerInstance) PrepareBinary(binaryName string, componentName string, version utils.Version) error

func (*TiKVWorkerInstance) Start added in v1.16.3

func (inst *TiKVWorkerInstance) Start(ctx context.Context) error

Start calls set inst.cmd and Start

type TiProxy added in v1.13.0

type TiProxy struct {
	Process
	// contains filtered or unexported fields
}

TiProxy represent a ticdc instance.

func NewTiProxy added in v1.13.0

func NewTiProxy(shOpt SharedOptions, binPath string, dir, host, configPath string, id int, port int, pds []*PDInstance) *TiProxy

NewTiProxy create a TiProxy instance.

func (*TiProxy) Addr added in v1.13.0

func (c *TiProxy) Addr() string

Addr return addresses that can be connected by MySQL clients.

func (*TiProxy) Component added in v1.13.0

func (c *TiProxy) Component() string

Component return component name.

func (*TiProxy) LogFile added in v1.13.0

func (c *TiProxy) LogFile() string

LogFile return the log file.

func (*TiProxy) MetricAddr added in v1.14.0

func (c *TiProxy) MetricAddr() (r MetricAddr)

MetricAddr implements Instance interface.

func (*TiProxy) PrepareBinary added in v1.16.1

func (inst *TiProxy) PrepareBinary(binaryName string, componentName string, version utils.Version) error

func (*TiProxy) Start added in v1.13.0

func (c *TiProxy) Start(ctx context.Context) error

Start implements Instance interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL