Documentation ¶
Index ¶
- Constants
- Variables
- func CloseServers()
- func CreateShard(ts Server, keyspace, shard string) error
- func CreateTablet(ts Server, tablet *Tablet) error
- func CreateTabletReplicationData(ts Server, tablet *Tablet) error
- func DecodeKeyspacePartitionMap(buf *bytes.Buffer, kind byte) map[TabletType]*KeyspacePartition
- func DeleteTabletReplicationData(ts Server, tablet *Tablet) error
- func EncodeKeyspacePartitionMap(buf *bytes2.ChunkedWriter, name string, ...)
- func EncodeSrvShardArray(buf *bytes2.ChunkedWriter, name string, values []SrvShard)
- func EncodeTabletTypeArray(buf *bytes2.ChunkedWriter, name string, values []TabletType)
- func EndPointEquality(left, right *EndPoint) bool
- func FindAllShardsInKeyspace(ts Server, keyspace string) (map[string]*ShardInfo, error)
- func GetSubprocessFlags() []string
- func IsInReplicationGraph(tt TabletType) bool
- func IsServingType(tt TabletType) bool
- func IsSlaveType(tt TabletType) bool
- func IsTrivialTypeChange(oldTabletType, newTabletType TabletType) bool
- func IsTypeInList(tabletType TabletType, types []TabletType) bool
- func IsValidTypeChange(oldTabletType, newTabletType TabletType) bool
- func LookupVtName(ts Server, cell, keyspace, shard string, tabletType TabletType, ...) ([]*net.SRV, error)
- func MakeStringTypeList(types []TabletType) []string
- func ParseUid(value string) (uint32, error)
- func RegisterServer(name string, ts Server)
- func RegisterTopoReader(tr TopoReader)
- func SrvAddr(srv *net.SRV) string
- func SrvEntries(addrs *EndPoints, namedPort string) (srvs []*net.SRV, err error)
- func UpdateTablet(ts Server, tablet *TabletInfo) error
- func Validate(ts Server, tabletAlias TabletAlias) error
- func ValidateShardName(shard string) (string, key.KeyRange, error)
- type EndPoint
- type EndPoints
- type GetEndPointsArgs
- type GetSrvKeyspaceArgs
- type GetSrvKeyspaceNamesArgs
- type KeyspacePartition
- type ReplicationLink
- type Server
- type Shard
- type ShardInfo
- type ShardReplication
- type ShardReplicationInfo
- type SourceShard
- type SrvKeyspace
- type SrvKeyspaceNames
- type SrvShard
- type SrvShardArray
- type Tablet
- func (tablet *Tablet) Alias() TabletAlias
- func (tablet *Tablet) Complete() error
- func (tablet *Tablet) DbName() string
- func (tablet *Tablet) Hostname() string
- func (tablet *Tablet) IsAssigned() bool
- func (tablet *Tablet) IsInReplicationGraph() bool
- func (tablet *Tablet) IsServingType() bool
- func (tablet *Tablet) IsSlaveType() bool
- func (tablet *Tablet) Json() string
- func (tablet *Tablet) String() string
- type TabletAlias
- type TabletAliasList
- type TabletInfo
- type TabletState
- type TabletType
- type TopoReader
Constants ¶
const ( // idle - no keyspace, shard or type assigned TYPE_IDLE = TabletType("idle") // primary copy of data TYPE_MASTER = TabletType("master") // a slaved copy of the data ready to be promoted to master TYPE_REPLICA = TabletType("replica") // a slaved copy of the data for olap load patterns. // too many aliases for olap - need to pick one TYPE_RDONLY = TabletType("rdonly") TYPE_BATCH = TabletType("batch") // a slaved copy of the data ready, but not serving query traffic // could be a potential master. TYPE_SPARE = TabletType("spare") // a slaved copy of the data ready, but not serving query traffic // implies something abnormal about the setup - don't consider it // a potential master and don't worry about lag when reparenting. TYPE_EXPERIMENTAL = TabletType("experimental") // a slaved copy of the data intentionally lagged for pseudo backup TYPE_LAG = TabletType("lag") // when a reparent occurs, the tablet goes into lag_orphan state until // it can be reparented properly TYPE_LAG_ORPHAN = TabletType("lag_orphan") // a slaved copy of the data that was serving but is now applying // a schema change. Will go bak to its serving type after the // upgrade TYPE_SCHEMA_UPGRADE = TabletType("schema_apply") // a slaved copy of the data, but offline to queries other than backup // replication sql thread may be stopped TYPE_BACKUP = TabletType("backup") // a slaved copy of the data, where mysqld is *not* running, // and we are serving our data files to clone slaves // use 'vtctl Snapshot -server-mode ...' to get in this mode // use 'vtctl SnapshotSourceEnd ...' to get out of this mode TYPE_SNAPSHOT_SOURCE = TabletType("snapshot_source") // A tablet that has not been in the replication graph and is restoring // from a snapshot. idle -> restore -> spare TYPE_RESTORE = TabletType("restore") // a machine with data that needs to be wiped TYPE_SCRAP = TabletType("scrap") )
const ( // The normal state for a master STATE_READ_WRITE = TabletState("ReadWrite") // The normal state for a slave, or temporarily a master. Not // to be confused with type, which implies a workload. STATE_READ_ONLY = TabletState("ReadOnly") )
const ( // DefaultPortName is the port named used by SrvEntries // if "" is given as the named port. DefaultPortName = "_vtocc" )
const ( // According to docs, the tablet uid / (mysql server id) is uint32. // However, zero appears to be a sufficiently degenerate value to use // as a marker for not having a parent server id. // http://dev.mysql.com/doc/refman/5.1/en/replication-options.html NO_TABLET = 0 )
Variables ¶
var ( // ErrNodeExists is returned by functions to specify the // requested resource already exists. ErrNodeExists = errors.New("node already exists") // ErrNoNode is returned by functions to specify the requested // resource does not exist. ErrNoNode = errors.New("node doesn't exist") // ErrNotEmpty is returned by functions to specify a child of the // resource is still present and prevents the action from completing. ErrNotEmpty = errors.New("node not empty") // ErrTimeout is returned by functions that wait for a result // when the timeout value is reached. ErrTimeout = errors.New("deadline exceeded") // ErrInterrupted is returned by functions that wait for a result // when they are interrupted. ErrInterrupted = errors.New("interrupted") // ErrBadVersion is returned by an update function that // failed to update the data because the version was different ErrBadVersion = errors.New("bad node version") // ErrPartialResult is returned by a function that could only // get a subset of its results ErrPartialResult = errors.New("partial result") )
var AllTabletTypes = []TabletType{TYPE_IDLE, TYPE_MASTER, TYPE_REPLICA, TYPE_RDONLY, TYPE_BATCH, TYPE_SPARE, TYPE_EXPERIMENTAL, TYPE_LAG, TYPE_LAG_ORPHAN, TYPE_SCHEMA_UPGRADE, TYPE_BACKUP, TYPE_SNAPSHOT_SOURCE, TYPE_RESTORE, TYPE_SCRAP, }
var SlaveTabletTypes = []TabletType{ TYPE_REPLICA, TYPE_RDONLY, TYPE_BATCH, TYPE_SPARE, TYPE_EXPERIMENTAL, TYPE_LAG, TYPE_LAG_ORPHAN, TYPE_SCHEMA_UPGRADE, TYPE_BACKUP, TYPE_SNAPSHOT_SOURCE, TYPE_RESTORE, }
Functions ¶
func CreateShard ¶
CreateShard creates a new shard and tries to fill in the right information.
func CreateTablet ¶
CreateTablet creates a new tablet and all associated paths for the replication graph.
func DecodeKeyspacePartitionMap ¶
func DecodeKeyspacePartitionMap(buf *bytes.Buffer, kind byte) map[TabletType]*KeyspacePartition
func DeleteTabletReplicationData ¶
DeleteTabletReplicationData deletes replication data.
func EncodeKeyspacePartitionMap ¶
func EncodeKeyspacePartitionMap(buf *bytes2.ChunkedWriter, name string, values map[TabletType]*KeyspacePartition)
func EncodeSrvShardArray ¶
func EncodeSrvShardArray(buf *bytes2.ChunkedWriter, name string, values []SrvShard)
func EncodeTabletTypeArray ¶
func EncodeTabletTypeArray(buf *bytes2.ChunkedWriter, name string, values []TabletType)
func EndPointEquality ¶
func FindAllShardsInKeyspace ¶
FindAllShardsInKeyspace reads and returns all the existing shards in a keyspace. It doesn't take any lock.
func GetSubprocessFlags ¶
func GetSubprocessFlags() []string
GetSubprocessFlags returns all the flags required to launch a subprocess with the exact same topology server as the current process.
func IsInReplicationGraph ¶
func IsInReplicationGraph(tt TabletType) bool
IsInReplicationGraph returns if this tablet appears in the replication graph Only IDLE and SCRAP are not in the replication graph. The other non-obvious types are BACKUP, SNAPSHOT_SOURCE, RESTORE and LAG_ORPHAN: these have had a master at some point (or were the master), so they are in the graph.
func IsServingType ¶
func IsServingType(tt TabletType) bool
IsServingType returns if a tablet appears in the serving graph
func IsSlaveType ¶
func IsSlaveType(tt TabletType) bool
IsSlaveType returns if this type should be connected to a master db and actively replicating? MASTER is not obviously (only support one level replication graph) IDLE and SCRAP are not either BACKUP, RESTORE, LAG_ORPHAN may or may not be, but we don't know for sure
func IsTrivialTypeChange ¶
func IsTrivialTypeChange(oldTabletType, newTabletType TabletType) bool
IsTrivialTypeChange returns if this db type be trivially reassigned without changes to the replication graph
func IsTypeInList ¶
func IsTypeInList(tabletType TabletType, types []TabletType) bool
IsTypeInList returns true if the given type is in the list. Use it with AllTabletType and SlaveTabletType for instance.
func IsValidTypeChange ¶
func IsValidTypeChange(oldTabletType, newTabletType TabletType) bool
IsValidTypeChange returns if we should we allow this transition at all. Most transitions are allowed, but some don't make sense under any circumstances. If a transistion could be forced, don't disallow it here.
func LookupVtName ¶
func MakeStringTypeList ¶
func MakeStringTypeList(types []TabletType) []string
MakeStringTypeList returns a list of strings that match the input list.
func RegisterServer ¶
RegisterServer adds an implementation for a Server. If an implementation with that name already exists, panics. Call this in the 'init' function in your module.
func RegisterTopoReader ¶
func RegisterTopoReader(tr TopoReader)
func SrvEntries ¶
FIXME(msolomon) merge with zkns
func UpdateTablet ¶
func UpdateTablet(ts Server, tablet *TabletInfo) error
UpdateTablet updates the tablet data only - not associated replication paths.
func Validate ¶
func Validate(ts Server, tabletAlias TabletAlias) error
Types ¶
type EndPoint ¶
type EndPoints ¶
type EndPoints struct {
Entries []EndPoint `json:"entries"`
}
func NewEndPoints ¶
func NewEndPoints() *EndPoints
NewEndPoints creates a EndPoints with a pre-allocated slice for Entries.
type GetEndPointsArgs ¶
type GetEndPointsArgs struct { Cell string Keyspace string Shard string TabletType TabletType }
type GetSrvKeyspaceArgs ¶
type GetSrvKeyspaceNamesArgs ¶
type GetSrvKeyspaceNamesArgs struct {
Cell string
}
type KeyspacePartition ¶
type KeyspacePartition struct { // List of non-overlapping continuous shards sorted by range. Shards []SrvShard }
KeyspacePartition represents a continuous set of shards to serve an entire data set.
func (*KeyspacePartition) MarshalBson ¶
func (kp *KeyspacePartition) MarshalBson(buf *bytes2.ChunkedWriter)
func (*KeyspacePartition) UnmarshalBson ¶
func (kp *KeyspacePartition) UnmarshalBson(buf *bytes.Buffer)
type ReplicationLink ¶
type ReplicationLink struct { TabletAlias TabletAlias Parent TabletAlias }
ReplicationLink describes a MySQL replication relationship
type Server ¶
type Server interface { // topo.Server management interface. Close() // GetKnownCells returns the list of known cells running our processes. // It is possible to find all tablets in the entire system // by then calling GetTabletsByCell on every cell, for instance. // They shall be sorted. GetKnownCells() ([]string, error) // CreateKeyspace creates the given keyspace, assuming it doesn't exist // yet. Can return ErrNodeExists if it already exists. CreateKeyspace(keyspace string) error // GetKeyspaces returns the known keyspaces. They shall be sorted. GetKeyspaces() ([]string, error) // DeleteKeyspaceShards deletes all the shards in a keyspace. // Use with caution. DeleteKeyspaceShards(keyspace string) error // CreateShard creates an empty shard, assuming it doesn't exist // yet. The contents of the shard will be a new Shard{} object, // with KeyRange populated by the result of ValidateShardName(). // Can return ErrNodeExists if it already exists. CreateShard(keyspace, shard string, value *Shard) error // UpdateShard unconditionnally updates the shard information // pointed at by si.keyspace / si.shard to the *si value. // This will only be called with a lock on the shard. // Can return ErrNoNode if the shard doesn't exist yet. UpdateShard(si *ShardInfo) error // ValidateShard performs routine checks on the shard. ValidateShard(keyspace, shard string) error // GetShard reads a shard and returns it. // Can return ErrNoNode GetShard(keyspace, shard string) (si *ShardInfo, err error) // GetShardNames returns the known shards in a keyspace. // Can return ErrNoNode if the keyspace wasn't created, // or if DeleteKeyspaceShards was called. They shall be sorted. GetShardNames(keyspace string) ([]string, error) // CreateTablet creates the given tablet, assuming it doesn't exist // yet. It does *not* create the tablet replication paths. // Can return ErrNodeExists if it already exists. CreateTablet(tablet *Tablet) error // UpdateTablet updates a given tablet. The version is used // for atomic updates. UpdateTablet will return ErrNoNode if // the tablet doesn't exist and ErrBadVersion if the version // has changed. UpdateTablet(tablet *TabletInfo, existingVersion int64) (newVersion int64, err error) // UpdateTabletFields updates the current tablet record // with new values, independently of the version // Can return ErrNoNode if the tablet doesn't exist. UpdateTabletFields(tabletAlias TabletAlias, update func(*Tablet) error) error // DeleteTablet removes a tablet from the system. // We assume no RPC is currently running to it. // TODO(alainjobart) verify this assumption, link with RPC code. // Can return ErrNoNode if the tablet doesn't exist. DeleteTablet(alias TabletAlias) error // ValidateTablet performs routine checks on the tablet. ValidateTablet(alias TabletAlias) error // GetTablet returns the tablet data (includes the current version). // Can return ErrNoNode if the tablet doesn't exist. GetTablet(alias TabletAlias) (*TabletInfo, error) // GetTabletsByCell returns all the tablets in the given cell. // Can return ErrNoNode if no tablet was ever created in that cell. GetTabletsByCell(cell string) ([]TabletAlias, error) // CreateShardReplication creates the ShardReplication object, // assuming it doesn't exist yet. // Can return ErrNodeExists if it already exists. CreateShardReplication(cell, keyspace, shard string, sr *ShardReplication) error // UpdateShardReplicationFields updates the current // ShardReplication record with new values // Can return ErrNoNode if the object doesn't exist. UpdateShardReplicationFields(cell, keyspace, shard string, update func(*ShardReplication) error) error // GetShardReplication returns the replication data. // Can return ErrNoNode if the object doesn't exist. GetShardReplication(cell, keyspace, shard string) (*ShardReplicationInfo, error) // DeleteShardReplication deletes the replication data. // Can return ErrNoNode if the object doesn't exist. DeleteShardReplication(cell, keyspace, shard string) error // GetSrvTabletTypesPerShard returns the existing serving types // for a shard. // Can return ErrNoNode. GetSrvTabletTypesPerShard(cell, keyspace, shard string) ([]TabletType, error) // UpdateEndPoints updates the serving records for a cell, // keyspace, shard, tabletType. UpdateEndPoints(cell, keyspace, shard string, tabletType TabletType, addrs *EndPoints) error // GetEndPoints returns the EndPoints list of serving addresses // for a TabletType inside a shard. // Can return ErrNoNode. GetEndPoints(cell, keyspace, shard string, tabletType TabletType) (*EndPoints, error) // DeleteSrvTabletType deletes the serving records for a cell, // keyspace, shard, tabletType. // Can return ErrNoNode. DeleteSrvTabletType(cell, keyspace, shard string, tabletType TabletType) error // UpdateSrvShard updates the serving records for a cell, // keyspace, shard. UpdateSrvShard(cell, keyspace, shard string, srvShard *SrvShard) error // GetSrvShard reads a SrvShard record. // Can return ErrNoNode. GetSrvShard(cell, keyspace, shard string) (*SrvShard, error) // UpdateSrvKeyspace updates the serving records for a cell, keyspace. UpdateSrvKeyspace(cell, keyspace string, srvKeyspace *SrvKeyspace) error // GetSrvKeyspace reads a SrvKeyspace record. // Can return ErrNoNode. GetSrvKeyspace(cell, keyspace string) (*SrvKeyspace, error) // GetSrvKeyspaceNames returns the list of visible Keyspaces // in this cell. They shall be sorted. GetSrvKeyspaceNames(cell string) ([]string, error) // UpdateTabletEndpoint updates a single tablet record in the // already computed serving graph. The update has to be somewhat // atomic, so it requires Server intrisic knowledge. // If the node doesn't exist, it is not updated, this is not an error. UpdateTabletEndpoint(cell, keyspace, shard string, tabletType TabletType, addr *EndPoint) error // LockKeyspaceForAction locks the keyspace in order to // perform the action described by contents. It will wait for // the lock for at most duration. The wait can be interrupted // if the interrupted channel is closed. It returns the lock // path. // Can return ErrTimeout or ErrInterrupted LockKeyspaceForAction(keyspace, contents string, timeout time.Duration, interrupted chan struct{}) (string, error) // UnlockKeyspaceForAction unlocks a keyspace. UnlockKeyspaceForAction(keyspace, lockPath, results string) error // LockShardForAction locks the shard in order to // perform the action described by contents. It will wait for // the lock for at most duration. The wait can be interrupted // if the interrupted channel is closed. It returns the lock // path. // Can return ErrTimeout or ErrInterrupted LockShardForAction(keyspace, shard, contents string, timeout time.Duration, interrupted chan struct{}) (string, error) // UnlockShardForAction unlocks a shard. UnlockShardForAction(keyspace, shard, lockPath, results string) error // WriteTabletAction initiates a remote action on the tablet. // Actions are queued up, and executed sequentially. An // action is identified by the returned string, actionPath. WriteTabletAction(tabletAlias TabletAlias, contents string) (string, error) // WaitForTabletAction waits for a tablet action to complete. It // will wait for the result for at most duration. The wait can // be interrupted if the interrupted channel is closed. // Can return ErrTimeout or ErrInterrupted WaitForTabletAction(actionPath string, waitTime time.Duration, interrupted chan struct{}) (string, error) // PurgeTabletActions removes all queued actions for a tablet. // This might break the locking mechanism of the remote action // queue, used with caution. PurgeTabletActions(tabletAlias TabletAlias, canBePurged func(data string) bool) error // ValidateTabletActions checks a tablet can execute remote // actions. ValidateTabletActions(tabletAlias TabletAlias) error // CreateTabletPidNode will keep a PID node up to date with // this tablet's current PID, until 'done' is closed. CreateTabletPidNode(tabletAlias TabletAlias, contents string, done chan struct{}) error // ValidateTabletPidNode makes sure a PID file exists for the tablet ValidateTabletPidNode(tabletAlias TabletAlias) error // GetSubprocessFlags returns the flags required to run a // subprocess that uses the same Server parameters as // this process. GetSubprocessFlags() []string // ActionEventLoop is the main loop for the action processing engine. // It will feed events to the dispatchAction callback. // If dispatchAction returns an error, we'll wait a bit before trying // again. // If 'done' is closed, the loop returns. ActionEventLoop(tabletAlias TabletAlias, dispatchAction func(actionPath, data string) error, done chan struct{}) // ReadTabletActionPath reads the actionPath and returns the // associated TabletAlias, the data (originally written by // WriteTabletAction), and its version ReadTabletActionPath(actionPath string) (TabletAlias, string, int64, error) // UpdateTabletAction updates the actionPath with the new data. // version is the current version we're expecting. Use -1 to set // any version. // Can return ErrBadVersion. UpdateTabletAction(actionPath, data string, version int64) error // StoreTabletActionResponse stores the data for the response. // This will not unblock the caller yet. StoreTabletActionResponse(actionPath, data string) error // UnblockTabletAction will let the client continue. // StoreTabletActionResponse must have been called already. UnblockTabletAction(actionPath string) error }
topo.Server is the interface used to talk to a persistent backend storage server and locking service.
Zookeeper is a good example of this, and zktopo contains the implementation for this using zookeeper.
Inside Google, we use Chubby.
func GetServer ¶
func GetServer() Server
GetServer returns 'our' Server, going down this list:
- If only one is registered, that's the one.
- If more than one are registered, use the 'topo_implementation' flag (which defaults to zookeeper).
- Then panics.
func GetServerByName ¶
Returns a specific Server by name, or nil.
type Shard ¶
type Shard struct { // There can be only at most one master, but there may be none. (0) MasterAlias TabletAlias // This must match the shard name based on our other conventions, but // helpful to have it decomposed here. KeyRange key.KeyRange // ServedTypes is a list of all the tablet types this shard will // serve. This is usually used with overlapping shards during // data shuffles like shard splitting. ServedTypes []TabletType // SourceShards is the list of shards we're replicating from, // using filtered replication. SourceShards []SourceShard // Cells is the list of cells that have tablets for this shard. // It is populated at InitTablet time when a tabelt is added // in a cell that is not in the list yet. Cells []string }
A pure data struct for information stored in topology server. This node is used to present a controlled view of the shard, unaware of every management action. It also contains configuration data for a shard.
type ShardInfo ¶
type ShardInfo struct { *Shard // contains filtered or unexported fields }
ShardInfo is a meta struct that contains metadata to give the data more context and convenience. This is the main way we interact with a shard.
func NewShardInfo ¶
NewShardInfo returns a ShardInfo basing on shard with the keyspace / shard. This function should be only used by Server implementations.
type ShardReplication ¶
type ShardReplication struct { // Note there can be only one ReplicationLink in this array // for a given Slave (each Slave can only have one parent) ReplicationLinks []ReplicationLink }
ShardReplication describes the MySQL replication relationships whithin a cell.
func (*ShardReplication) GetReplicationLink ¶
func (sr *ShardReplication) GetReplicationLink(tabletAlias TabletAlias) (ReplicationLink, error)
type ShardReplicationInfo ¶
type ShardReplicationInfo struct { *ShardReplication // contains filtered or unexported fields }
ShardReplicationInfo is the companion structure for ShardReplication.
func NewShardReplicationInfo ¶
func NewShardReplicationInfo(sr *ShardReplication, cell, keyspace, shard string) *ShardReplicationInfo
For topo.Server implementations to create the structure
func (*ShardReplicationInfo) Cell ¶
func (sri *ShardReplicationInfo) Cell() string
func (*ShardReplicationInfo) Keyspace ¶
func (sri *ShardReplicationInfo) Keyspace() string
func (*ShardReplicationInfo) Shard ¶
func (sri *ShardReplicationInfo) Shard() string
type SourceShard ¶
type SourceShard struct { // Uid is the unique ID for this SourceShard object. // It is for instance used as a unique index in blp_checkpoint // when storing the position. It should be unique whithin a // destination Shard, but not globally unique. Uid uint32 // the source keyspace Keyspace string // the source shard Shard string // the source shard keyrange KeyRange key.KeyRange }
SourceShard represents a data source for filtered replication accross shards. When this is used in a destination shard, the master of that shard will run filtered replication.
func (*SourceShard) String ¶
func (source *SourceShard) String() string
type SrvKeyspace ¶
type SrvKeyspace struct { // Shards to use per type, only contains complete partitions. Partitions map[TabletType]*KeyspacePartition // This list will be deprecated as soon as Partitions is used. // List of non-overlapping shards sorted by range. Shards []SrvShard // List of available tablet types for this keyspace in this cell. // May not have a server for every shard, but we have some. TabletTypes []TabletType // contains filtered or unexported fields }
A distilled serving copy of keyspace detail stored in the local cell for fast access. Derived from the global keyspace, shards and local details. In zk, it is in /zk/local/vt/ns/<keyspace>
func NewSrvKeyspace ¶
func NewSrvKeyspace(version int64) *SrvKeyspace
func (*SrvKeyspace) MarshalBson ¶
func (sk *SrvKeyspace) MarshalBson(buf *bytes2.ChunkedWriter)
func (*SrvKeyspace) UnmarshalBson ¶
func (sk *SrvKeyspace) UnmarshalBson(buf *bytes.Buffer)
type SrvKeyspaceNames ¶
type SrvKeyspaceNames struct {
Entries []string
}
type SrvShard ¶
type SrvShard struct { // Copied from Shard KeyRange key.KeyRange ServedTypes []TabletType // TabletTypes represents the list of types we have serving tablets // for, in this cell only. TabletTypes []TabletType // contains filtered or unexported fields }
SrvShard contains a roll-up of the shard in the local namespace. In zk, it is under /zk/local/vt/ns/<keyspace>/<shard>
func NewSrvShard ¶
func (*SrvShard) MarshalBson ¶
func (ss *SrvShard) MarshalBson(buf *bytes2.ChunkedWriter)
func (*SrvShard) UnmarshalBson ¶
type SrvShardArray ¶
type SrvShardArray []SrvShard
func (SrvShardArray) Len ¶
func (sa SrvShardArray) Len() int
func (SrvShardArray) Less ¶
func (sa SrvShardArray) Less(i, j int) bool
func (SrvShardArray) Sort ¶
func (sa SrvShardArray) Sort()
func (SrvShardArray) Swap ¶
func (sa SrvShardArray) Swap(i, j int)
type Tablet ¶
type Tablet struct { Cell string // the cell this tablet is assigned to (doesn't change) Uid uint32 // the server id for this instance Parent TabletAlias // the globally unique alias for our replication parent - zero if this is the global master Addr string // host:port for queryserver SecureAddr string // host:port for queryserver using encrypted connection MysqlAddr string // host:port for the mysql instance MysqlIpAddr string // ip:port for the mysql instance - needed to match slaves with tablets and preferable to relying on reverse dns Keyspace string Shard string Type TabletType State TabletState // Normally the database name is implied by "vt_" + keyspace. I // really want to remove this but there are some databases that are // hard to rename. DbNameOverride string KeyRange key.KeyRange }
Tablet is a pure data struct for information serialized into json and stored into topo.Server
func (*Tablet) Complete ¶
Complete validates and normalizes the tablet. If the shard name contains a '-' it is going to try to infer the keyrange from it.
func (*Tablet) DbName ¶
DbName is usually implied by keyspace. Having the shard information in the database name complicates mysql replication.
func (*Tablet) IsAssigned ¶
Was this tablet ever assigned data? A "scrap" node will show up as assigned even though its data cannot be used for serving.
func (*Tablet) IsInReplicationGraph ¶
func (*Tablet) IsServingType ¶
func (*Tablet) IsSlaveType ¶
type TabletAlias ¶
TabletAlias is the minimum required information to locate a tablet.
Tablets are really globally unique, but crawling every cell to find out where it lives is time consuming and expensive. This is only needed during complex operations. Tablet cell assignments don't change that often, thus using a TabletAlias is efficient.
func FindAllTabletAliasesInShard ¶
func FindAllTabletAliasesInShard(ts Server, keyspace, shard string) ([]TabletAlias, error)
FindAllTabletAliasesInShard uses the replication graph to find all the tablet aliases in the given shard. It can return ErrPartialResult if some cells were not fetched, in which case the result only contains the cells that were fetched.
func ParseTabletAliasString ¶
func ParseTabletAliasString(aliasStr string) (result TabletAlias, err error)
func (TabletAlias) IsZero ¶
func (ta TabletAlias) IsZero() bool
func (TabletAlias) String ¶
func (ta TabletAlias) String() string
func (TabletAlias) TabletUidStr ¶
func (ta TabletAlias) TabletUidStr() string
type TabletAliasList ¶
type TabletAliasList []TabletAlias
TabletAliasList is used mainly for sorting
func (TabletAliasList) Len ¶
func (tal TabletAliasList) Len() int
func (TabletAliasList) Less ¶
func (tal TabletAliasList) Less(i, j int) bool
func (TabletAliasList) Swap ¶
func (tal TabletAliasList) Swap(i, j int)
type TabletInfo ¶
type TabletInfo struct { *Tablet // contains filtered or unexported fields }
func NewTabletInfo ¶
func NewTabletInfo(tablet *Tablet, version int64) *TabletInfo
NewTabletInfo returns a TabletInfo basing on tablet with the version set. This function should be only used by Server implementations.
func (*TabletInfo) Path ¶
func (ti *TabletInfo) Path() string
FIXME(alainjobart) when switch to topo.Server this will become useless
func (*TabletInfo) Version ¶
func (ti *TabletInfo) Version() int64
type TabletState ¶
type TabletState string
TabletState describe if the tablet is read-only or read-write.
type TabletType ¶
type TabletType string
TabletType is the main type for a tablet. It has an implication on: - the replication graph - the services run by vttablet on a tablet - the uptime expectancy
func DecodeTabletTypeArray ¶
func DecodeTabletTypeArray(buf *bytes.Buffer, kind byte) []TabletType
func (TabletType) IsSlaveType ¶
func (tt TabletType) IsSlaveType() bool
type TopoReader ¶
type TopoReader interface { // GetSrvKeyspaces returns the names of all the keyspaces in // the topology for the cell. GetSrvKeyspaceNames(GetSrvKeyspaceNamesArgs, *SrvKeyspaceNames) error // GetSrvKeyspace returns information about a keyspace in a // particular cell (as specified by the GetSrvKeyspaceArgs). GetSrvKeyspace(GetSrvKeyspaceArgs, *SrvKeyspace) error // GetEndPoints returns addresses for a tablet type in a shard // in a keyspace (as specified in GetEndPointsArgs). GetEndPoints(GetEndPointsArgs, *EndPoints) error }
TopoReader returns read only information about the topology.