spec

package
v0.0.0-...-a027a2a Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ComponentDMMaster     = spec.ComponentDMMaster
	ComponentDMWorker     = spec.ComponentDMWorker
	ComponentPrometheus   = spec.ComponentPrometheus
	ComponentGrafana      = spec.ComponentGrafana
	ComponentAlertmanager = spec.ComponentAlertmanager
)

Components names supported by TiUP

Variables

This section is empty.

Functions

func AllDMComponentNames

func AllDMComponentNames() (roles []string)

AllDMComponentNames contains the names of all dm components. should include all components in ComponentsByStartOrder

func DMComponentVersion

func DMComponentVersion(comp, version string) string

DMComponentVersion maps the dm version to the third components binding version Empty version means the latest stable one

func GetSpecManager

func GetSpecManager() *cspec.SpecManager

GetSpecManager return the spec manager of dm cluster.

Types

type AlertmanagerSpec

type AlertmanagerSpec = spec.AlertmanagerSpec

AlertmanagerSpec is the spec of Alertmanager

type Component

type Component = spec.Component

Component represents a component of the cluster.

type DMMasterComponent

type DMMasterComponent struct{ Topology *Specification }

DMMasterComponent represents TiDB component.

func (*DMMasterComponent) Instances

func (c *DMMasterComponent) Instances() []Instance

Instances implements Component interface.

func (*DMMasterComponent) Name

func (c *DMMasterComponent) Name() string

Name implements Component interface.

func (*DMMasterComponent) Role

func (c *DMMasterComponent) Role() string

Role implements Component interface.

type DMServerConfigs

type DMServerConfigs struct {
	Master map[string]interface{} `yaml:"master"`
	Worker map[string]interface{} `yaml:"worker"`
}

DMServerConfigs represents the server runtime configuration

type DMWorkerComponent

type DMWorkerComponent struct{ Topology *Specification }

DMWorkerComponent represents DM worker component.

func (*DMWorkerComponent) Instances

func (c *DMWorkerComponent) Instances() []Instance

Instances implements Component interface.

func (*DMWorkerComponent) Name

func (c *DMWorkerComponent) Name() string

Name implements Component interface.

func (*DMWorkerComponent) Role

func (c *DMWorkerComponent) Role() string

Role implements Component interface.

type GlobalOptions

type GlobalOptions = spec.GlobalOptions

GlobalOptions of spec.

type GrafanaSpec

type GrafanaSpec = spec.GrafanaSpec

GrafanaSpec is the spec of Grafana

type Instance

type Instance = spec.Instance

Instance represents an instance

type InstanceSpec

type InstanceSpec interface {
	Role() string
	SSH() (string, int)
	GetMainPort() int
	IsImported() bool
	IgnoreMonitorAgent() bool
}

InstanceSpec represent a instance specification

type MasterInstance

type MasterInstance struct {
	Name string
	spec.BaseInstance
	// contains filtered or unexported fields
}

MasterInstance represent the TiDB instance

func (*MasterInstance) InitConfig

func (i *MasterInstance) InitConfig(
	ctx context.Context,
	e ctxt.Executor,
	clusterName,
	clusterVersion,
	deployUser string,
	paths meta.DirPaths,
) error

InitConfig implement Instance interface

func (*MasterInstance) ScaleConfig

func (i *MasterInstance) ScaleConfig(
	ctx context.Context,
	e ctxt.Executor,
	topo spec.Topology,
	clusterName,
	clusterVersion,
	deployUser string,
	paths meta.DirPaths,
) error

ScaleConfig deploy temporary config on scaling

type MasterSpec

type MasterSpec struct {
	Host           string `yaml:"host"`
	SSHPort        int    `yaml:"ssh_port,omitempty" validate:"ssh_port:editable"`
	Imported       bool   `yaml:"imported,omitempty"`
	Patched        bool   `yaml:"patched,omitempty"`
	IgnoreExporter bool   `yaml:"ignore_exporter,omitempty"`
	// Use Name to get the name with a default value if it's empty.
	Name            string                 `yaml:"name,omitempty"`
	Port            int                    `yaml:"port,omitempty" default:"8261"`
	PeerPort        int                    `yaml:"peer_port,omitempty" default:"8291"`
	DeployDir       string                 `yaml:"deploy_dir,omitempty"`
	DataDir         string                 `yaml:"data_dir,omitempty"`
	LogDir          string                 `yaml:"log_dir,omitempty"`
	NumaNode        string                 `yaml:"numa_node,omitempty" validate:"numa_node:editable"`
	Config          map[string]interface{} `yaml:"config,omitempty" validate:"config:ignore"`
	ResourceControl ResourceControl        `yaml:"resource_control,omitempty" validate:"resource_control:editable"`
	Arch            string                 `yaml:"arch,omitempty"`
	OS              string                 `yaml:"os,omitempty"`
	V1SourcePath    string                 `yaml:"v1_source_path,omitempty"`
}

MasterSpec represents the Master topology specification in topology.yaml

func (*MasterSpec) GetMainPort

func (s *MasterSpec) GetMainPort() int

GetMainPort returns the main port of the instance

func (*MasterSpec) IgnoreMonitorAgent

func (s *MasterSpec) IgnoreMonitorAgent() bool

IgnoreMonitorAgent returns if the node does not have monitor agents available

func (*MasterSpec) IsImported

func (s *MasterSpec) IsImported() bool

IsImported returns if the node is imported from TiDB-Ansible

func (*MasterSpec) Role

func (s *MasterSpec) Role() string

Role returns the component role of the instance

func (*MasterSpec) SSH

func (s *MasterSpec) SSH() (string, int)

SSH returns the host and SSH port of the instance

func (*MasterSpec) Status

func (s *MasterSpec) Status(tlsCfg *tls.Config, _ ...string) string

Status queries current status of the instance

type Metadata

type Metadata struct {
	User    string `yaml:"user"`       // the user to run and manage cluster on remote
	Version string `yaml:"dm_version"` // the version of TiDB cluster

	Topology *Specification `yaml:"topology"`
}

Metadata is the specification of generic cluster metadata

func (*Metadata) GetBaseMeta

func (m *Metadata) GetBaseMeta() *cspec.BaseMeta

GetBaseMeta implements Metadata interface.

func (*Metadata) GetTopology

func (m *Metadata) GetTopology() cspec.Topology

GetTopology implements Metadata interface.

func (*Metadata) SetTopology

func (m *Metadata) SetTopology(topo cspec.Topology)

SetTopology implements Metadata interface.

func (*Metadata) SetUser

func (m *Metadata) SetUser(s string)

SetUser implement UpgradableMetadata interface.

func (*Metadata) SetVersion

func (m *Metadata) SetVersion(s string)

SetVersion implement UpgradableMetadata interface.

type MonitoredOptions

type MonitoredOptions = spec.MonitoredOptions

MonitoredOptions is the spec of Monitored

type PrometheusSpec

type PrometheusSpec = spec.PrometheusSpec

PrometheusSpec is the spec of Prometheus

type ResourceControl

type ResourceControl = meta.ResourceControl

ResourceControl is the spec of ResourceControl

type Specification

type Specification struct {
	GlobalOptions    GlobalOptions            `yaml:"global,omitempty" validate:"global:editable"`
	MonitoredOptions *MonitoredOptions        `yaml:"monitored,omitempty" validate:"monitored:editable"`
	ServerConfigs    DMServerConfigs          `yaml:"server_configs,omitempty" validate:"server_configs:ignore"`
	Masters          []*MasterSpec            `yaml:"master_servers"`
	Workers          []*WorkerSpec            `yaml:"worker_servers"`
	Monitors         []*spec.PrometheusSpec   `yaml:"monitoring_servers"`
	Grafanas         []*spec.GrafanaSpec      `yaml:"grafana_servers,omitempty"`
	Alertmanagers    []*spec.AlertmanagerSpec `yaml:"alertmanager_servers,omitempty"`
}

Specification represents the specification of topology.yaml

func (*Specification) BaseTopo

func (s *Specification) BaseTopo() *spec.BaseTopo

BaseTopo implements Topology interface.

func (*Specification) ComponentsByStartOrder

func (topo *Specification) ComponentsByStartOrder() (comps []Component)

ComponentsByStartOrder return component in the order need to start.

func (*Specification) ComponentsByStopOrder

func (topo *Specification) ComponentsByStopOrder() (comps []Component)

ComponentsByStopOrder return component in the order need to stop.

func (*Specification) ComponentsByUpdateOrder

func (topo *Specification) ComponentsByUpdateOrder() (comps []Component)

ComponentsByUpdateOrder return component in the order need to be updated.

func (*Specification) CountDir

func (s *Specification) CountDir(targetHost, dirPrefix string) int

CountDir counts for dir paths used by any instance in the cluster with the same prefix, useful to find potential path conflicts

func (*Specification) Endpoints

func (topo *Specification) Endpoints(user string) []*scripts.DMMasterScript

Endpoints returns the PD endpoints configurations

func (*Specification) FillHostArch

func (s *Specification) FillHostArch(hostArch map[string]string) error

FillHostArch fills the topology with the given host->arch

func (*Specification) GetGlobalOptions

func (topo *Specification) GetGlobalOptions() spec.GlobalOptions

GetGlobalOptions returns cluster topology

func (*Specification) GetMasterList

func (s *Specification) GetMasterList() []string

GetMasterList returns a list of Master API hosts of the current cluster

func (*Specification) GetMonitoredOptions

func (topo *Specification) GetMonitoredOptions() *spec.MonitoredOptions

GetMonitoredOptions returns MonitoredOptions

func (*Specification) IterComponent

func (topo *Specification) IterComponent(fn func(comp Component))

IterComponent iterates all components in component starting order

func (*Specification) IterHost

func (topo *Specification) IterHost(fn func(instance Instance))

IterHost iterates one instance for each host

func (*Specification) IterInstance

func (topo *Specification) IterInstance(fn func(instance Instance))

IterInstance iterates all instances in component starting order

func (*Specification) Merge

func (s *Specification) Merge(that spec.Topology) spec.Topology

Merge returns a new Topology which sum old ones

func (*Specification) MergeTopo

func (s *Specification) MergeTopo(rhs spec.Topology) spec.Topology

MergeTopo implements ScaleOutTopology interface.

func (*Specification) NewPart

func (s *Specification) NewPart() spec.Topology

NewPart implements ScaleOutTopology interface.

func (*Specification) TLSConfig

func (s *Specification) TLSConfig(dir string) (*tls.Config, error)

TLSConfig generates a tls.Config for the specification as needed

func (*Specification) Type

func (s *Specification) Type() string

Type implements Topology interface.

func (*Specification) UnmarshalYAML

func (s *Specification) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML sets default values when unmarshaling the topology file

func (*Specification) Validate

func (s *Specification) Validate() error

Validate validates the topology specification and produce error if the specification invalid (e.g: port conflicts or directory conflicts)

type WorkerInstance

type WorkerInstance struct {
	Name string
	spec.BaseInstance
	// contains filtered or unexported fields
}

WorkerInstance represent the DM worker instance

func (*WorkerInstance) InitConfig

func (i *WorkerInstance) InitConfig(
	ctx context.Context,
	e ctxt.Executor,
	clusterName,
	clusterVersion,
	deployUser string,
	paths meta.DirPaths,
) error

InitConfig implement Instance interface

func (*WorkerInstance) ScaleConfig

func (i *WorkerInstance) ScaleConfig(
	ctx context.Context,
	e ctxt.Executor,
	topo spec.Topology,
	clusterName,
	clusterVersion,
	deployUser string,
	paths meta.DirPaths,
) error

ScaleConfig deploy temporary config on scaling

type WorkerSpec

type WorkerSpec struct {
	Host           string `yaml:"host"`
	SSHPort        int    `yaml:"ssh_port,omitempty" validate:"ssh_port:editable"`
	Imported       bool   `yaml:"imported,omitempty"`
	Patched        bool   `yaml:"patched,omitempty"`
	IgnoreExporter bool   `yaml:"ignore_exporter,omitempty"`
	// Use Name to get the name with a default value if it's empty.
	Name            string                 `yaml:"name,omitempty"`
	Port            int                    `yaml:"port,omitempty" default:"8262"`
	DeployDir       string                 `yaml:"deploy_dir,omitempty"`
	DataDir         string                 `yaml:"data_dir,omitempty"`
	LogDir          string                 `yaml:"log_dir,omitempty"`
	NumaNode        string                 `yaml:"numa_node,omitempty" validate:"numa_node:editable"`
	Config          map[string]interface{} `yaml:"config,omitempty" validate:"config:ignore"`
	ResourceControl ResourceControl        `yaml:"resource_control,omitempty" validate:"resource_control:editable"`
	Arch            string                 `yaml:"arch,omitempty"`
	OS              string                 `yaml:"os,omitempty"`
}

WorkerSpec represents the Master topology specification in topology.yaml

func (*WorkerSpec) GetMainPort

func (s *WorkerSpec) GetMainPort() int

GetMainPort returns the main port of the instance

func (*WorkerSpec) IgnoreMonitorAgent

func (s *WorkerSpec) IgnoreMonitorAgent() bool

IgnoreMonitorAgent returns if the node does not have monitor agents available

func (*WorkerSpec) IsImported

func (s *WorkerSpec) IsImported() bool

IsImported returns if the node is imported from TiDB-Ansible

func (*WorkerSpec) Role

func (s *WorkerSpec) Role() string

Role returns the component role of the instance

func (*WorkerSpec) SSH

func (s *WorkerSpec) SSH() (string, int)

SSH returns the host and SSH port of the instance

func (*WorkerSpec) Status

func (s *WorkerSpec) Status(tlsCfg *tls.Config, masterList ...string) string

Status queries current status of the instance

Jump to

Keyboard shortcuts

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