topology

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: 1 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChangeMasterTo

func ChangeMasterTo(instanceKey *dtstruct.InstanceKey, masterKey *dtstruct.InstanceKey, masterBinlogCoordinates *dtstruct.LogCoordinates, skipUnresolve bool, gtidHint string) (dtstruct.InstanceAdaptor, error)

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

func DetachMaster

func DetachMaster(instanceKey *dtstruct.InstanceKey) (dtstruct.InstanceAdaptor, error)

DetachMaster detaches a replica from its master by corrupting the upstream host (in such way that is reversible).

func GetCandidateReplica

GetCandidateReplica chooses the best replica to promote given a (possibly dead) master.

func MakeCoMaster

func MakeCoMaster(instanceKey *dtstruct.InstanceKey) (dtstruct.InstanceAdaptor, error)

MakeCoMaster will attempt to make an instance co-master with its master, by making its master a replica 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

func MakeLocalMaster(instanceKey *dtstruct.InstanceKey) (dtstruct.InstanceAdaptor, error)

MakeLocalMaster promotes a replica above its master, making it replica 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 replicas, which is most advanced among its siblings.

func MakeMaster

func MakeMaster(instanceKey *dtstruct.InstanceKey) (dtstruct.InstanceAdaptor, error)

MakeMaster will take an instance, make all its siblings its replicas and make it master (stop its replication, make writeable).

func MatchBelow

func MatchBelow(instanceKey, otherKey *dtstruct.InstanceKey, requireInstanceMaintenance bool) (dtstruct.InstanceAdaptor, *dtstruct.LogCoordinates, 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 actually 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 MatchUp

func MatchUp(instanceKey *dtstruct.InstanceKey, requireInstanceMaintenance bool) (dtstruct.InstanceAdaptor, *dtstruct.LogCoordinates, error)

MatchUp will move a replica up the replication chain, so that it becomes sibling of its master.

func MatchUpReplicas

func MatchUpReplicas(masterKey *dtstruct.InstanceKey, pattern string) ([]dtstruct.InstanceAdaptor, dtstruct.InstanceAdaptor, error, []error)

MatchUpReplicas will move all replicas of given master up the replication chain, so that they become siblings of their master. This should be called when the local master dies.

func MoveBelow

func MoveBelow(instanceKey, siblingKey *dtstruct.InstanceKey) (dtstruct.InstanceAdaptor, error)

MoveBelow will attempt moving instance indicated by instanceKey below its supposed sibling indicated by siblingKey. It will perform all safety and sanity checks and will tamper with this instance's replication as well as its sibling. e.g. if move below B1 to C1, will get new topology like this:

     C -->  A  <-- B <-- C1                C -->  A  <-- B <-- C1 <-- B1
		              ^            ----->
      			  |
	     			  B1

func MoveEquivalent

func MoveEquivalent(instanceKey, anotherKey *dtstruct.InstanceKey) (dtstruct.InstanceAdaptor, error)

MoveEquivalent will attempt moving instance indicated by instanceKey below another instance, based on known master coordinates equivalence. e.g. if move equivalent C1 to B, will get new topology like this:

     C -->  A  <-- B               C -->  A  <-- B <-- C1
		^             ^		----->           		^
     |			  |               	            |
	    C1			  B1	           	           B1

func MoveUp

func MoveUp(instanceKey *dtstruct.InstanceKey) (dtstruct.InstanceAdaptor, 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. e.g. if move up C1, will get new topology like this:

     C -->  A  <-- B                C -->  A  <-- B
		^             ^		----->            ^      ^
     |			  |                       |	     |
	    C1			  B1	                 C1	    B1

func MoveUpReplicas

func MoveUpReplicas(instanceKey *dtstruct.InstanceKey, pattern string) ([]dtstruct.InstanceAdaptor, dtstruct.InstanceAdaptor, error, []error)

MoveUpReplicas will attempt moving up all replicas of a given instance, at the same time. However this means all replicas of the given instance, and the instance itself, will all stop replicating together.

func MultiMatchBelow

func MultiMatchBelow(replicas []dtstruct.InstanceAdaptor, belowKey *dtstruct.InstanceKey, postponedFunctionsContainer *dtstruct.PostponedFunctionsContainer) (matchedReplicas []dtstruct.InstanceAdaptor, belowInstance dtstruct.InstanceAdaptor, err error, errs []error)

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

func MultiMatchReplicas

func MultiMatchReplicas(masterKey *dtstruct.InstanceKey, belowKey *dtstruct.InstanceKey, pattern string) ([]dtstruct.InstanceAdaptor, dtstruct.InstanceAdaptor, error, []error)

MultiMatchReplicas will match all replicas of given master below given instance.

func ReattachMaster

func ReattachMaster(instanceKey *dtstruct.InstanceKey) (dtstruct.InstanceAdaptor, error)

ReattachMaster reattaches a replica back onto its master by undoing a DetachMaster operation.

func RegroupReplicas

func RegroupReplicas(masterKey *dtstruct.InstanceKey, returnReplicaEvenOnFailureToRegroup bool, onCandidateReplicaChosen func(dtstruct.InstanceAdaptor), postponedFunctionsContainer *dtstruct.PostponedFunctionsContainer) (aheadReplicas []dtstruct.InstanceAdaptor, equalReplicas []dtstruct.InstanceAdaptor, laterReplicas []dtstruct.InstanceAdaptor, cannotReplicateReplicas []dtstruct.InstanceAdaptor, instance dtstruct.InstanceAdaptor, err error)

RegroupReplicas is a "smart" method of promoting one replica over the others ("promoting" it on top of its siblings).

func RelocateBelow

func RelocateBelow(instanceKey, otherKey *dtstruct.InstanceKey) (interface{}, error)

RelocateBelow will try and figure out the best way to move instance indicated by instanceKey below another instance.

func RelocateReplicas

func RelocateReplicas(instanceKey, otherKey *dtstruct.InstanceKey, pattern string) (replicas []dtstruct.InstanceAdaptor, other dtstruct.InstanceAdaptor, err error, errs []error)

RelocateReplicas will try and figure out the best way to move replicas of an instance indicated by instanceKey below another instance.

func RematchReplica

func RematchReplica(instanceKey *dtstruct.InstanceKey, requireInstanceMaintenance bool) (dtstruct.InstanceAdaptor, *dtstruct.LogCoordinates, error)

RematchReplica will re-match a replica to its master.

func Repoint

func Repoint(instanceKey *dtstruct.InstanceKey, masterKey *dtstruct.InstanceKey, gtidHint string) (dtstruct.InstanceAdaptor, error)

Repoint connects a replica to a master using its exact same executing coordinates. The given masterKey can be null, in which case the existing master is used.

func RepointReplicasTo

func RepointReplicasTo(instanceKey *dtstruct.InstanceKey, pattern string, belowKey *dtstruct.InstanceKey) ([]dtstruct.InstanceAdaptor, error, []error)

RepointReplicasTo repoints replicas of a given instance (possibly filtered) onto another master.

func TakeMaster

func TakeMaster(instanceKey *dtstruct.InstanceKey, allowTakingCoMaster bool) (dtstruct.InstanceAdaptor, error)

TakeMaster will move an instance up the chain and cause its master to become its replica. It's almost a role change, just that other replicas of either 'instance' or its master are currently unaffected (they continue replicate without change) Note that the master must itself be a replica; however the grandparent does not necessarily have to be reachable and can in fact be dead.

func TakeSiblings

func TakeSiblings(instanceKey *dtstruct.InstanceKey) (instance dtstruct.InstanceAdaptor, takenSiblings int, err error)

TakeSiblings is a convenience method for turning siblings of a replica to be its subordinates. This operation is a syntactic sugar on top relocate-replicas.

func Topology

func Topology(request *dtstruct.Request, historyTimestampPattern string, tabulated bool, printTag bool) (result interface{}, err error)

Topology returns a string representation of the topology of given cluster.

Types

This section is empty.

Jump to

Keyboard shortcuts

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