DataObjects

package
v0.0.0-...-fb76de4 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2021 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyMap

func CopyMap(mapDest map[string]DataNodePxc, mapSource map[string]DataNodePxc) map[string]DataNodePxc

func MergeMaps

func MergeMaps(arrayOfMaps [4]map[string]DataNodePxc) map[string]DataNodePxc

==================== Generic

Types

type DataCluster

type DataCluster struct {
	ActiveFailover    int
	FailBack          bool
	ActionNodes       map[string]DataNodePxc
	BackupReaders     map[string]DataNodePxc
	BackupWriters     map[string]DataNodePxc
	BackupHgReaderId  int
	BakcupHgWriterId  int
	CheckTimeout      int
	ClusterIdentifier int //cluster_id
	ClusterSize       int
	HasPrimary        bool
	ClusterName       string
	Comment           string

	Debug           bool
	FailOverNode    DataNodePxc
	HasFailoverNode bool
	Haswriter       bool
	HgReaderId      int
	HgWriterId      int
	Hostgroups      map[int]Hostgroup
	//	Hosts map[string] DataNode
	MainSegment       int
	MonitorPassword   string
	MonitorUser       string
	Name              string
	NodesPxc          *SyncMap //[string] DataNodePxc // <ip:port,datanode>
	NodesPxcMaint     []DataNodePxc
	MaxNumWriters     int
	OffLineReaders    map[string]DataNodePxc
	OffLineWriters    map[string]DataNodePxc
	OffLineHgReaderID int
	OffLineHgWriterId int
	ReaderNodes       map[string]DataNodePxc
	RequireFailover   bool
	RetryDown         int
	RetryUp           int
	Singlenode        bool
	SinglePrimary     bool
	Size              int
	Ssl               *SslCertificates
	Status            int
	WriterIsReader    int
	WriterNodes       map[string]DataNodePxc
	// contains filtered or unexported fields
}

func (*DataCluster) GetActionList

func (cluster *DataCluster) GetActionList() map[string]DataNodePxc

This method is where we initiate the analysis of the nodes an the starting point of the population of the actionList The actionList is the object returning the list of nodes that require modification Any modification at their status in ProxySQL is done by the ProxySQLNode object

type DataNode

type DataNode struct {
	ActionType        int
	NodeIsNew         bool
	RetryUp           int
	RetryDown         int
	Comment           string
	Compression       int
	Connection        *sql.DB
	ConnUsed          int
	Debug             bool
	Dns               string
	GtidPort          int
	HostgroupId       int
	Hostgroups        []Hostgroup
	Ip                string
	MaxConnection     int
	MaxLatency        int
	MaxReplicationLag int
	Name              string
	NodeTCPDown       bool
	Password          string
	Port              int
	Processed         bool
	ProcessStatus     int
	ProxyStatus       string
	ReadOnly          bool
	Ssl               *SslCertificates
	Status            map[string]string
	UseSsl            bool
	User              string
	Variables         map[string]string
	Weight            int
}

func (*DataNode) CloseConnection

func (node *DataNode) CloseConnection() bool

func (*DataNode) DELETE_NODE

func (node *DataNode) DELETE_NODE() int

func (*DataNode) GetConnection

func (node *DataNode) GetConnection() bool

this method is used to assign a connection to a proxySQL node return true if successful in any other case false

func (*DataNode) INSERT_READ

func (node *DataNode) INSERT_READ() int

func (*DataNode) INSERT_WRITE

func (node *DataNode) INSERT_WRITE() int

func (*DataNode) MOVE_DOWN_HG_CHANGE

func (node *DataNode) MOVE_DOWN_HG_CHANGE() int

func (*DataNode) MOVE_DOWN_OFFLINE

func (node *DataNode) MOVE_DOWN_OFFLINE() int

func (*DataNode) MOVE_OUT_MAINTENANCE

func (node *DataNode) MOVE_OUT_MAINTENANCE() int

func (*DataNode) MOVE_SWAP_READER_TO_WRITER

func (node *DataNode) MOVE_SWAP_READER_TO_WRITER() int

func (*DataNode) MOVE_SWAP_WRITER_TO_READER

func (node *DataNode) MOVE_SWAP_WRITER_TO_READER() int

func (*DataNode) MOVE_TO_MAINTENANCE

func (node *DataNode) MOVE_TO_MAINTENANCE() int

func (*DataNode) MOVE_UP_HG_CHANGE

func (node *DataNode) MOVE_UP_HG_CHANGE() int

func (*DataNode) MOVE_UP_OFFLINE

func (node *DataNode) MOVE_UP_OFFLINE() int

func (*DataNode) NOTHING_TO_DO

func (node *DataNode) NOTHING_TO_DO() int

NODE CONSTANT declaration by methods

func (*DataNode) ReturnActionCategory

func (node *DataNode) ReturnActionCategory(code int) string

func (*DataNode) ReturnTextFromCode

func (node *DataNode) ReturnTextFromCode(code int) string

func (*DataNode) SAVE_RETRY

func (node *DataNode) SAVE_RETRY() int

type DataNodePxc

type DataNodePxc struct {
	DataNodeBase            DataNode
	PxcMaintMode            string
	WsrepConnected          bool
	WsrepDesinccount        int
	WsrepDonorrejectqueries bool
	WsrepGcommUuid          string
	WsrepLocalIndex         int
	WsrepPcWeight           int
	WsrepProvider           map[string]string
	WsrepReady              bool
	WsrepRejectqueries      bool
	WsrepSegment            int
	WsrepStatus             int
	WsrepClusterSize        int
	WsrepClusterName        string
	WsrepClusterStatus      string
	WsrepNodeName           string
	HasPrimaryState         bool
	PxcView                 PxcClusterView
}

type Hostgroup

type Hostgroup struct {
	Id    int
	Size  int
	Type  string
	Nodes []DataNode
}

type Locker

type Locker struct {
	MyServerIp   string
	MyServerPort int
	MyServer     *ProxySQLNode

	FileLock               string
	FileLockPath           string
	FileLockInterval       int64
	FileLockReset          bool
	ClusterLockId          string
	ClusterLockInterval    int64
	ClusterLockReset       bool
	ClusterLastLockTime    int64
	ClusterCurrentLockTime int64
	IsClusterLocked        bool
	IsFileLocked           bool

	LockFileTimeout    int64
	LockClusterTimeout int64
	// contains filtered or unexported fields
}

func (*Locker) CheckClusterLock

func (locker *Locker) CheckClusterLock() *ProxySQLNode

func (*Locker) CheckFileLock

func (locker *Locker) CheckFileLock() *ProxySQLNode

TODO fill the method

func (*Locker) Init

func (locker *Locker) Init(config *global.Configuration) bool

Initialize the locker TODO initialize

func (*Locker) PushSchedulerLock

func (locker *Locker) PushSchedulerLock(nodes map[string]ProxySQLNode) bool

We are ready to submit our changes. As always all is executed in a transaction TODO SHOULD we remove the proxysql node that doesn't work ????

func (*Locker) RemoveLockFile

func (locker *Locker) RemoveLockFile() bool

func (*Locker) SetLockFile

func (locker *Locker) SetLockFile() bool

type ProxySQLCluster

type ProxySQLCluster struct {
	Name     string
	Nodes    map[string]ProxySQLNode
	Active   bool
	User     string
	Password string
}

Cluster object and methods

func (ProxySQLCluster) GetProxySQLnodes

func (cluster ProxySQLCluster) GetProxySQLnodes(myNode *ProxySQLNode) bool

This method in ProxySQL Cluster Object is responsible for getting the list of ACTIVE ProxySQL servers. Interestingly ProxySQL has not clue if a ProxySQL nodes ur down. Or at least is not reported in the proxysql_server tables or any stats table Given that we check if nodes are reachable opening a connection and closing it

type ProxySQLNode

type ProxySQLNode struct {
	ActionNodeList  map[string]DataNodePxc
	Dns             string
	Hostgoups       map[int]Hostgroup
	Ip              string
	MonitorPassword string
	MonitorUser     string
	Password        string
	Port            int
	User            string
	Connection      *sql.DB
	MySQLCluster    *DataCluster
	Variables       map[string]string
	IsInitialized   bool
	Weight          int
	HoldLock        bool
	IsLockExpired   bool
	LastLockTime    int64
	Comment         string
}

func (*ProxySQLNode) CloseConnection

func (node *ProxySQLNode) CloseConnection() bool

func (*ProxySQLNode) DeleteDataNode

func (node *ProxySQLNode) DeleteDataNode(dataNode DataNode, hg int, ip string, port int) string

Delete the given node

func (*ProxySQLNode) GetConnection

func (node *ProxySQLNode) GetConnection() bool

this method is used to assign a connection to a proxySQL node return true if successful in any other case false

Note ?timeout=1s is HARDCODED on purpose. This is a check that MUST execute in less than a second. Having a connection taking longer than that is outrageous. Period!

func (*ProxySQLNode) GetDataCluster

func (node *ProxySQLNode) GetDataCluster(config global.Configuration) bool

Retrieve active cluster check for pxc_cluster and cluster_id add to the object a DataCluster object. DataCluster returns already Initialized, which means it returns with all node populated with status ProxySQLNode

|
|-> DataCluster
		|
		|-> DataObject
				|
			Pxc | GR

func (*ProxySQLNode) Init

func (node *ProxySQLNode) Init(config *global.Configuration) bool

Init the proxySQL node

func (*ProxySQLNode) InsertRead

func (node *ProxySQLNode) InsertRead(dataNode DataNode, hg int, ip string, port int) string

When inserting a node we need to differentiate when is a NEW node coming from the Bakcup HG because in that case we will NOT push it directly to prod

func (*ProxySQLNode) InsertWrite

func (node *ProxySQLNode) InsertWrite(dataNode DataNode, hg int, ip string, port int) string

When inserting a node we need to differentiate when is a NEW node coming from the Bakcup HG because in that case we will NOT push it directly to prod

func (*ProxySQLNode) MoveNodeDownToHGCange

func (node *ProxySQLNode) MoveNodeDownToHGCange(dataNode DataNode, hg int, ip string, port int) string

func (*ProxySQLNode) MoveNodeDownToOfflineSoft

func (node *ProxySQLNode) MoveNodeDownToOfflineSoft(dataNode DataNode, hg int, ip string, port int) string

func (*ProxySQLNode) MoveNodeUpFromHGCange

func (node *ProxySQLNode) MoveNodeUpFromHGCange(dataNode DataNode, hg int, ip string, port int) string

func (*ProxySQLNode) MoveNodeUpFromOfflineSoft

func (node *ProxySQLNode) MoveNodeUpFromOfflineSoft(dataNode DataNode, hg int, ip string, port int) string

func (*ProxySQLNode) ProcessChanges

func (node *ProxySQLNode) ProcessChanges() bool

This method is the one applying the changes to the proxy database

func (*ProxySQLNode) SaveRetry

func (node *ProxySQLNode) SaveRetry(dataNode DataNode, hg int, ip string, port int) string

This action is used to modify the RETRY options stored in the comment field It is important to know that after a final action (like move to OFFLINE_SOFT or move to another HG) the application will try to reset the RETRIES to 0

type PxcClusterView

type PxcClusterView struct {
	//'HOST_NAME', 'UUID','STATUS','LOCAL_INDEX','SEGMENT'
	HostName   string
	Uuid       string
	Status     string
	LocalIndex int
	Segment    int
}

type SslCertificates

type SslCertificates struct {
	// contains filtered or unexported fields
}

type SyncMap

type SyncMap struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewRegularIntMap

func NewRegularIntMap() *SyncMap

Sync Map =====================================

func (*SyncMap) Delete

func (rm *SyncMap) Delete(key string)

func (*SyncMap) ExposeMap

func (rm *SyncMap) ExposeMap() map[string]DataNodePxc

func (*SyncMap) Load

func (rm *SyncMap) Load(key string) (value DataNodePxc, ok bool)

func (*SyncMap) Store

func (rm *SyncMap) Store(key string, value DataNodePxc)

type VariableStatus

type VariableStatus struct {
	VarName  string `db:"VARIABLE_NAME"`
	VarValue string `db:"VARIABLE_VALUE"`
}

Jump to

Keyboard shortcuts

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