spec

package
v1.9.3 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2022 License: Apache-2.0 Imports: 15 Imported by: 2

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 added in v1.1.0

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 added in v1.3.0

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 added in v1.1.0

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"`
	Grafana map[string]string      `yaml:"grafana"`
}

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 added in v1.1.0

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 added in v1.1.0

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

MasterInstance represent the TiDB instance

func (*MasterInstance) InitConfig added in v1.1.0

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 added in v1.1.0

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 added in v1.6.0

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(_ context.Context, 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 added in v1.4.0

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 added in v1.3.0

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 added in v1.3.0

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

BaseTopo implements Topology interface.

func (*Specification) ComponentsByStartOrder added in v1.3.0

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

ComponentsByStartOrder return component in the order need to start.

func (*Specification) ComponentsByStopOrder added in v1.3.0

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

ComponentsByStopOrder return component in the order need to stop.

func (*Specification) ComponentsByUpdateOrder added in v1.3.0

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

ComponentsByUpdateOrder return component in the order need to be updated.

func (*Specification) CountDir added in v1.3.0

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 added in v1.3.0

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

Endpoints returns the PD endpoints configurations

func (*Specification) FillHostArch added in v1.6.0

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

FillHostArch fills the topology with the given host->arch

func (*Specification) GetGlobalOptions added in v1.3.0

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

GetGlobalOptions returns cluster topology

func (*Specification) GetGrafanaConfig added in v1.9.0

func (s *Specification) GetGrafanaConfig() map[string]string

GetGrafanaConfig returns global grafana configurations

func (*Specification) GetMasterList added in v1.3.0

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

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

func (*Specification) GetMonitoredOptions added in v1.3.0

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

GetMonitoredOptions returns MonitoredOptions

func (*Specification) IterComponent added in v1.3.0

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

IterComponent iterates all components in component starting order

func (*Specification) IterHost added in v1.3.0

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

IterHost iterates one instance for each host

func (*Specification) IterInstance added in v1.3.0

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

IterInstance iterates all instances in component starting order

func (*Specification) Merge added in v1.3.0

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

Merge returns a new Topology which sum old ones

func (*Specification) MergeTopo added in v1.3.0

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

MergeTopo implements ScaleOutTopology interface.

func (*Specification) NewPart added in v1.3.0

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

NewPart implements ScaleOutTopology interface.

func (*Specification) TLSConfig added in v1.3.0

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

TLSConfig generates a tls.Config for the specification as needed

func (*Specification) Type added in v1.3.0

func (s *Specification) Type() string

Type implements Topology interface.

func (*Specification) UnmarshalYAML added in v1.3.0

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

UnmarshalYAML sets default values when unmarshaling the topology file

func (*Specification) Validate added in v1.3.0

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 added in v1.1.0

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

WorkerInstance represent the DM worker instance

func (*WorkerInstance) InitConfig added in v1.1.0

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 added in v1.1.0

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 added in v1.6.0

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(_ context.Context, 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