instance

package
v1.15.2 Latest Latest
Warning

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

Go to latest
Published: May 28, 2024 License: Apache-2.0 Imports: 25 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 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(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) Start added in v1.0.5

func (d *Drainer) Start(ctx context.Context, version utils.Version) 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, version utils.Version) 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
}

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 {
	Role PDRole

	Process
	// contains filtered or unexported fields
}

PDInstance represent a running pd-server

func NewPDInstance

func NewPDInstance(role PDRole, binPath, dir, host, configPath string, id int, pds []*PDInstance, port int, isCSEMode 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) Start

func (inst *PDInstance) Start(ctx context.Context, version utils.Version) 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(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) 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, version utils.Version) error

Start implements Instance interface.

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(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) Start added in v1.2.0

func (c *TiCDC) Start(ctx context.Context, version utils.Version) 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(binPath string, dir, host, configPath string, id, port int, pds []*PDInstance, tiproxyCertDir string, enableBinlog bool, isCSEMode 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) Start

func (inst *TiDBInstance) Start(ctx context.Context, version utils.Version) error

Start calls set inst.cmd and Start

type TiFlashInstance

type TiFlashInstance struct {
	Role TiFlashRole

	TCPPort         int
	ServicePort     int
	ProxyPort       int
	ProxyStatusPort int

	Process
	// contains filtered or unexported fields
}

TiFlashInstance represent a running TiFlash

func NewTiFlashInstance

func NewTiFlashInstance(role TiFlashRole, cseOptions CSEOptions, 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)

func (*TiFlashInstance) Start

func (inst *TiFlashInstance) Start(ctx context.Context, version utils.Version) error

Start calls set inst.cmd and Start

func (*TiFlashInstance) StatusAddrs added in v1.0.4

func (inst *TiFlashInstance) StatusAddrs() (addrs []string)

StatusAddrs implements Instance interface.

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(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) Start added in v1.11.0

func (c *TiKVCDC) Start(ctx context.Context, version utils.Version) 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(binPath string, dir, host, configPath string, id int, port int, pds []*PDInstance, tsos []*PDInstance, isCSEMode bool, cseOptions CSEOptions, isPDMSMode bool) *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) Start

func (inst *TiKVInstance) Start(ctx context.Context, version utils.Version) error

Start calls set inst.cmd and Start

func (*TiKVInstance) StoreAddr

func (inst *TiKVInstance) StoreAddr() string

StoreAddr return the store address of TiKV

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(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) Start added in v1.13.0

func (c *TiProxy) Start(ctx context.Context, version utils.Version) error

Start implements Instance interface.

Jump to

Keyboard shortcuts

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