gms

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigKeyEnableLocalMode                     = "ENABLE_LOCAL_MODE"
	ConfigKeyEnableBackgroundStatisticCollection = "ENABLE_BACKGROUND_STATISTIC_COLLECTION"
	ConfigKeyMemoryLimitPerQuery                 = "PER_QUERY_MEMORY_LIMIT"
	ConfigKeyPhysicalConnSocketTimeout           = "SOCKET_TIMEOUT"
	ConfigKeyInformationSchemaAggregateStats     = "INFO_SCHEMA_QUERY_WITH_STAT"
	ConfigKeyPhysicalConnIdleTimeout             = "CONN_POOL_IDLE_TIMEOUT"
	ConfigKeyPhysicalConnBlockingTimeout         = "CONN_POOL_BLOCK_TIMEOUT"
	ConfigKeyPhysicalConnMinPoolSize             = "CONN_POOL_MIN_POOL_SIZE"
	ConfigKeyPhysicalConnMaxPoolSize             = "CONN_POOL_MAX_POOL_SIZE"
	ConfigKeyTimeZone                            = "LOGICAL_DB_TIME_ZONE"
	ConfigKeyEnableComplexDmlCrossDB             = "ENABLE_COMPLEX_DML_CROSS_DB"
	ConfigKeyMaxAllowedPacketSize                = "MAX_ALLOWED_PACKET"
	ConfigKeyForbidDeleteWholeTable              = "FORBID_EXECUTE_DML_ALL"
	ConfigKeyLogicalConnIdleTimeout              = "LOGIC_IDLE_TIMEOUT"
	ConfigKeyTransactionLogsPurgeStartTime       = "PURGE_TRANS_START_TIME"
	ConfigKeySlowSqlRtThreshold                  = "SLOW_SQL_TIME"
	ConfigKeyMergeUnionSize                      = "MERGE_UNIONS_SIZE"
	ConfigKeyEnableBinlogRowsQueryLogEvents      = "ENABLE_SQL_FLASHBACK_EXACT_MATCH"
	ConfigKeyParallelism                         = "PARALLELISM"
	ConfigKeyEnableTableRecycleBin               = "ENABLE_RECYCLEBIN"
)
View Source
const MetaDBName = "polardbx_meta_db"

Variables

This section is empty.

Functions

func ConvertIntOrStringMapToStringMap

func ConvertIntOrStringMapToStringMap(config map[string]intstr.IntOrString) map[string]string

func GenerateDynamicConfigMap

func GenerateDynamicConfigMap(config map[string]string) map[string]string

GenerateDynamicConfigMap Deprecated.

Types

type CdcNodeInfo

type CdcNodeInfo struct {
	ContainerId string `json:"containerId"`
	Host        string `json:"host"`
	DaemonPort  int32  `json:"daemonPort"`
}

CdcNodeInfo

type ClusterKind

type ClusterKind int32

ClusterKind defines the PolarDBX cluster's kinds

const (
	MasterCluster   ClusterKind = 0
	ReadOnlyCluster ClusterKind = 1
)

These are valid cluster kinds

func (ClusterKind) String

func (k ClusterKind) String() string

type ComputeNodeInfo

type ComputeNodeInfo struct {
	// Host is the host or ip of server node.
	Host string `json:"host"`

	// Port is the service port of server node.
	Port int32 `json:"port"`

	// HtapPort is the port for HTAP of server node.
	HtapPort int32 `json:"htapPort"`

	// MgrPort is the port for management of server node.
	MgrPort int32 `json:"mgrPort"`

	// MppPort is the port for MPP of server node.
	MppPort int32 `json:"mppPort"`

	// Status stands
	Status PCNodeStatus `json:"status"`

	CpuCore int32 `json:"cpuCore"`

	MemSize int64 `json:"memSize"`

	Extra string `json:"extra,omitempty"`
}

ComputeNodeInfo defines the necessary information for compute nodes in PolarDBX cluster.

type GrantOption

type GrantOption struct {
	// Type of grant.
	Type GrantPrivilegeType `json:"type"`

	// Databases to grant, when type is GrantSuperPrivilege, the values are ignored.
	Databases []string `json:"databases"`

	// User to grant.
	User string `json:"user"`

	// Host to grant, default is "%" stands for all.
	Host string `json:"host,omitempty"`

	// Customized grant statement, only be used when GrantCustomPrivilege. Refer to
	// PolarDB-X privileges document.
	Privileges []string `json:"privileges,omitempty"`
}

GrantOption which

type GrantPrivilegeType

type GrantPrivilegeType string

GrantPrivilegeType for

const (
	GrantSuperPrivilege     GrantPrivilegeType = "super"
	GrantAllPrivilege       GrantPrivilegeType = "all"
	GrantReadWritePrivilege GrantPrivilegeType = "read-write"
	GrantReadOnlyPrivilege  GrantPrivilegeType = "read-only"
	GrantDdlPrivilege       GrantPrivilegeType = "ddl"
	GrantCustomPrivilege    GrantPrivilegeType = "custom"
)

These are valid grant privilege types.

type K8sObject

type K8sObject struct {
	Uid  types.UID
	Name string
}

type K8sTopology

type K8sTopology struct {
	GMS K8sObject
	DN  map[string]K8sObject
}

type Manager

type Manager interface {
	IsMetaDBInitialized() (bool, error)

	// InitializeMetaDB initializes the metadb. It's essential for creating a PolarDBX cluster.
	InitializeMetaDB() error

	// IsGmsSchemaRestored return the status if the schema is restored.
	IsGmsSchemaRestored() (bool, error)

	// RestoreSchemas restores the schemas in metadb.
	RestoreSchemas(fromPxcCluster string) error

	// EnableComputeNodes enables the specified compute server nodes by setting
	// the metadb.
	EnableComputeNodes(computeNodes ...ComputeNodeInfo) error

	// DisableComputeNodes disables the specified compute server nodes by setting
	// the metadb.
	DisableComputeNodes(computeNodes ...ComputeNodeInfo) error

	// DeleteComputeNodes deletes the specified compute server nodes by setting
	// the metadb.
	DeleteComputeNodes(computeNodes ...ComputeNodeInfo) error

	// ListComputeNodes lists all enabled compute server nodes.
	ListComputeNodes() ([]ComputeNodeInfo, error)

	// SyncComputeNodes deletes all nodes not specified and insert those not exists
	// in metadb
	SyncComputeNodes(computeNodes ...ComputeNodeInfo) error

	// EnableStorageNodes adds the specified storage nodes by adding the corresponding
	// records into metadb.
	EnableStorageNodes(storageNodes ...StorageNodeInfo) error

	// DisableStorageNodes disables the specified storage nodes by removing the corresponding
	// records from metadb.
	DisableStorageNodes(storageNodes ...StorageNodeInfo) error

	// ListStorageNodes lists all storage nodes.
	ListStorageNodes(kind StorageKind) ([]StorageNodeInfo, error)

	// ListCdcNodes lists all enabled CDC nodes.
	ListCdcNodes() ([]CdcNodeInfo, error)

	// DeleteCdcNodes deletes the specified CDC nodes by setting the metadb.
	DeleteCdcNodes(cdcNodes ...CdcNodeInfo) error

	// ListDynamicParams list all dynamic parameters in the cluster.
	ListDynamicParams() (map[string]string, error)

	// SyncDynamicParams syncs all specified parameters to cluster by setting the parameter table in metadb.
	SyncDynamicParams(params map[string]string) error

	// SyncSecurityIPs syncs all specified security ips to cluster.
	SyncSecurityIPs([]string) error

	// CreateDBAccount creates an account in cluster by directly creating records in metadb.
	CreateDBAccount(user, passwd string, grantOptions ...*GrantOption) error

	// DeleteDBAccount deletes the specified account in cluster by directly deleting records in metadb.
	DeleteDBAccount(user string) error

	// SyncAccountPasswd syncs the password of specified user in cluster by directly modifying records
	// in metadb. If the user not exists, it returns an error.
	SyncAccountPasswd(user, passwd string) error

	// SyncK8sTopology syncs the k8s topology into GMS.
	SyncK8sTopology(topology *K8sTopology) error

	// GetK8sTopology gets the k8s topology from GMS.
	GetK8sTopology() (*K8sTopology, error)

	// Lock locks the cluster, idempotent
	Lock() error

	// Unlock unlocks the cluster, idempotent
	Unlock() error

	// Close closes the manager
	Close() error
}

Manager defines a set of methods for manage the PolarDBX cluster.

func NewGmsManager

func NewGmsManager(ctx context.Context, clusterId string, metadb *MetaDB, cipher security.PasswordCipher) Manager

type MetaDB

type MetaDB struct {
	Id        string
	Host      string
	Host4Conn string
	Port      int
	XPort     int
	User      string
	Passwd    string

	Type StorageType
}

type PCNodeStatus

type PCNodeStatus int32

PCNodeStatus is the abbrev. for PolarDB-X Compute Node Status

const (
	PCNodeEnabled  PCNodeStatus = 0
	PCNodeDisabled PCNodeStatus = 1
)

These are valid PCNodeStatus

type PSNodeStatus

type PSNodeStatus int32

PSNodeStatus is the abbrev. for PolarDB-X Storage Node Status

const (
	PSNodeEnabled   PSNodeStatus = 0
	PSNodeDisabling PSNodeStatus = 1
	PSNodeDisabled  PSNodeStatus = 2
)

These are valid PSNodeStatus

type StorageKind

type StorageKind int32

StorageKind indicates the role of the storage node.

const (
	StorageKindMaster StorageKind = 0
	StorageKindSlave  StorageKind = 1
	StorageKindMetaDB StorageKind = 2
)

These are valid storage kinds.

type StorageNodeInfo

type StorageNodeInfo struct {
	// Id is the unique identity for storage node.
	Id string `json:"id"`

	// Host is host or ip of the storage node.
	Host string `json:"host"`

	// Port is the service port of the storage node.
	Port int32 `json:"port"`

	// XProtocolPort is the x-protocol port of the storage node.
	XProtocolPort int32 `json:"xport"`

	// User is the user of the storage node with super privilege.
	User string `json:"user"`

	// Passwd is the password encrypted of the user above.
	Passwd string `json:"passwd"`

	// Type indicates the storage type.
	Type StorageType `json:"type"`

	// Kind indicates the storage kind.
	Kind StorageKind `json:"kind"`

	// Status indicates that the storage's status.
	Status PSNodeStatus `json:"status"`

	// MaxConn indicates the max connection size the storage node supports.
	MaxConn int32 `json:"maxConn"`

	// CpuCore indicates the CPU core the storage node uses.
	CpuCore int32 `json:"cpuCore"`

	// MemSize indicates the memory size the storage node uses.
	MemSize int64 `json:"memSize"`

	// Extra define the extra messages.
	Extra string `json:"extra,omitempty"`
}

StorageNodeInfo defines the basic information for storage node.

type StorageType

type StorageType int32

StorageType indicates the type of the underlying storage node.

const (
	StorageTypeXCluster57    StorageType = 0
	StorageTypeMySQL         StorageType = 1
	StorageTypePolarDB       StorageType = 2
	StorageTypeXCluster80    StorageType = 3
	StorageTypeGalaxySingle  StorageType = 4
	StorageTypeGalaxyCluster StorageType = 5
)

These are valid storage types.

func GetStorageType

func GetStorageType(engine string, version string) (StorageType, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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