dtstruct

package
v0.0.0-...-6b32d26 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Copyright 2021 SANGFOR TECHNOLOGIES

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.

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

View Source
const (
	ReplicationThreadStateNoThread ReplicationThreadState = -1
	ReplicationThreadStateStopped                         = 0
	ReplicationThreadStateRunning                         = 1
	ReplicationThreadStateOther                           = 2
)

Variables

This section is empty.

Functions

func IsSmallerBinlogFormat

func IsSmallerBinlogFormat(binlogFormat string, otherBinlogFormat string) bool

IsSmallerBinlogFormat tests two binlog formats and sees if one is "smaller" than the other. "smaller" binlog format means you can replicate from the smaller to the larger.

Types

type InstancesByCountReplicas

type InstancesByCountReplicas []*MysqlInstance

InstancesByCountReplicas sorts instances by umber of replicas, descending

func (InstancesByCountReplicas) Len

func (this InstancesByCountReplicas) Len() int

func (InstancesByCountReplicas) Less

func (this InstancesByCountReplicas) Less(i, j int) bool

func (InstancesByCountReplicas) Swap

func (this InstancesByCountReplicas) Swap(i, j int)

type InstancesSorterByExec

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

InstancesSorterByExec sorts instances by executed binlog coordinates

func NewInstancesSorterByExec

func NewInstancesSorterByExec(instances [](*MysqlInstance), dataCenter string) *InstancesSorterByExec

func (*InstancesSorterByExec) Len

func (this *InstancesSorterByExec) Len() int

func (*InstancesSorterByExec) Less

func (this *InstancesSorterByExec) Less(i, j int) bool

func (*InstancesSorterByExec) Swap

func (this *InstancesSorterByExec) Swap(i, j int)

type MysqlInstance

type MysqlInstance struct {
	*dtstruct.Instance

	VersionComment      string
	CountMySQLSnapshots int

	ServerUUID                   string
	MasterUUID                   string
	AncestryUUID                 string
	Binlog_format                string
	BinlogRowImage               string
	LogBinEnabled                bool
	LogSlaveUpdatesEnabled       bool // for API backwards compatibility. Equals `LogReplicationUpdatesEnabled`
	LogReplicationUpdatesEnabled bool
	SelfBinlogCoordinates        dtstruct.LogCoordinates
	MasterExecutedGtidSet        string // Not exported

	//
	Slave_SQL_Running          bool // for API backwards compatibility. Equals `ReplicationSQLThreadRuning`
	ReplicationSQLThreadRuning bool
	Slave_IO_Running           bool // for API backwards compatibility. Equals `ReplicationIOThreadRuning`
	ReplicationIOThreadRuning  bool
	ReplicationSQLThreadState  ReplicationThreadState
	ReplicationIOThreadState   ReplicationThreadState

	GTIDMode              string
	SupportsOracleGTID    bool
	UsingOracleGTID       bool
	UsingMariaDBGTID      bool
	UsingPseudoGTID       bool
	ReadBinlogCoordinates dtstruct.LogCoordinates
	ExecBinlogCoordinates dtstruct.LogCoordinates
	IsDetached            bool
	RelaylogCoordinates   dtstruct.LogCoordinates
	LastSQLError          string
	LastIOError           string
	SecondsBehindMaster   sql.NullInt64
	SQLDelay              uint
	ExecutedGtidSet       string
	GtidPurged            string
	GtidErrant            string

	SemiSyncAvailable                 bool // when both semi sync plugins (master & replica) are loaded
	SemiSyncEnforced                  bool
	SemiSyncMasterEnabled             bool
	SemiSyncReplicaEnabled            bool
	SemiSyncMasterTimeout             uint64
	SemiSyncMasterWaitForReplicaCount uint
	SemiSyncMasterStatus              bool
	SemiSyncMasterClients             uint
	SemiSyncReplicaStatus             bool

	// Group replication global variables
	ReplicationGroupName            string
	ReplicationGroupIsSinglePrimary bool

	// Replication group members information. See
	// https://dev.mysql.com/doc/refman/8.0/en/replication-group-members-table.html for details.
	ReplicationGroupMemberState string
	ReplicationGroupMemberRole  string

	// List of all known members of the same group
	ReplicationGroupMembers dtstruct.InstanceKeyMap

	// Primary of the replication group
	ReplicationGroupPrimaryInstanceKey dtstruct.InstanceKey
}

func NewInstance

func NewInstance() *MysqlInstance

NewInstance creates a new, empty instance

func (*MysqlInstance) AddGroupMemberKey

func (this *MysqlInstance) AddGroupMemberKey(groupMemberKey *dtstruct.InstanceKey)

AddGroupMemberKey adds a group member to the list of this instance's group members.

func (*MysqlInstance) CanMove

func (this *MysqlInstance) CanMove() (bool, error)

CanMove returns true if this instance's state allows it to be repositioned. For example, if this instance lags too much, it will not be moveable.

func (*MysqlInstance) CanMoveAsCoMaster

func (this *MysqlInstance) CanMoveAsCoMaster() (bool, error)

CanMoveAsCoMaster returns true if this instance's state allows it to be repositioned.

func (*MysqlInstance) CanMoveViaMatch

func (this *MysqlInstance) CanMoveViaMatch() (bool, error)

CanMoveViaMatch returns true if this instance's state allows it to be repositioned via pseudo-GTID matching

func (*MysqlInstance) Equals

func (this *MysqlInstance) Equals(other *dtstruct.Instance) bool

Equals tests that this instance is the same instance as other. The function does not test configuration or status.

func (*MysqlInstance) FlavorNameAndMajorVersion

func (this *MysqlInstance) FlavorNameAndMajorVersion() string

FlavorNameAndMajorVersion returns a string of the combined flavor and major version which is useful in some checks.

func (*MysqlInstance) GetDatabaseType

func (this *MysqlInstance) GetDatabaseType() string

func (*MysqlInstance) GetHandler

func (this *MysqlInstance) GetHandler() dtstruct.InstanceAdaptor

func (*MysqlInstance) GetHostname

func (mi *MysqlInstance) GetHostname() string

func (*MysqlInstance) GetInstance

func (mi *MysqlInstance) GetInstance() *dtstruct.Instance

TODO double check

func (*MysqlInstance) GetNextBinaryLog

func (this *MysqlInstance) GetNextBinaryLog(binlogCoordinates dtstruct.LogCoordinates) (dtstruct.LogCoordinates, error)

GetNextBinaryLog returns the successive, if any, binary log file to the one given

func (*MysqlInstance) GetPort

func (mi *MysqlInstance) GetPort() int

func (*MysqlInstance) HasReasonableMaintenanceReplicationLag

func (this *MysqlInstance) HasReasonableMaintenanceReplicationLag() bool

HasReasonableMaintenanceReplicationLag returns true when the replica lag is reasonable, and maintenance operations should have a green light to go.

func (*MysqlInstance) HumanReadableDescription

func (this *MysqlInstance) HumanReadableDescription() string

HumanReadableDescription returns a simple readable string describing the status, version, etc. properties of this instance

func (*MysqlInstance) IsDescendantOf

func (this *MysqlInstance) IsDescendantOf(other *MysqlInstance) bool

IsDescendantOf returns true if this is replication directly or indirectly from other

func (*MysqlInstance) IsMariaDB

func (this *MysqlInstance) IsMariaDB() bool

IsMariaDB checks whether this is any version of MariaDB

func (*MysqlInstance) IsMasterOf

func (this *MysqlInstance) IsMasterOf(replica *MysqlInstance) bool

IsReplicaOf returns true if this i supposed master of given replica

func (*MysqlInstance) IsMaxScale

func (this *MysqlInstance) IsMaxScale() bool

isMaxScale checks whether this is any version of MaxScale

func (*MysqlInstance) IsMySQL51

func (this *MysqlInstance) IsMySQL51() bool

func (*MysqlInstance) IsMySQL55

func (this *MysqlInstance) IsMySQL55() bool

func (*MysqlInstance) IsMySQL56

func (this *MysqlInstance) IsMySQL56() bool

func (*MysqlInstance) IsMySQL57

func (this *MysqlInstance) IsMySQL57() bool

func (*MysqlInstance) IsMySQL80

func (this *MysqlInstance) IsMySQL80() bool

func (*MysqlInstance) IsNDB

func (this *MysqlInstance) IsNDB() bool

isNDB check whether this is NDB Cluster (aka MySQL Cluster)

func (*MysqlInstance) IsOracleMySQL

func (this *MysqlInstance) IsOracleMySQL() bool

IsOracleMySQL checks whether this is an Oracle MySQL distribution

func (*MysqlInstance) IsPercona

func (this *MysqlInstance) IsPercona() bool

IsPercona checks whether this is any version of Percona Server

func (*MysqlInstance) IsReplica

func (this *MysqlInstance) IsReplica() bool

IsReplica makes simple heuristics to decide whether this instance is a replica of another instance

func (*MysqlInstance) IsReplicaOf

func (this *MysqlInstance) IsReplicaOf(master *MysqlInstance) bool

IsReplicaOf returns true if this instance claims to replicate from given master

func (*MysqlInstance) IsReplicaServer

func (this *MysqlInstance) IsReplicaServer() bool

IsReplicaServer checks whether this is any type of a binlog server (currently only maxscale)

func (*MysqlInstance) IsReplicationGroupMember

func (this *MysqlInstance) IsReplicationGroupMember() bool

IsReplicationGroup checks whether the host thinks it is part of a known replication group. Notice that this might return True even if the group has decided to expel the member represented by this instance, as the instance might not know that under certain circumstances

func (*MysqlInstance) IsReplicationGroupPrimary

func (this *MysqlInstance) IsReplicationGroupPrimary() bool

func (*MysqlInstance) IsReplicationGroupSecondary

func (this *MysqlInstance) IsReplicationGroupSecondary() bool

func (*MysqlInstance) LagStatusString

func (this *MysqlInstance) LagStatusString() string

LagStatusString returns a human readable representation of current lag

func (*MysqlInstance) Less

func (this *MysqlInstance) Less(handler dtstruct.InstanceAdaptor, dataCenter string) bool

func (*MysqlInstance) MarshalJSON

func (this *MysqlInstance) MarshalJSON() ([]byte, error)

func (*MysqlInstance) NextGTID

func (this *MysqlInstance) NextGTID() (string, error)

NextGTID returns the next (Oracle) GTID to be executed. Useful for skipping queries

func (*MysqlInstance) ReplicaRunning

func (this *MysqlInstance) ReplicaRunning() bool

ReplicaRunning returns true when this instance's status is of a replicating replica.

func (*MysqlInstance) ReplicationThreadsExist

func (this *MysqlInstance) ReplicationThreadsExist() bool

NoReplicationThreadRunning returns true when neither SQL nor IO threads are running (including the case where isn't even a replica)

func (*MysqlInstance) ReplicationThreadsStopped

func (this *MysqlInstance) ReplicationThreadsStopped() bool

NoReplicationThreadRunning returns true when neither SQL nor IO threads are running (including the case where isn't even a replica)

func (*MysqlInstance) SQLThreadUpToDate

func (this *MysqlInstance) SQLThreadUpToDate() bool

SQLThreadUpToDate returns true when the instance had consumed all relay logs.

func (*MysqlInstance) SetFlavorName

func (this *MysqlInstance) SetFlavorName()

applyFlavorName

func (*MysqlInstance) SetHstPrtAndClusterName

func (this *MysqlInstance) SetHstPrtAndClusterName(hostname string, port int, upstreamHostname string, upstreamPort int, clusterName string)

func (*MysqlInstance) SetInstance

func (this *MysqlInstance) SetInstance(instance *dtstruct.Instance)

func (*MysqlInstance) SetPromotionRule

func (this *MysqlInstance) SetPromotionRule(promotionRule dtstruct.CandidatePromotionRule)

func (*MysqlInstance) StatusString

func (this *MysqlInstance) StatusString() string

StatusString returns a human readable description of this instance's status

func (*MysqlInstance) TabulatedDescription

func (this *MysqlInstance) TabulatedDescription(separator string) string

TabulatedDescription returns a simple tabulated string of various properties

func (*MysqlInstance) UsingGTID

func (this *MysqlInstance) UsingGTID() bool

UsingGTID returns true when this replica is currently replicating via GTID (either Oracle or MariaDB)

type ReplicationThreadState

type ReplicationThreadState int

func ReplicationThreadStateFromStatus

func ReplicationThreadStateFromStatus(status string) ReplicationThreadState

func (*ReplicationThreadState) Exists

func (this *ReplicationThreadState) Exists() bool

func (*ReplicationThreadState) IsRunning

func (this *ReplicationThreadState) IsRunning() bool

func (*ReplicationThreadState) IsStopped

func (this *ReplicationThreadState) IsStopped() bool

Jump to

Keyboard shortcuts

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