Documentation ¶
Overview ¶
Copyright © 2020 Marvin
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2020 Marvin ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2020 Marvin ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2020 Marvin ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2020 Marvin ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2020 Marvin ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2020 Marvin ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2020 Marvin ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- func CheckCommandArgsAndMayPrintHelp(cmd *cobra.Command, args []string, minArgs int) (shouldContinue bool, err error)
- func CurrentUser() string
- func ExpandRelativeDir(topo *Topology)
- func FillHostArchOrOS(s any, hostArchOrOS map[string]string, fullType FullHostType) error
- func FillTopologyDataDir(globalDeployDir, globalDataDir, instDataDir string) string
- func FillTopologyDeployDir(globalDeployDir, instDeployDir, compRole string, compPort int) string
- func FillTopologyLogDir(globalDeployDir, globalLogDir, instLogDir string) string
- func FmtVer(ver string) (string, error)
- func PortStarted(ctx context.Context, e executor.Executor, os string, port int, timeout uint64) error
- func PortStopped(ctx context.Context, e executor.Executor, os string, port int, timeout uint64) error
- func ReadYamlFile(file string) ([]byte, error)
- func UserHome() string
- func ValidateClusterNameOrError(n string) error
- type BaseInstance
- func (b *BaseInstance) Arch() string
- func (b *BaseInstance) ComponentName() string
- func (b *BaseInstance) ComponentRole() string
- func (b *BaseInstance) GetInstanceConfig() map[string]any
- func (b *BaseInstance) InitSystemdConfig(ctx context.Context, e executor.Executor, opt *GlobalOptions, ...) error
- func (b *BaseInstance) InstanceDataDir() string
- func (b *BaseInstance) InstanceDeployDir() string
- func (b *BaseInstance) InstanceHost() string
- func (b *BaseInstance) InstanceListenHost() string
- func (b *BaseInstance) InstanceLogDir() string
- func (b *BaseInstance) InstanceManageHost() string
- func (b *BaseInstance) InstanceName() string
- func (b *BaseInstance) InstanceNumaNode() string
- func (b *BaseInstance) InstancePeerPort() int
- func (b *BaseInstance) InstancePort() int
- func (b *BaseInstance) InstanceSshPort() int
- func (b *BaseInstance) IsPatched() bool
- func (b *BaseInstance) MergeServerConfig(ctx context.Context, e executor.Executor, ...) error
- func (b *BaseInstance) OS() string
- func (b *BaseInstance) ServiceName() string
- func (b *BaseInstance) ServiceReady(ctx context.Context, e executor.Executor, timeout uint64) error
- func (b *BaseInstance) SetPatched(patch bool)
- func (b *BaseInstance) Status(ctx context.Context, tlsCfg *tls.Config, addrs ...string) (string, error)
- func (b *BaseInstance) UsedDir() []string
- func (b *BaseInstance) UsedPort() []int
- type Component
- type DBMSMasterComponent
- type DBMSWorkerComponent
- type FullHostType
- type GlobalOptions
- type IMetadata
- type Instance
- type InstanceTopology
- type MasterInstance
- type MasterOptions
- type Metadata
- func (m *Metadata) GenMetadata() *Metadata
- func (m *Metadata) GetTopology() *Topology
- func (m *Metadata) GetUser() string
- func (m *Metadata) GetVersion() string
- func (m *Metadata) ScaleOutTopology(topo *Topology)
- func (m *Metadata) SetTopology(topo *Topology)
- func (m *Metadata) SetUser(user string)
- func (m *Metadata) SetVersion(version string)
- type ServerConfig
- type SystemdMode
- type Topology
- func (t *Topology) ComponentsByStartOrder() (comps []Component)
- func (t *Topology) ComponentsByStopOrder() (comps []Component)
- func (t *Topology) ComponentsByUpdateOrder() (comps []Component)
- func (t *Topology) CountDir(targetHost, dirPrefix string) int
- func (t *Topology) FillHostArchOrOS(hostArch map[string]string, fullType FullHostType) error
- func (t *Topology) IterComponent(fn func(c Component))
- func (t *Topology) IterInstance(fn func(inst Instance), concurrency ...int)
- func (t *Topology) String() string
- type WorkerInstance
- type WorkerOptions
Constants ¶
const ( ComponentDBMSMaster = "dbms-master" ComponentDBMSWorker = "dbms-worker" )
const ( // DefaultDeployUser is the cluster deploy default user DefaultDeployUser = "dbms" // metadata // MetaFileName is the file name of the cluster topology file, eg. {clusterName}/ MetaFileName = "meta.yaml" // CacheDirName is the directory to save cluster cache file .eg. {clusterName}/{CacheDirName} CacheDirName = "cache" // PatchDirName is the directory to store patch file, eg. {clusterName}/{PatchDirName}/dbms-hotfix.tar.gz PatchDirName = "patch" // SshDirName is the directory to store cluster ssh file, eg. {clusterName}/{SshDirName} SshDirName = "ssh" // AuditDirName is the directory to store cluster operation audit log, eg. {clusterName}/{AuditDirName} AuditDirName = "audit" // LockDirName is the directory to store cluster operation lock LockDirName = "lock" ScaleOutLockName = "scale-out.yaml" // InstantClientDir is the directory to store the oracle instance client InstantClientDir = "instantclient" // cluster // BinDirName is the directory to save bin files BinDirName = "bin" // BackupDirName is the directory to save backup files BackupDirName = "backup" // ScriptDirName is the directory to save script files ScriptDirName = "script" // ConfDirName is the directory to save script files ConfDirName = "conf" // DataDirName is the directory to save script files DataDirName = "data" // LogDirName is the directory to save script files LogDirName = "log" )
Variables ¶
This section is empty.
Functions ¶
func CheckCommandArgsAndMayPrintHelp ¶
func CheckCommandArgsAndMayPrintHelp(cmd *cobra.Command, args []string, minArgs int) (shouldContinue bool, err error)
CheckCommandArgsAndMayPrintHelp checks whether user passes enough number of arguments. If insufficient number of arguments are passed, an error with proper suggestion will be raised. When no argument is passed, command help will be printed and no error will be raised.
func ExpandRelativeDir ¶
func ExpandRelativeDir(topo *Topology)
ExpandRelativeDir fill DeployDir, DataDir and LogDir to absolute path
func FillHostArchOrOS ¶
func FillHostArchOrOS(s any, hostArchOrOS map[string]string, fullType FullHostType) error
FillHostArchOrOS fills the topology with the given host->arch
func FillTopologyDataDir ¶
FillTopologyDataDir fill topology data dir
func FillTopologyDeployDir ¶
FillTopologyDeployDir fill topology deploy dir
func FillTopologyLogDir ¶
FillTopologyLogDir fill topology log dir
func FmtVer ¶
FmtVer converts a version string to SemVer format, if the string is not a valid SemVer and fails to parse and convert it, an error is raised.
func PortStarted ¶
func PortStarted(ctx context.Context, e executor.Executor, os string, port int, timeout uint64) error
PortStarted wait until a port is being listened
func PortStopped ¶
func PortStopped(ctx context.Context, e executor.Executor, os string, port int, timeout uint64) error
PortStopped wait until a port is being released
func ReadYamlFile ¶
ReadYamlFile read yaml content from file`
func ValidateClusterNameOrError ¶
ValidateClusterNameOrError validates a cluster name and returns error if the name is invalid.
Types ¶
type BaseInstance ¶
type BaseInstance struct { InstanceTopology Host string ManageHost string ListenHost string Port int SSHPort int PeerPort int NumaNode string Patched bool DeployDir string DataDir string LogDir string OSVersion string OSArch string StatusFn func(ctx context.Context, tlsCfg *tls.Config, pdHosts ...string) (string, error) Config map[string]any Component Component }
BaseInstance implements some method of Instance interface
func (*BaseInstance) ComponentName ¶
func (b *BaseInstance) ComponentName() string
ComponentName implement Instance interface
func (*BaseInstance) ComponentRole ¶
func (b *BaseInstance) ComponentRole() string
ComponentRole implement Instance interface
func (*BaseInstance) GetInstanceConfig ¶
func (b *BaseInstance) GetInstanceConfig() map[string]any
GetInstanceConfig implement Instance interface
func (*BaseInstance) InitSystemdConfig ¶
func (b *BaseInstance) InitSystemdConfig(ctx context.Context, e executor.Executor, opt *GlobalOptions, user, cacheDir string) error
InitSystemdConfig init the service configuration.
func (*BaseInstance) InstanceDataDir ¶
func (b *BaseInstance) InstanceDataDir() string
InstanceDataDir implement Instance interface
func (*BaseInstance) InstanceDeployDir ¶
func (b *BaseInstance) InstanceDeployDir() string
InstanceDeployDir implement Instance interface
func (*BaseInstance) InstanceHost ¶
func (b *BaseInstance) InstanceHost() string
InstanceHost implement Instance interface
func (*BaseInstance) InstanceListenHost ¶
func (b *BaseInstance) InstanceListenHost() string
InstanceListenHost implement Instance interface
func (*BaseInstance) InstanceLogDir ¶
func (b *BaseInstance) InstanceLogDir() string
InstanceLogDir implement Instance interface
func (*BaseInstance) InstanceManageHost ¶
func (b *BaseInstance) InstanceManageHost() string
InstanceManageHost implement Instance interface
func (*BaseInstance) InstanceName ¶
func (b *BaseInstance) InstanceName() string
InstanceName implement Instance interface
func (*BaseInstance) InstanceNumaNode ¶
func (b *BaseInstance) InstanceNumaNode() string
InstanceNumaNode implement Instance interface
func (*BaseInstance) InstancePeerPort ¶
func (b *BaseInstance) InstancePeerPort() int
InstancePeerPort implement Instance interface
func (*BaseInstance) InstancePort ¶
func (b *BaseInstance) InstancePort() int
InstancePort implement Instance interface
func (*BaseInstance) InstanceSshPort ¶
func (b *BaseInstance) InstanceSshPort() int
InstanceSshPort implement Instance interface
func (*BaseInstance) IsPatched ¶
func (b *BaseInstance) IsPatched() bool
IsPatched implement Instance interface
func (*BaseInstance) MergeServerConfig ¶
func (b *BaseInstance) MergeServerConfig(ctx context.Context, e executor.Executor, globalCfg, instanceCfg map[string]any, cacheDir string) error
MergeServerConfig merges the server configuration and overwrite the global configuration
func (*BaseInstance) ServiceName ¶
func (b *BaseInstance) ServiceName() string
ServiceName implement Instance interface
func (*BaseInstance) ServiceReady ¶
ServiceReady implement Instance interface
func (*BaseInstance) SetPatched ¶
func (b *BaseInstance) SetPatched(patch bool)
SetPatched implement Instance interface
func (*BaseInstance) Status ¶
func (b *BaseInstance) Status(ctx context.Context, tlsCfg *tls.Config, addrs ...string) (string, error)
Status implement Instance interface
func (*BaseInstance) UsedDir ¶
func (b *BaseInstance) UsedDir() []string
UsedDir implement Instance interface
func (*BaseInstance) UsedPort ¶
func (b *BaseInstance) UsedPort() []int
UsedPort implement Instance interface
type DBMSMasterComponent ¶
type DBMSMasterComponent struct {
Topology *Topology
}
func (*DBMSMasterComponent) ComponentName ¶
func (m *DBMSMasterComponent) ComponentName() string
func (*DBMSMasterComponent) ComponentRole ¶
func (m *DBMSMasterComponent) ComponentRole() string
func (*DBMSMasterComponent) Instances ¶
func (m *DBMSMasterComponent) Instances() []Instance
type DBMSWorkerComponent ¶
type DBMSWorkerComponent struct {
Topology *Topology
}
func (*DBMSWorkerComponent) ComponentName ¶
func (m *DBMSWorkerComponent) ComponentName() string
func (*DBMSWorkerComponent) ComponentRole ¶
func (m *DBMSWorkerComponent) ComponentRole() string
func (*DBMSWorkerComponent) Instances ¶
func (m *DBMSWorkerComponent) Instances() []Instance
type FullHostType ¶
type FullHostType string
FullHostType is the type of fullhost operations
const ( // FullArchType cpu-arch type FullArchType FullHostType = "Arch" // FullOSType kernel-name FullOSType FullHostType = "OS" )
type GlobalOptions ¶
type GlobalOptions struct { User string `yaml:"user,omitempty" default:"dbms"` Group string `yaml:"group,omitempty"` SSHPort int `yaml:"ssh_port,omitempty" default:"22" validate:"ssh_port:editable"` SSHType string `yaml:"ssh_type,omitempty" default:"builtin"` ListenHost string `yaml:"listen_host,omitempty" validate:"listen_host:editable"` DeployDir string `yaml:"deploy_dir,omitempty" default:"deploy"` DataDir string `yaml:"data_dir,omitempty" default:"data"` LogDir string `yaml:"log_dir,omitempty"` OS string `yaml:"os,omitempty" default:"linux"` Arch string `yaml:"arch,omitempty"` SystemdMode SystemdMode `yaml:"systemd_mode,omitempty" default:"system"` }
type Instance ¶
type Instance interface { InstanceName() string InstanceManageHost() string InstanceHost() string InstancePort() int InstancePeerPort() int InstanceSshPort() int InstanceDeployDir() string InstanceDataDir() string InstanceLogDir() string InstanceListenHost() string InstanceNumaNode() string OS() string Arch() string GetInstanceConfig() map[string]any UsedPort() []int UsedDir() []string ComponentName() string ComponentRole() string ServiceName() string ServiceReady(ctx context.Context, e executor.Executor, timeout uint64) error InstanceInitConfig(ctx context.Context, e executor.Executor, deployUser string, cacheDir string) error InstanceScaleConfig(ctx context.Context, e executor.Executor, topo *Topology, deployUser, cacheDir string) error Status(ctx context.Context, tlsCfg *tls.Config, addrs ...string) (string, error) IsPatched() bool SetPatched(patch bool) }
Instance represents the instance.
type InstanceTopology ¶
InstanceTopology represents a instance topology, used to reflect get component instance topology and update instance topology
type MasterInstance ¶
type MasterInstance struct { BaseInstance // contains filtered or unexported fields }
MasterInstance represent the dbms-master instance
func (*MasterInstance) InstanceInitConfig ¶
func (m *MasterInstance) InstanceInitConfig(ctx context.Context, e executor.Executor, deployUser string, cacheDir string) error
InstanceInitConfig implements Instance interface
func (*MasterInstance) InstanceScaleConfig ¶
func (m *MasterInstance) InstanceScaleConfig(ctx context.Context, e executor.Executor, topo *Topology, deployUser, cacheDir string) error
InstanceScaleConfig implements Instance interface
type MasterOptions ¶
type MasterOptions struct { Host string `yaml:"host"` ManageHost string `yaml:"manage_host,omitempty" validate:"manage_host:editable"` SSHPort int `yaml:"ssh_port,omitempty" validate:"ssh_port:editable"` Patched bool `yaml:"patched,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"` InstanceNumaNode string `yaml:"numa_node,omitempty" validate:"numa_node:editable"` Config map[string]any `yaml:"config,omitempty" validate:"config:ignore"` Arch string `yaml:"arch,omitempty"` OS string `yaml:"os,omitempty"` }
MasterOptions represents the Master topology specification in topology.yaml
func (*MasterOptions) InstanceName ¶
func (s *MasterOptions) InstanceName() string
func (*MasterOptions) InstanceRole ¶
func (s *MasterOptions) InstanceRole() string
type Metadata ¶
type Metadata struct { User string `yaml:"user"` Version string `yaml:"version"` Topology *Topology `yaml:"topology"` }
func ParseMetadataYaml ¶
ParseMetadataYaml read yaml content from `file` and unmarshal it to `out`
func (*Metadata) GenMetadata ¶
func (*Metadata) GetTopology ¶
func (*Metadata) GetVersion ¶
func (*Metadata) ScaleOutTopology ¶
func (*Metadata) SetTopology ¶
func (*Metadata) SetVersion ¶
type ServerConfig ¶
type SystemdMode ¶
type SystemdMode string
SystemdMode is the mode used by systemctl
const ( // SystemMode system mode SystemMode SystemdMode = "system" // UserMode user mode UserMode SystemdMode = "user" )
type Topology ¶
type Topology struct { GlobalOptions *GlobalOptions `yaml:"global,omitempty" validate:"global:editable"` ServerConfigs *ServerConfig `yaml:"server_configs,omitempty" validate:"server_configs:ignore"` MasterServers []*MasterOptions `yaml:"master_servers"` WorkerServers []*WorkerOptions `yaml:"worker_servers"` }
func ParseTopologyYaml ¶
ParseTopologyYaml read yaml content from `file` and unmarshal it to `out` ignoreGlobal ignore global variables in file, only ignoreGlobal with a index of 0 is effective
func (*Topology) ComponentsByStartOrder ¶
ComponentsByStartOrder return component in the order need to start.
func (*Topology) ComponentsByStopOrder ¶
ComponentsByStopOrder return component in the order need to stop.
func (*Topology) ComponentsByUpdateOrder ¶
ComponentsByUpdateOrder return component in the order need to be updated.
func (*Topology) CountDir ¶
CountDir counts for dir paths used by any instance in the cluster with the same prefix, useful to find potential path conflicts
func (*Topology) FillHostArchOrOS ¶
func (t *Topology) FillHostArchOrOS(hostArch map[string]string, fullType FullHostType) error
FillHostArchOrOS fills the topology with the given host->arch
func (*Topology) IterComponent ¶
IterComponent iterates all components in component starting order
func (*Topology) IterInstance ¶
IterInstance iterates all instances in component starting order
type WorkerInstance ¶
type WorkerInstance struct { BaseInstance // contains filtered or unexported fields }
WorkerInstance represent the dbms-worker instance
func (*WorkerInstance) InstanceInitConfig ¶
func (w *WorkerInstance) InstanceInitConfig(ctx context.Context, e executor.Executor, deployUser string, cacheDir string) error
InstanceInitConfig implements Instance interface
func (*WorkerInstance) InstanceScaleConfig ¶
func (w *WorkerInstance) InstanceScaleConfig(ctx context.Context, e executor.Executor, topo *Topology, deployUser, cacheDir string) error
InstanceScaleConfig implements Instance interface
type WorkerOptions ¶
type WorkerOptions struct { Host string `yaml:"host"` ManageHost string `yaml:"manage_host,omitempty" validate:"manage_host:editable"` SSHPort int `yaml:"ssh_port,omitempty" validate:"ssh_port:editable"` Patched bool `yaml:"patched,omitempty"` Port int `yaml:"port,omitempty" default:"8262"` DeployDir string `yaml:"deploy_dir,omitempty"` LogDir string `yaml:"log_dir,omitempty"` InstanceNumaNode string `yaml:"numa_node,omitempty" validate:"numa_node:editable"` Config map[string]any `yaml:"config,omitempty" validate:"config:ignore"` Arch string `yaml:"arch,omitempty"` OS string `yaml:"os,omitempty"` }
WorkerOptions represents the Master topology specification in topology.yaml
func (*WorkerOptions) InstanceName ¶
func (w *WorkerOptions) InstanceName() string
func (*WorkerOptions) InstanceRole ¶
func (w *WorkerOptions) InstanceRole() string