inst

package
v1.3.16 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2015 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const InvalidPort = 65535
View Source
const SQLThreadPollDuration = 200 * time.Millisecond

Variables

This section is empty.

Functions

func ApplyClusterAlias added in v1.2.20

func ApplyClusterAlias(clusterInfo *ClusterInfo)

func AsciiTopology

func AsciiTopology(instanceKey *InstanceKey) (string, error)

AsciiTopology returns a string representation of the topology of given instance.

func AuditOperation

func AuditOperation(auditType string, instanceKey *InstanceKey, message string) error

AuditOperation creates and writes a new audit entry by given params

func BeginMaintenance

func BeginMaintenance(instanceKey *InstanceKey, owner string, reason string) (int64, error)

BeginMaintenance will make new maintenance entry for given instanceKey.

func EndMaintenance

func EndMaintenance(maintenanceToken int64) error

EndMaintenance will terminate an active maintenance via maintenanceToken

func EndMaintenanceByInstanceKey

func EndMaintenanceByInstanceKey(instanceKey *InstanceKey) error

EndMaintenanceByInstanceKey will terminate an active maintenance using given instanceKey as hint

func ExecDBWriteFunc added in v1.2.20

func ExecDBWriteFunc(f func() error) error

ExecDBWriteFunc chooses how to execute a write onto the database: whether synchronuously or not

func ExecInstance

func ExecInstance(instanceKey *InstanceKey, query string, args ...interface{}) (sql.Result, error)

ExecInstance executes a given query on the given MySQL topology instance

func ExecuteOnTopology added in v1.3.19

func ExecuteOnTopology(f func())

ExecuteOnTopology will execute given function while maintaining concurrency limit on topology servers. It is safe in the sense that we will not leak tokens.

func ForgetExpiredHostnameResolves added in v1.2.9

func ForgetExpiredHostnameResolves() error

ForgetExpiredHostnameResolves

func ForgetInstance

func ForgetInstance(instanceKey *InstanceKey) error

ForgetInstance removes an instance entry from the orchestrator backed database. It may be auto-rediscovered through topology or requested for discovery by multiple means.

func ForgetLongUnseenInstances

func ForgetLongUnseenInstances() error

ForgetLongUnseenInstances will remove entries of all instacnes that have long since been last seen.

func GetCNAME

func GetCNAME(hostname string) (string, error)

GetCNAME resolves an IP or hostname into a normalized valid CNAME

func GetCandidateSlave added in v1.3.6

func GetCandidateSlave(masterKey *InstanceKey, forceRefresh bool) (*Instance, [](*Instance), int, error)

GetCandidateSlave chooses the best slave to promote given a (possibly dead) master

func InjectUnseenMasters added in v1.3.19

func InjectUnseenMasters() error

InjectUnseenMasters will review masters of instances that are known to be replication, yet which are not listed in database_instance. Since their slaves are listed as replicating, we can assume that such masters actually do exist: we shall therefore inject them with minimal details into the database_instance table.

func InstanceIsMasterOf added in v1.0.5

func InstanceIsMasterOf(instance0, instance1 *Instance) bool

InstanceIsMasterOf checks whether an instance is the master of another

func InstancesAreSiblings

func InstancesAreSiblings(instance0, instance1 *Instance) bool

InstancesAreSiblings checks whether both instances are replicating from same master

func LoadHostnameResolveCacheFromDatabase added in v1.2.12

func LoadHostnameResolveCacheFromDatabase() error

func MatchBelow added in v1.2.9

func MatchBelow(instanceKey, otherKey *InstanceKey, requireInstanceMaintenance bool, requireOtherMaintenance bool) (*Instance, *BinlogCoordinates, error)

MatchBelow will attempt moving instance indicated by instanceKey below its the one indicated by otherKey. The refactoring is based on matching binlog entries, not on "classic" positions comparisons. The "other instance" could be the sibling of the moving instance any of its ancestors. It may actuall be a cousin of some sort (though unlikely). The only important thing is that the "other instance" is more advanced in replication than given instance.

func MatchUpSlaves added in v1.3.6

func MatchUpSlaves(masterKey *InstanceKey) ([](*Instance), *Instance, error)

MatchUpSlaves will move all slaves of given master up the replication chain, so that they become siblings of their master. This should be called when the local master dies, and all its slaves are to be resurrected via Pseudo-GTID

func MultiMatchBelow added in v1.3.6

func MultiMatchBelow(slaves [](*Instance), belowKey *InstanceKey) ([](*Instance), *Instance, error)

MultiMatchBelow will efficiently match multiple slaves below a given instance. It is assumed that all given slaves are siblings

func MultiMatchSlaves added in v1.3.10

func MultiMatchSlaves(masterKey *InstanceKey, belowKey *InstanceKey) ([](*Instance), *Instance, error)

MultiMatchSlaves will match (via pseudo-gtid) all slaves of given master below given instance.

func PopulateInstancesAgents added in v1.1.2

func PopulateInstancesAgents(instances [](*Instance)) error

For the given list of instances, fill in extra data acquired from agents At current this is the number of snapshots. This isn't too pretty; it's a push-into-instance-data-that-belongs-to-agent thing. Originally the need was to visually present the number of snapshots per host on the web/cluster page, which indeed proves to be useful in our experience.

func ReadClusterAliases added in v1.2.20

func ReadClusterAliases() error

ReadClusterAliases reads the entrie cluster name aliases mapping

func ReadClusterNameByMaster

func ReadClusterNameByMaster(instanceKey *InstanceKey, masterKey *InstanceKey) (string, error)

ReadClusterNameByMaster will return the cluster name for a given instance by looking at its master and getting it from there. It is a non-recursive function and so-called-recursion is performed upon periodic reading of instances.

func ReadClusters

func ReadClusters() ([]string, error)

ReadClusters reads names of all known clusters

func ReadCountMySQLSnapshots added in v1.1.11

func ReadCountMySQLSnapshots(hostnames []string) (map[string]int, error)

ReadCountMySQLSnapshots is a utility method to return registered number of snapshots for a given list of hosts

func ReadResolvedHostname added in v1.2.9

func ReadResolvedHostname(hostname string) (string, error)

ReadResolvedHostname returns the resolved hostname given a hostname, or empty if not exists

func RefreshTopologyInstances added in v1.3.6

func RefreshTopologyInstances(instances [](*Instance))

RefreshTopologyInstances will do a blocking (though concurrent) refresh of all given instances

func ResetHostnameResolveCache added in v1.2.12

func ResetHostnameResolveCache() error

func ResolveHostname added in v1.2.9

func ResolveHostname(hostname string) (string, error)

Attempt to resolve a hostname. This may returned a database cached hostname or otherwise it may resolve the hostname via CNAME

func ReviewUnseenInstances added in v1.3.10

func ReviewUnseenInstances() error

ReviewUnseenInstances reviews instances that have not been seen (suposedly dead) and updates some of their data

func ScanInstanceRow

func ScanInstanceRow(instanceKey *InstanceKey, query string, dest ...interface{}) error

ScanInstanceRow executes a read-a-single-row query on a given MySQL topology instance

func SetClusterAlias added in v1.2.20

func SetClusterAlias(clusterName string, alias string) error

SetClusterAlias will write (and override) a single cluster name mapping

func StartSlaves added in v1.3.19

func StartSlaves(slaves [](*Instance))

StartSlaves will do concurrent start-slave

func StopSlavesNicely added in v1.3.6

func StopSlavesNicely(slaves [](*Instance), timeout time.Duration)

StopSlavesNicely will attemt to stop all given slaves nicely, up to timeout

func UpdateInstanceLastAttemptedCheck added in v1.2.9

func UpdateInstanceLastAttemptedCheck(instanceKey *InstanceKey) error

UpdateInstanceLastAttemptedCheck updates the last_attempted_check timestamp in the orchestrator backed database for a given instance. This is used as a failsafe mechanism in case access to the instance gets hung (it happens), in which case the entire ReadTopology gets stuck (and no, connection timeout nor driver timeouts don't help. Don't look at me, the world is a harsh place to live in). And so we make sure to note down *before* we even attempt to access the instance; and this raises a red flag when we wish to access the instance again: if last_attempted_check is *newer* than last_checked, that's bad news and means we have a "hanging" issue.

func UpdateInstanceLastChecked

func UpdateInstanceLastChecked(instanceKey *InstanceKey) error

UpdateInstanceLastChecked updates the last_check timestamp in the orchestrator backed database for a given instance

func UpdateResolvedHostname added in v1.2.10

func UpdateResolvedHostname(hostname string, resolvedHostname string) bool

UpdateResolvedHostname will store the given resolved hostname in cache Returns false when the key already existed with same resolved value (similar to AFFECTED_ROWS() in mysql)

func WriteClusterAlias added in v1.2.20

func WriteClusterAlias(clusterName string, alias string) error

WriteClusterAlias will write (and override) a single cluster name mapping

func WriteLongRunningProcesses added in v1.1.2

func WriteLongRunningProcesses(instanceKey *InstanceKey, processes []Process) error

WriteLongRunningProcesses rewrites current state of long running processes for given instance

func WriteResolvedHostname added in v1.2.9

func WriteResolvedHostname(hostname string, resolvedHostname string) error

WriteResolvedHostname stores a hostname and the resolved hostname to backend database

Types

type Audit

type Audit struct {
	AuditId          int64
	AuditTimestamp   string
	AuditType        string
	AuditInstanceKey InstanceKey
	Message          string
}

Audit presents a single audit entry (namely in the database)

func ReadRecentAudit

func ReadRecentAudit(page int) ([]Audit, error)

ReadRecentAudit returns a list of audit entries order chronologically descending, using page number.

type BinlogCoordinates

type BinlogCoordinates struct {
	LogFile string
	LogPos  int64
	Type    BinlogType
}

BinlogCoordinates described binary log coordinates in the form of log file & log position.

func FindLastPseudoGTIDEntry added in v1.3.19

func FindLastPseudoGTIDEntry(instance *Instance, recordedInstanceRelayLogCoordinates BinlogCoordinates) (*BinlogCoordinates, string, error)

FindLastPseudoGTIDEntry will search an instance's binary logs or relay logs for the last pseudo-GTID entry, and return found coordinates as well as entry text

func GetLastPseudoGTIDEntryInInstance added in v1.2.9

func GetLastPseudoGTIDEntryInInstance(instance *Instance) (*BinlogCoordinates, string, error)

func GetLastPseudoGTIDEntryInRelayLogs added in v1.3.0

func GetLastPseudoGTIDEntryInRelayLogs(instance *Instance, recordedInstanceRelayLogCoordinates BinlogCoordinates) (*BinlogCoordinates, string, error)

func GetNextBinlogCoordinatesToMatch added in v1.2.9

func GetNextBinlogCoordinatesToMatch(instance *Instance, instanceCoordinates BinlogCoordinates, recordedInstanceRelayLogCoordinates BinlogCoordinates,
	other *Instance, otherCoordinates BinlogCoordinates) (*BinlogCoordinates, error)

GetNextBinlogCoordinatesToMatch is given a twin-coordinates couple for a would-be slave (instanceKey) and another instance (otherKey). This is part of the match-below process, and is the heart of the operation: matching the binlog events starting the twin-coordinates (where both share the same Pseudo-GTID) until "instance" runs out of entries, hopefully before "other" runs out. If "other" runs out that means "instance" is more advanced in replication than "other", in which case we can't turn it into a slave of "other". Otherwise "instance" will point to the *next* binlog entry in "other"

func SearchPseudoGTIDEntryInBinlog added in v1.2.9

func SearchPseudoGTIDEntryInBinlog(instanceKey *InstanceKey, binlog string, entryText string) (BinlogCoordinates, error)

Given a binlog entry text (query), search it in the given binary log of a given instance

func SearchPseudoGTIDEntryInInstance added in v1.2.9

func SearchPseudoGTIDEntryInInstance(instance *Instance, entryText string) (*BinlogCoordinates, error)

func (*BinlogCoordinates) DisplayString added in v1.3.6

func (this *BinlogCoordinates) DisplayString() string

DisplayString returns a user-friendly string representation of these coordinates

func (*BinlogCoordinates) Equals

func (this *BinlogCoordinates) Equals(other *BinlogCoordinates) bool

Equals tests equality of this corrdinate and another one.

func (*BinlogCoordinates) PreviousFileCoordinates added in v1.3.6

func (this *BinlogCoordinates) PreviousFileCoordinates() (BinlogCoordinates, error)

Previous guesses the filename of the previous binlog/relaylog

func (*BinlogCoordinates) SmallerThan

func (this *BinlogCoordinates) SmallerThan(other *BinlogCoordinates) bool

SmallerThan returns true if this coordinate is strictly smaller than the other.

type BinlogEvent added in v1.2.9

type BinlogEvent struct {
	Coordinates  BinlogCoordinates
	NextEventPos int64
	EventType    string
	Info         string
}

func (*BinlogEvent) NextBinlogCoordinates added in v1.2.9

func (this *BinlogEvent) NextBinlogCoordinates() BinlogCoordinates

func (*BinlogEvent) NormalizeInfo added in v1.2.9

func (this *BinlogEvent) NormalizeInfo()

type BinlogEventCursor added in v1.2.9

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

func NewBinlogEventCursor added in v1.2.9

func NewBinlogEventCursor(startCoordinates BinlogCoordinates, fetchNextEventsFunc func(BinlogCoordinates) ([]BinlogEvent, error)) BinlogEventCursor

fetchNextEventsFunc expected to return events starting at a given position, and automatically fetch those from next binary log when no more rows are found in current log. It is expected to return empty array with no error upon end of binlogs It is expected to return error upon error...

func (*BinlogEventCursor) NextCoordinates added in v1.2.9

func (this *BinlogEventCursor) NextCoordinates() (BinlogCoordinates, error)

NextCoordinates return the binlog coordinates of the next entry as yet unprocessed by the cursor. Moreover, when the cursor terminates (consumes last entry), these coordinates indicate what will be the futuristic coordinates of the next binlog entry. The value of this function is used by match-below to move a slave behind another, after exhausting the shared binlog entries of both.

func (*BinlogEventCursor) NextEvent added in v1.2.9

func (this *BinlogEventCursor) NextEvent() (*BinlogEvent, error)

NextEvent will return the next event entry from binary logs; it will automatically skip to next binary log if need be. Internally, it uses the cachedEvents array, so that it does not go to the MySQL server upon each call. Returns nil upon reaching end of binary logs.

func (*BinlogEventCursor) NextRealEvent added in v1.2.9

func (this *BinlogEventCursor) NextRealEvent() (*BinlogEvent, error)

NextRealEvent returns the next event from binlog that is not meta/control event (these are start-of-binary-log, rotate-binary-log etc.)

type BinlogType added in v1.3.0

type BinlogType int
const (
	BinaryLog BinlogType = iota
	RelayLog
)

type ClusterInfo added in v1.1.2

type ClusterInfo struct {
	ClusterName    string
	ClusterAlias   string // Human friendly alias
	CountInstances uint
}

ClusterInfo makes for a cluster status/info summary

func ReadClusterInfo added in v1.2.20

func ReadClusterInfo(clusterName string) (*ClusterInfo, error)

ReadClusterInfo reads some info about a given cluster

func ReadClustersInfo added in v1.1.2

func ReadClustersInfo() ([]ClusterInfo, error)

ReadClustersInfo reads names of all known clusters and some aggregated info

type HostnameResolve added in v1.2.12

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

type Instance

type Instance struct {
	Key                    InstanceKey
	ServerID               uint
	Version                string
	ReadOnly               bool
	Binlog_format          string
	LogBinEnabled          bool
	LogSlaveUpdatesEnabled bool
	SelfBinlogCoordinates  BinlogCoordinates
	MasterKey              InstanceKey
	Slave_SQL_Running      bool
	Slave_IO_Running       bool
	UsingOracleGTID        bool
	UsingMariaDBGTID       bool
	ReadBinlogCoordinates  BinlogCoordinates
	ExecBinlogCoordinates  BinlogCoordinates
	RelaylogCoordinates    BinlogCoordinates
	LastSQLError           string
	LastIOError            string
	SecondsBehindMaster    sql.NullInt64
	SlaveLagSeconds        sql.NullInt64
	SlaveHosts             InstanceKeyMap
	ClusterName            string

	IsLastCheckValid     bool
	IsUpToDate           bool
	IsRecentlyChecked    bool
	SecondsSinceLastSeen sql.NullInt64
	CountMySQLSnapshots  int
	// contains filtered or unexported fields
}

Instance represents a database instance, including its current configuration & status. It presents important replication configuration and detailed replication status.

func ChangeMasterTo

func ChangeMasterTo(instanceKey *InstanceKey, masterKey *InstanceKey, masterBinlogCoordinates *BinlogCoordinates) (*Instance, error)

ChangeMasterTo changes the given instance's master according to given input.

func EnslaveSiblingsSimple added in v1.3.6

func EnslaveSiblingsSimple(instanceKey *InstanceKey) (*Instance, int, error)

EnslaveSiblingsSimple is a convenience method for turning sublings of a slave to be its subordinates. This uses normal connected replication (does not utilize Pseudo-GTID)

func FindInstances added in v1.3.10

func FindInstances(regexpPattern string) ([](*Instance), error)

FindInstances reads all instances whose name matches given pattern

func GetInstanceMaster

func GetInstanceMaster(instance *Instance) (*Instance, error)

GetInstanceMaster synchronously reaches into the replication topology and retrieves master's data

func KillQuery added in v1.1.2

func KillQuery(instanceKey *InstanceKey, process int64) (*Instance, error)

KillQuery stops replication on a given instance

func MakeCoMaster added in v1.0.5

func MakeCoMaster(instanceKey *InstanceKey) (*Instance, error)

MakeCoMaster will attempt to make an instance co-master with its master, by making its master a slave of its own. This only works out if the master is not replicating; the master does not have a known master (it may have an unknown master).

func MakeLocalMaster added in v1.2.9

func MakeLocalMaster(instanceKey *InstanceKey) (*Instance, error)

MakeLocalMaster promotes a slave above its master, making it slave of its grandparent, while also enslaving its siblings. This serves as a convenience method to recover replication when a local master fails; the instance promoted is one of its slaves, which is most advanced among its siblings. This method utilizes Pseudo GTID

func MakeMaster added in v1.2.9

func MakeMaster(instanceKey *InstanceKey) (*Instance, error)

MakeMaster will take an instance, make all its siblings its slaves (via pseudo-GTID) and make it master (stop its replicaiton, make writeable).

func MasterPosWait

func MasterPosWait(instanceKey *InstanceKey, binlogCoordinates *BinlogCoordinates) (*Instance, error)

MasterPosWait issues a MASTER_POS_WAIT() an given instance according to given coordinates.

func MoveBelow

func MoveBelow(instanceKey, siblingKey *InstanceKey) (*Instance, error)

MoveBelow will attempt moving instance indicated by instanceKey below its supposed sibling indicated by sinblingKey. It will perform all safety and sanity checks and will tamper with this instance's replication as well as its sibling.

func MoveUp

func MoveUp(instanceKey *InstanceKey) (*Instance, error)

MoveUp will attempt moving instance indicated by instanceKey up the topology hierarchy. It will perform all safety and sanity checks and will tamper with this instance's replication as well as its master.

func NewInstance

func NewInstance() *Instance

NewInstance creates a new, empty instance

func PickAndPromoteCandidateSlave added in v1.3.6

func PickAndPromoteCandidateSlave(masterKey *InstanceKey) (*Instance, error)

PickAndPromoteCandidateSlave will choose a candidate slave

func ReadClusterInstances

func ReadClusterInstances(clusterName string) ([](*Instance), error)

ReadClusterInstances reads all instances of a given cluster

func ReadInstance

func ReadInstance(instanceKey *InstanceKey) (*Instance, bool, error)

ReadInstance reads an instance from the orchestrator backend database

func ReadProblemInstances

func ReadProblemInstances() ([](*Instance), error)

ReadProblemInstances reads all instances with problems

func ReadSlaveInstances added in v1.2.9

func ReadSlaveInstances(masterKey *InstanceKey) ([](*Instance), error)

ReadSlaveInstances reads slaves of a given master

func ReadTopologyInstance

func ReadTopologyInstance(instanceKey *InstanceKey) (*Instance, error)

ReadTopologyInstance connects to a topology MySQL instance and reads its configuration and replication status. It writes read info into orchestrator's backend.

func ReadUnseenInstances added in v1.3.10

func ReadUnseenInstances() ([](*Instance), error)

ReadUnseenInstances reads all instances which were not recently seen

func RefreshInstanceSlaveHosts added in v1.0.5

func RefreshInstanceSlaveHosts(instanceKey *InstanceKey) (*Instance, error)

RefreshInstanceSlaveHosts is a workaround for a bug in MySQL where SHOW SLAVE HOSTS continues to present old, long disconnected slaves. It turns out issuing a couple FLUSH commands mitigates the problem.

func RefreshTopologyInstance

func RefreshTopologyInstance(instanceKey *InstanceKey) (*Instance, error)

RefreshTopologyInstance will synchronuously re-read topology instance

func ResetSlave added in v1.1.11

func ResetSlave(instanceKey *InstanceKey) (*Instance, error)

ResetSlave resets a slave, breaking the replication

func ResetSlaveOperation added in v1.1.11

func ResetSlaveOperation(instanceKey *InstanceKey) (*Instance, error)

ResetSlaveOperation will reset a slave

func SearchInstances

func SearchInstances(searchString string) ([](*Instance), error)

SearchInstances reads all instances qualifying for some searchString

func SetReadOnly added in v1.1.11

func SetReadOnly(instanceKey *InstanceKey, readOnly bool) (*Instance, error)

SetReadOnly sets or clears the instance's global read_only variable

func StartSlave

func StartSlave(instanceKey *InstanceKey) (*Instance, error)

StartSlave starts replication on a given instance

func StartSlaveUntilMasterCoordinates

func StartSlaveUntilMasterCoordinates(instanceKey *InstanceKey, masterCoordinates *BinlogCoordinates) (*Instance, error)

StartSlaveUntilMasterCoordinates issuesa START SLAVE UNTIL... statement on given instance

func StopSlave

func StopSlave(instanceKey *InstanceKey) (*Instance, error)

StopSlave stops replication on a given instance

func StopSlaveNicely

func StopSlaveNicely(instanceKey *InstanceKey, timeout time.Duration) (*Instance, error)

StopSlaveNicely stops a slave such that SQL_thread and IO_thread are aligned (i.e. SQL_thread consumes all relay log entries) It will actually START the sql_thread even if the slave is completely stopped.

func (*Instance) AddSlaveKey

func (this *Instance) AddSlaveKey(slaveKey *InstanceKey)

AddSlaveKey adds a slave to the list of this instance's slaves.

func (*Instance) CanMove

func (this *Instance) 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 (*Instance) CanMoveAsCoMaster added in v1.0.5

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

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

func (*Instance) CanMoveViaMatch added in v1.2.9

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

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

func (*Instance) CanReplicateFrom

func (this *Instance) CanReplicateFrom(other *Instance) (bool, error)

CanReplicateFrom uses heursitics to decide whether this instacne can practically replicate from other instance. Checks are made to binlog format, version number, binary logs etc.

func (*Instance) Equals

func (this *Instance) Equals(other *Instance) bool

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

func (*Instance) GetBinaryLogs added in v1.2.9

func (this *Instance) GetBinaryLogs() []string

GetBinaryLogs returns the list of binary log names

func (*Instance) GetNextBinaryLog added in v1.2.9

func (this *Instance) GetNextBinaryLog(binlog string) (string, error)

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

func (*Instance) GetSlaveHostsAsJson

func (this *Instance) GetSlaveHostsAsJson() string

GetSlaveHostsAsJson Marshals slaves list a JSON

func (*Instance) HumanReadableDescription added in v1.3.10

func (this *Instance) HumanReadableDescription() string

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

func (*Instance) IsMasterOf

func (this *Instance) IsMasterOf(slave *Instance) bool

IsSlaveOf returns true if this i supposed master of given slave

func (*Instance) IsSlave

func (this *Instance) IsSlave() bool

IsSlave makes simple heuristics to decide whether this insatnce is a slave of another instance

func (*Instance) IsSlaveOf

func (this *Instance) IsSlaveOf(master *Instance) bool

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

func (*Instance) IsSmallerMajorVersion

func (this *Instance) IsSmallerMajorVersion(other *Instance) bool

MajorVersion tests this instance against another and returns true if this instance is of a smaller "major" varsion. e.g. 5.5.36 is NOT a smaller major version as comapred to 5.5.36, but IS as compared to 5.6.9

func (*Instance) MajorVersion

func (this *Instance) MajorVersion() []string

MajorVersion returns this instance's major version number (e.g. for 5.5.36 it returns "5.5")

func (*Instance) ReadSlaveHostsFromJson

func (this *Instance) ReadSlaveHostsFromJson(jsonString string) error

ReadSlaveHostsFromJson unmarshalls a json to read list of slaves

func (*Instance) SQLThreadUpToDate

func (this *Instance) SQLThreadUpToDate() bool

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

func (*Instance) SetBinaryLogs added in v1.2.9

func (this *Instance) SetBinaryLogs(binlogs []string)

SetBinaryLogs applies the binary logs list

func (*Instance) SlaveRunning

func (this *Instance) SlaveRunning() bool

SlaveRunning returns true when this instance's status is of a replicating slave.

func (*Instance) StatusString added in v1.3.10

func (this *Instance) StatusString() string

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

func (*Instance) UsingGTID added in v1.2.20

func (this *Instance) UsingGTID() bool

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

type InstanceKey

type InstanceKey struct {
	Hostname string
	Port     int
}

InstanceKey is an instance indicator, identifued by hostname and port

func NewInstanceKeyFromStrings

func NewInstanceKeyFromStrings(hostname string, port string) (*InstanceKey, error)

NewInstanceKeyFromStrings creates a new InstanceKey by resolving hostname and port. hostname is normalized via ResolveHostname. port is tested to be valid integer.

func ParseInstanceKey

func ParseInstanceKey(hostPort string) (*InstanceKey, error)

ParseInstanceKey will parse an InstanceKey from a string representation such as 127.0.0.1:3306

func ReadMaintenanceInstanceKey

func ReadMaintenanceInstanceKey(maintenanceToken int64) (*InstanceKey, error)

ReadMaintenanceInstanceKey will return the instanceKey for active maintenance by maintenanceToken

func ReadOutdatedInstanceKeys

func ReadOutdatedInstanceKeys() ([]InstanceKey, error)

ReadOutdatedInstanceKeys reads and returns keys for all instances that are not up to date (i.e. pre-configured time has passed since they were last cheked) But we also check for the case where an attempt at instance checking has been made, that hasn't resulted in an actual check! This can happen when TCP/IP connections are hung, in which case the "check" never returns. In such case we multiply interval by a factor, so as not to open too many connections on the instance.

func (*InstanceKey) DisplayString

func (this *InstanceKey) DisplayString() string

DisplayString returns a user-friendly string representation of this key

func (*InstanceKey) Equals

func (this *InstanceKey) Equals(other *InstanceKey) bool

Equals tests equality between this key and another key

func (*InstanceKey) Formalize

func (this *InstanceKey) Formalize() *InstanceKey

Formalize this key by getting CNAME for hostname

func (*InstanceKey) IsValid

func (this *InstanceKey) IsValid() bool

IsValid uses simple heuristics to see whether this key represents an actual instance

type InstanceKeyMap

type InstanceKeyMap map[InstanceKey]bool

InstanceKeyMap is a convenience struct for listing InstanceKey-s

func (*InstanceKeyMap) GetInstanceKeys

func (this *InstanceKeyMap) GetInstanceKeys() []InstanceKey

GetInstanceKeys returns keys in this map in the form of an array

func (*InstanceKeyMap) MarshalJSON

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

MarshalJSON will marshal this map as JSON

type InstancesByExecBinlogCoordinates added in v1.3.6

type InstancesByExecBinlogCoordinates [](*Instance)

func (InstancesByExecBinlogCoordinates) Len added in v1.3.6

func (InstancesByExecBinlogCoordinates) Less added in v1.3.6

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

func (InstancesByExecBinlogCoordinates) Swap added in v1.3.6

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

type Maintenance

type Maintenance struct {
	MaintenanceId  uint
	Key            InstanceKey
	BeginTimestamp string
	SecondsElapsed uint
	IsActive       bool
	Owner          string
	Reason         string
}

Maintenance indicates a maintenance entry (also in the database)

func ReadActiveMaintenance

func ReadActiveMaintenance() ([]Maintenance, error)

ReadActiveMaintenance returns the list of currently active maintenance entries

type Process added in v1.1.2

type Process struct {
	InstanceHostname string
	InstancePort     int
	Id               int64
	User             string
	Host             string
	Db               string
	Command          string
	Time             int64
	State            string
	Info             string
	StartedAt        string
}

Process presents a MySQL executing thread (as observed by PROCESSLIST)

func ReadLongRunningProcesses added in v1.1.2

func ReadLongRunningProcesses(filter string) ([]Process, error)

ReadLongRunningProcesses returns the list of current known long running processes of all instances

Jump to

Keyboard shortcuts

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