Documentation
¶
Index ¶
- Constants
- Variables
- func AdvertiseHost(listen string) string
- func ComponentDisplayName(componentID RepoComponentID) string
- func GenTiProxySessionCerts(dir string) error
- func PrepareCommand(ctx context.Context, binPath string, args, envs []string, workDir string) *exec.Cmd
- func RegisterComponentDisplayName(componentID RepoComponentID, displayName string)
- func RegisterServiceDisplayName(serviceID ServiceID, displayName string)
- func ResolveSiblingBinary(baseBinPath, want string) (string, bool)
- func ResolveTiKVWorkerBinPath(binPath string) string
- func ServiceDisplayName(serviceID ServiceID) string
- type CSEOptions
- type Config
- type DMMaster
- type DMMasterPlan
- type DMMemberPlan
- type DMWorker
- type DMWorkerPlan
- type Drainer
- type DrainerPlan
- type GrafanaInstance
- type GrafanaPlan
- type MetricAddr
- type Mode
- type NGMonitoringInstance
- type NGMonitoringPlan
- type OSProcess
- type PDInstance
- type PDMemberPlan
- type PDPlan
- type Process
- type ProcessInfo
- type PrometheusInstance
- type Pump
- type PumpPlan
- type ReadyWaiter
- type RepoComponentID
- type ServiceID
- type ServicePlan
- type ServiceSharedPlan
- type SharedOptions
- type TiCDC
- type TiCDCPlan
- type TiDBInstance
- type TiDBPlan
- type TiFlashInstance
- func (inst *TiFlashInstance) Addr() string
- func (inst *TiFlashInstance) LogFile() string
- func (inst *TiFlashInstance) MetricAddr() (r MetricAddr)
- func (inst *TiFlashInstance) Prepare(ctx context.Context) error
- func (inst *TiFlashInstance) StoreAddr() string
- func (inst *TiFlashInstance) WaitReady(ctx context.Context) error
- type TiFlashPlan
- type TiKVCDCInstance
- type TiKVCDCPlan
- type TiKVInstance
- type TiKVPlan
- type TiKVWorkerInstance
- type TiKVWorkerPlan
- type TiProxyInstance
- type TiProxyPlan
Constants ¶
const ( // ServicePump is the service ID for Pump. ServicePump ServiceID = "pump" // ServiceDrainer is the service ID for Drainer. ServiceDrainer ServiceID = "drainer" // ComponentPump is the repository component ID for Pump. ComponentPump RepoComponentID = "pump" // ComponentDrainer is the repository component ID for Drainer. ComponentDrainer RepoComponentID = "drainer" )
const ( // ServiceTiCDC is the service ID for TiCDC. ServiceTiCDC ServiceID = "ticdc" // ServiceTiKVCDC is the service ID for TiKV CDC. ServiceTiKVCDC ServiceID = "tikv-cdc" // ComponentCDC is the repository component ID for TiCDC. ComponentCDC RepoComponentID = "cdc" // ComponentTiKVCDC is the repository component ID for TiKV CDC. ComponentTiKVCDC RepoComponentID = "tikv-cdc" )
const ( // ServiceDMMaster is the service ID for DM-master. ServiceDMMaster ServiceID = "dm-master" // ServiceDMWorker is the service ID for DM-worker. ServiceDMWorker ServiceID = "dm-worker" // ComponentDMMaster is the repository component ID for DM-master. ComponentDMMaster RepoComponentID = "dm-master" // ComponentDMWorker is the repository component ID for DM-worker. ComponentDMWorker RepoComponentID = "dm-worker" )
const ( // ServicePrometheus is the service ID for the Prometheus instance. ServicePrometheus ServiceID = "prometheus" // ServiceGrafana is the service ID for the Grafana instance. ServiceGrafana ServiceID = "grafana" // ServiceNGMonitoring is the service ID for NG Monitoring. ServiceNGMonitoring ServiceID = "ng-monitoring" // ComponentPrometheus is the repository component ID for Prometheus. ComponentPrometheus RepoComponentID = "prometheus" // ComponentGrafana is the repository component ID for Grafana. ComponentGrafana RepoComponentID = "grafana" // ComponentNGMonitoring is the repository component ID for NG Monitoring. ComponentNGMonitoring RepoComponentID = "ng-monitoring" )
const ( // ServicePD is the service ID for PD. ServicePD ServiceID = "pd" // ServicePDAPI is the service ID for the PD API-only service. ServicePDAPI ServiceID = "pd-api" // ServicePDTSO is the service ID for the PD TSO-only service. ServicePDTSO ServiceID = "pd-tso" // ServicePDScheduling is the service ID for the PD Scheduling-only service. ServicePDScheduling ServiceID = "pd-scheduling" // ServicePDRouter is the service ID for the PD Router-only service. ServicePDRouter ServiceID = "pd-router" // ServicePDResourceManager is the service ID for the PD Resource Manager-only service. ServicePDResourceManager ServiceID = "pd-resource-manager" // ComponentPD is the repository component ID for PD. ComponentPD RepoComponentID = "pd" )
const ( // PortNamePort is the standard key for the main listen port in // ServiceSharedPlan.Ports. PortNamePort = "port" // PortNameStatusPort is the standard key for the status/metrics port in // ServiceSharedPlan.Ports. PortNameStatusPort = "statusPort" )
const ( // ServiceTiDB is the service ID for TiDB. ServiceTiDB ServiceID = "tidb" // ServiceTiDBSystem is the service ID for the internal TiDB system service. ServiceTiDBSystem ServiceID = "tidb-system" // ComponentTiDB is the repository component ID for TiDB. ComponentTiDB RepoComponentID = "tidb" )
const ( // ServiceTiFlash is the service ID for TiFlash. ServiceTiFlash ServiceID = "tiflash" // ServiceTiFlashWrite is the service ID for the TiFlash write node service. ServiceTiFlashWrite ServiceID = "tiflash-write" // ServiceTiFlashCompute is the service ID for the TiFlash compute node service. ServiceTiFlashCompute ServiceID = "tiflash-compute" // ComponentTiFlash is the repository component ID for TiFlash. ComponentTiFlash RepoComponentID = "tiflash" )
const ( // ServiceTiKV is the service ID for TiKV. ServiceTiKV ServiceID = "tikv" // ComponentTiKV is the repository component ID for TiKV. ComponentTiKV RepoComponentID = "tikv" )
const ( // ServiceTiKVWorker is the service ID for TiKV-worker. ServiceTiKVWorker ServiceID = "tikv-worker" // ComponentTiKVWorker is the repository component ID for TiKV-worker. ComponentTiKVWorker RepoComponentID = "tikv-worker" )
const ( // ServiceTiProxy is the service ID for TiProxy. ServiceTiProxy ServiceID = "tiproxy" // ComponentTiProxy is the repository component ID for TiProxy. ComponentTiProxy RepoComponentID = "tiproxy" )
Variables ¶
var ( // ModeNormal is the default mode. ModeNormal = "tidb" // ModeCSE is for CSE testing. ModeCSE = "tidb-cse" // ModeNextGen is for NG testing. ModeNextGen = "tidb-x" // ModeDisAgg is for tiflash testing. ModeDisAgg = "tiflash-disagg" // ModeTiKVSlim is for special tikv testing. ModeTiKVSlim = "tikv-slim" )
var SysProcAttr = &syscall.SysProcAttr{ Pdeathsig: syscall.SIGKILL, Setpgid: true, }
SysProcAttr to be use for every Process we start.
Functions ¶
func AdvertiseHost ¶
AdvertiseHost returns the interface's ip addr if listen host is 0.0.0.0
func ComponentDisplayName ¶
func ComponentDisplayName(componentID RepoComponentID) string
ComponentDisplayName returns a user-facing name for a repository component ID.
If no display name is registered, it falls back to a best-effort title-cased version of the id (split by '-' or '_').
func GenTiProxySessionCerts ¶
GenTiProxySessionCerts will create a self-signed certs for TiProxy session migration. NOTE that this cert is directly used by TiDB.
func PrepareCommand ¶
func PrepareCommand(ctx context.Context, binPath string, args, envs []string, workDir string) *exec.Cmd
PrepareCommand return command for playground
func RegisterComponentDisplayName ¶
func RegisterComponentDisplayName(componentID RepoComponentID, displayName string)
RegisterComponentDisplayName registers a user-facing name for a repository component ID.
It is intended to be called from the init() function of each component implementation, so the naming rules stay close to the component itself.
func RegisterServiceDisplayName ¶
RegisterServiceDisplayName registers a user-facing name for a service.
It is intended to be called from the init() function of each service implementation, so the naming rules stay close to the component itself.
func ResolveSiblingBinary ¶
ResolveSiblingBinary searches for an executable named want near baseBinPath.
It checks the directory containing baseBinPath and up to 3 parent directories. The returned bool reports whether the binary exists.
func ResolveTiKVWorkerBinPath ¶
ResolveTiKVWorkerBinPath resolves the tikv-worker binary path when a tikv-server path is provided.
func ServiceDisplayName ¶
ServiceDisplayName returns a user-facing name for a service.
If no service-specific display name is registered, it falls back to a best-effort title-cased form of the service ID.
Types ¶
type CSEOptions ¶
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 ¶
type DMMaster struct {
ProcessInfo
Plan DMMasterPlan
}
DMMaster represent a DM master instance.
type DMMasterPlan ¶
type DMMasterPlan struct {
InitialCluster []DMMemberPlan
RequireReady bool
}
DMMasterPlan is the service-specific plan for DM-master.
type DMMemberPlan ¶
type DMMemberPlan struct {
Name string
PeerAddr string // host:peerPort
MasterAddr string // host:statusPort
}
DMMemberPlan is one member in the DM initial cluster.
type DMWorker ¶
type DMWorker struct {
ProcessInfo
Plan DMWorkerPlan
}
DMWorker represent a DM worker instance.
func (*DMWorker) MasterAddrs ¶
MasterAddrs return the master addresses.
type DMWorkerPlan ¶
type DMWorkerPlan struct {
MasterAddrs []string // host:statusPort
}
DMWorkerPlan is the service-specific plan for DM-worker.
type Drainer ¶
type Drainer struct {
ProcessInfo
Plan DrainerPlan
}
Drainer represent a drainer instance.
type DrainerPlan ¶
type DrainerPlan struct{ PDAddrs []string }
DrainerPlan is the service-specific plan for Drainer.
type GrafanaInstance ¶
type GrafanaInstance struct {
ProcessInfo
PrometheusURL string
}
GrafanaInstance represents a running Grafana server.
func (*GrafanaInstance) LogFile ¶
func (inst *GrafanaInstance) LogFile() string
LogFile returns the log file path for the instance.
type GrafanaPlan ¶
type GrafanaPlan struct {
PrometheusURL string // http://host:port
}
GrafanaPlan is the service-specific plan for Grafana.
type MetricAddr ¶
type MetricAddr struct {
Targets []string `json:"targets"`
Labels map[string]string `json:"labels"`
}
MetricAddr will be used by prometheus scrape_configs.
type NGMonitoringInstance ¶
type NGMonitoringInstance struct {
ProcessInfo
Plan NGMonitoringPlan
}
NGMonitoringInstance represents a running ng-monitoring-server.
func (*NGMonitoringInstance) LogFile ¶
func (inst *NGMonitoringInstance) LogFile() string
LogFile returns the log file path for the instance.
type NGMonitoringPlan ¶
type NGMonitoringPlan struct {
PDAddrs []string
}
NGMonitoringPlan is the service-specific plan for NG Monitoring.
type OSProcess ¶
type OSProcess interface {
Start() error
Wait() error
Pid() int
Uptime() string
SetOutputFile(fname string) error
Cmd() *exec.Cmd
}
OSProcess represents an operating system process started by playground.
type PDInstance ¶
type PDInstance struct {
ProcessInfo
ShOpt SharedOptions
Plan PDPlan
}
PDInstance represent a running pd-server
func (*PDInstance) Addr ¶
func (inst *PDInstance) Addr() string
Addr return the listen address of PD
func (*PDInstance) InitCluster ¶
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
type PDMemberPlan ¶
PDMemberPlan is one member in the pd/pd-api initial cluster.
type PDPlan ¶
type PDPlan struct {
// InitialCluster is used by pd/pd-api (choose one of InitialCluster/JoinAddrs).
InitialCluster []PDMemberPlan
// JoinAddrs is used by pd/pd-api when joining an existing cluster.
JoinAddrs []string // host:peerPort
// BackendAddrs is used by pd-* microservices as backend endpoints.
BackendAddrs []string // host:statusPort
KVIsSingleReplica bool
}
PDPlan is the service-specific plan for PD-related services.
Fields are intentionally "static": executor should be able to start instances without re-deriving endpoints from other instances.
type Process ¶
type Process interface {
Info() *ProcessInfo
// Prepare builds the process command (config + args) for later start.
//
// It does NOT start the underlying process. Playground owns the actual
// proc.Start() call so it can consistently wire logs, waiters and readiness.
Prepare(ctx context.Context) error
// LogFile return the log file name
LogFile() string
}
Process represent running component
func NewProcessFromPlan ¶
func NewProcessFromPlan(plan ServicePlan, info ProcessInfo, shOpt SharedOptions, dataDir string) (Process, error)
NewProcessFromPlan creates a proc.Process instance from a planned service entry.
It is a centralized mapping from service IDs to proc implementations, so the controller does not need to maintain a parallel "service -> proc type" switch.
NOTE: This function does not validate ports/dirs beyond what is necessary for process construction. Planner and controller are responsible for those checks.
type ProcessInfo ¶
type ProcessInfo struct {
ID int
Dir string
Host string
Port int
StatusPort int // client port for PD
// UpTimeout is the maximum wait time (in seconds) for the instance to become
// ready.
//
// It is only used by components that implement readiness checks (e.g. TiDB,
// TiProxy, TiFlash). A value <= 0 means no limit.
UpTimeout int
ConfigPath string
// UserBinPath is the binary path provided by the user (if any).
//
// It is treated as input and must not be overwritten by binary resolution.
UserBinPath string
// BinPath is the resolved executable path used to start the instance.
//
// It is set by the playground planner/preloader and may come from either a
// user-provided path or a repository-installed component.
BinPath string
Version utils.Version
Proc OSProcess
RepoComponentID RepoComponentID
Service ServiceID
}
ProcessInfo holds the shared, low-level fields for a running playground instance.
Concrete instances embed it and expose it via the Process.Info method.
func (*ProcessInfo) DisplayName ¶
func (info *ProcessInfo) DisplayName() string
DisplayName returns the user-facing display name for an instance (no index included).
func (*ProcessInfo) Info ¶
func (info *ProcessInfo) Info() *ProcessInfo
Info returns itself so embedded ProcessInfo can satisfy Process.
func (*ProcessInfo) MetricAddr ¶
func (info *ProcessInfo) MetricAddr() (r MetricAddr)
MetricAddr returns the default address to pull metrics.
Specific instances can override it by defining their own MetricAddr method.
func (*ProcessInfo) Name ¶
func (info *ProcessInfo) Name() string
Name returns the stable instance name used by the underlying component flags and topology.
type PrometheusInstance ¶
type PrometheusInstance struct {
ProcessInfo
// contains filtered or unexported fields
}
PrometheusInstance represents a running Prometheus server.
func (*PrometheusInstance) LogFile ¶
func (inst *PrometheusInstance) LogFile() string
LogFile returns the log file path for the instance.
func (*PrometheusInstance) Prepare ¶
func (inst *PrometheusInstance) Prepare(ctx context.Context) error
Prepare builds the Prometheus process command.
func (*PrometheusInstance) RenderSDFile ¶
func (inst *PrometheusInstance) RenderSDFile(sid2targets map[ServiceID]MetricAddr) error
RenderSDFile writes Prometheus file_sd targets for all instances. ref: https://prometheus.io/docs/prometheus/latest/configuration/configuration/#file_sd_config
type Pump ¶
type Pump struct {
ProcessInfo
Plan PumpPlan
}
Pump represent a pump instance.
type PumpPlan ¶
type PumpPlan struct{ PDAddrs []string }
PumpPlan is the service-specific plan for Pump.
type ReadyWaiter ¶
type ReadyWaiter interface {
// WaitReady blocks until the instance is ready, or ctx is done.
//
// The maximum waiting time should usually be controlled by the instance's
// UpTimeout field (in seconds). A value <= 0 means no limit.
WaitReady(ctx context.Context) error
}
ReadyWaiter is an optional interface implemented by instances that need an explicit "ready" check after the process has been started.
It is intentionally separated from the core Process interface so most components can remain "start-and-done", while components like TiDB / TiProxy / TiFlash can keep showing a spinner until they are actually ready to serve.
type RepoComponentID ¶
type RepoComponentID string
RepoComponentID is a TiUP repository component ID.
It is used for version resolution, downloading and locating binaries.
func (RepoComponentID) String ¶
func (id RepoComponentID) String() string
type ServiceID ¶
type ServiceID string
ServiceID is a logical service identifier in playground.
A ServiceID represents one start behavior (args/config/ports/ready strategy), and is what playground orchestration should use for planning, dependency and "critical" semantics.
ServiceID is mode-independent. Mode only affects how a ServiceID maps to a RepoComponentID and its start implementation.
type ServicePlan ¶
type ServicePlan struct {
Name string
ServiceID string
StartAfterServices []string
ComponentID string
ResolvedVersion string
BinPath string
// Service-specific inputs (strong schema).
PD *PDPlan `json:",omitempty"`
TiKV *TiKVPlan `json:",omitempty"`
TiDB *TiDBPlan `json:",omitempty"`
TiKVWorker *TiKVWorkerPlan `json:",omitempty"`
TiFlash *TiFlashPlan `json:",omitempty"`
TiProxy *TiProxyPlan `json:",omitempty"`
Grafana *GrafanaPlan `json:",omitempty"`
NGMonitoring *NGMonitoringPlan `json:",omitempty"`
TiCDC *TiCDCPlan `json:",omitempty"`
TiKVCDC *TiKVCDCPlan `json:",omitempty"`
DMMaster *DMMasterPlan `json:",omitempty"`
DMWorker *DMWorkerPlan `json:",omitempty"`
Pump *PumpPlan `json:",omitempty"`
Drainer *DrainerPlan `json:",omitempty"`
// Debug fields (not part of execution semantics).
DebugConstraint string
}
ServicePlan is the per-instance start plan produced by the playground planner.
It intentionally omits low-level details like argv/workdir/env/fileops. Executor is responsible for turning the plan into concrete process commands.
type ServiceSharedPlan ¶
type ServiceSharedPlan struct {
//
// It is a low-level, per-instance detail: planner fills it based on service
// catalog definitions and executor/proc implementations may read it when a
// service needs more than the standard Port/StatusPort pair (e.g. TiFlash).
Ports map[string]int `json:",omitempty"`
}
ServiceSharedPlan contains common, low-level per-instance inputs.
type SharedOptions ¶
type SharedOptions struct {
/// Whether or not to tune the cluster in order to run faster (instead of easier to debug).
}
SharedOptions contains some commonly used, tunable options for most components. Unlike Config, these options are shared for all instances of all components.
type TiCDCPlan ¶
type TiCDCPlan struct{ PDAddrs []string }
TiCDCPlan is the service-specific plan for TiCDC.
type TiDBInstance ¶
type TiDBInstance struct {
ProcessInfo
ShOpt SharedOptions
Plan TiDBPlan
TiProxyCertDir string
}
TiDBInstance represent a running tidb-server
func (*TiDBInstance) Addr ¶
func (inst *TiDBInstance) Addr() string
Addr return the listen address of TiDB
func (*TiDBInstance) LogFile ¶
func (inst *TiDBInstance) LogFile() string
LogFile return the log file name.
type TiFlashInstance ¶
type TiFlashInstance struct {
ProcessInfo
ShOpt SharedOptions
Plan TiFlashPlan
}
TiFlashInstance represent a running TiFlash
func (*TiFlashInstance) Addr ¶
func (inst *TiFlashInstance) Addr() string
Addr return the address of tiflash
func (*TiFlashInstance) LogFile ¶
func (inst *TiFlashInstance) LogFile() string
LogFile return the log file name.
func (*TiFlashInstance) MetricAddr ¶
func (inst *TiFlashInstance) MetricAddr() (r MetricAddr)
MetricAddr returns the address(es) to pull metrics.
func (*TiFlashInstance) Prepare ¶
func (inst *TiFlashInstance) Prepare(ctx context.Context) error
Prepare builds the TiFlash process command.
func (*TiFlashInstance) StoreAddr ¶
func (inst *TiFlashInstance) StoreAddr() string
StoreAddr return the store address of TiFlash
type TiFlashPlan ¶
type TiFlashPlan struct {
PDAddrs []string
// ProcessInfo.Port remains the TiFlash HTTP port.
ServicePort int
TCPPort int
ProxyPort int
ProxyStatusPort int
}
TiFlashPlan is the service-specific plan for TiFlash.
type TiKVCDCInstance ¶
type TiKVCDCInstance struct {
ProcessInfo
Plan TiKVCDCPlan
}
TiKVCDCInstance represent a TiKV-CDC instance.
func (*TiKVCDCInstance) LogFile ¶
func (c *TiKVCDCInstance) LogFile() string
LogFile return the log file.
type TiKVCDCPlan ¶
type TiKVCDCPlan struct{ PDAddrs []string }
TiKVCDCPlan is the service-specific plan for TiKV-CDC.
type TiKVInstance ¶
type TiKVInstance struct {
ProcessInfo
ShOpt SharedOptions
Plan TiKVPlan
}
TiKVInstance represent a running tikv-server
func (*TiKVInstance) Addr ¶
func (inst *TiKVInstance) Addr() string
Addr return the address of tikv.
func (*TiKVInstance) LogFile ¶
func (inst *TiKVInstance) LogFile() string
LogFile return the log file name.
func (*TiKVInstance) Prepare ¶
func (inst *TiKVInstance) Prepare(ctx context.Context) error
Prepare builds the TiKV process command.
func (*TiKVInstance) StoreAddr ¶
func (inst *TiKVInstance) StoreAddr() string
StoreAddr return the store address of TiKV
func (*TiKVInstance) WaitReady ¶
func (inst *TiKVInstance) WaitReady(ctx context.Context) error
WaitReady implements ReadyWaiter.
In PD microservices mode, TiKV depends on a healthy TSO service. Historically playground performed this check in Prepare(), but Prepare() should only build the process command. Keep the behavior as a cancelable readiness step.
type TiKVPlan ¶
type TiKVPlan struct {
PDAddrs []string // host:statusPort
TSOAddrs []string // host:statusPort (ms mode)
}
TiKVPlan is the service-specific plan for TiKV.
type TiKVWorkerInstance ¶
type TiKVWorkerInstance struct {
ProcessInfo
ShOpt SharedOptions
Plan TiKVWorkerPlan
}
TiKVWorkerInstance represent a running TiKVWorker instance.
func (*TiKVWorkerInstance) Addr ¶
func (inst *TiKVWorkerInstance) Addr() string
Addr return the address of TiKVWorker.
func (*TiKVWorkerInstance) LogFile ¶
func (inst *TiKVWorkerInstance) LogFile() string
LogFile return the log file name.
type TiKVWorkerPlan ¶
type TiKVWorkerPlan struct {
PDAddrs []string
}
TiKVWorkerPlan is the service-specific plan for TiKV worker.
type TiProxyInstance ¶
type TiProxyInstance struct {
ProcessInfo
Plan TiProxyPlan
}
TiProxyInstance represent a ticdc instance.
func (*TiProxyInstance) Addr ¶
func (c *TiProxyInstance) Addr() string
Addr return addresses that can be connected by MySQL clients.
func (*TiProxyInstance) LogFile ¶
func (c *TiProxyInstance) LogFile() string
LogFile return the log file.
func (*TiProxyInstance) MetricAddr ¶
func (c *TiProxyInstance) MetricAddr() (r MetricAddr)
MetricAddr implements Process interface.
type TiProxyPlan ¶
type TiProxyPlan struct {
PDAddrs []string
}
TiProxyPlan is the service-specific plan for TiProxy.