go-vitess.v1: gopkg.in/src-d/go-vitess.v1/vt/topotools Index | Files | Directories

package topotools

import "gopkg.in/src-d/go-vitess.v1/vt/topotools"

Package topotools contains high level functions based on vt/topo and vt/actionnode. It should not depend on anything else that's higher level. In particular, it cannot depend on: - vt/wrangler: much higher level, wrangler depends on topotools. - vt/tabletmanager/initiator: we don't want the various remote

protocol dependencies here.

topotools is used by wrangler, so it ends up in all tools using wrangler (vtctl, vtctld, ...). It is also included by vttablet, so it contains: - most of the logic to create a shard / keyspace (tablet's init code) - some of the logic to perform a TabletExternallyReparented (RPC call

to master vttablet to let it know it's the master).

Index

Package Files

rebuild_keyspace.go rebuild_vschema.go split.go tablet.go utils.go vschema_ddl.go

func ApplyVSchemaDDL Uses

func ApplyVSchemaDDL(ksName string, ks *vschemapb.Keyspace, ddl *sqlparser.DDL) (*vschemapb.Keyspace, error)

ApplyVSchemaDDL applies the given DDL statement to the vschema keyspace definition and returns the modified keyspace object.

func ChangeType Uses

func ChangeType(ctx context.Context, ts *topo.Server, tabletAlias *topodatapb.TabletAlias, newType topodatapb.TabletType) (*topodatapb.Tablet, error)

ChangeType changes the type of the tablet. Make this external, since these transitions need to be forced from time to time.

If successful, the updated tablet record is returned.

func CheckOwnership Uses

func CheckOwnership(oldTablet, newTablet *topodatapb.Tablet) error

CheckOwnership returns nil iff the Hostname and port match on oldTablet and newTablet, which implies that no other tablet process has taken over the record.

func ConfigureTabletHook Uses

func ConfigureTabletHook(hk *hook.Hook, tabletAlias *topodatapb.TabletAlias)

ConfigureTabletHook configures the right parameters for a hook running locally on a tablet.

func CopyMapKeys Uses

func CopyMapKeys(m interface{}, typeHint interface{}) interface{}

CopyMapKeys copies keys from from map m into a new slice with the type specified by typeHint. Reflection can't make a new slice type just based on the key type AFAICT.

func CopyMapValues Uses

func CopyMapValues(m interface{}, typeHint interface{}) interface{}

CopyMapValues copies values from from map m into a new slice with the type specified by typeHint. Reflection can't make a new slice type just based on the key type AFAICT.

func DeleteTablet Uses

func DeleteTablet(ctx context.Context, ts *topo.Server, tablet *topodatapb.Tablet) error

DeleteTablet removes a tablet record from the topology: - the replication data record if any - the tablet record

func FindTabletByHostAndPort Uses

func FindTabletByHostAndPort(tabletMap map[string]*topo.TabletInfo, addr, portName string, port int32) (*topodatapb.TabletAlias, error)

FindTabletByHostAndPort searches within a tablet map for tablets.

func GetAllTablets Uses

func GetAllTablets(ctx context.Context, ts *topo.Server, cell string) ([]*topo.TabletInfo, error)

GetAllTablets returns a sorted list of tablets.

func GetAllTabletsAcrossCells Uses

func GetAllTabletsAcrossCells(ctx context.Context, ts *topo.Server) ([]*topo.TabletInfo, error)

GetAllTabletsAcrossCells returns all tablets from known cells. If it returns topo.ErrPartialResult, then the list is valid, but partial.

func MapKeys Uses

func MapKeys(m interface{}) []interface{}

MapKeys returns an array with th provided map keys.

func RebuildKeyspace Uses

func RebuildKeyspace(ctx context.Context, log logutil.Logger, ts *topo.Server, keyspace string, cells []string) (err error)

RebuildKeyspace rebuilds the serving graph data while locking out other changes.

func RebuildKeyspaceLocked Uses

func RebuildKeyspaceLocked(ctx context.Context, log logutil.Logger, ts *topo.Server, keyspace string, cells []string) error

RebuildKeyspaceLocked should only be used with an action lock on the keyspace - otherwise the consistency of the serving graph data can't be guaranteed.

Take data from the global keyspace and rebuild the local serving copies in each cell.

func RebuildVSchema Uses

func RebuildVSchema(ctx context.Context, log logutil.Logger, ts *topo.Server, cells []string) error

RebuildVSchema rebuilds the SrvVSchema for the provided cell list (or all cells if cell list is empty).

func SortedTabletMap Uses

func SortedTabletMap(tabletMap map[string]*topo.TabletInfo) (map[string]*topo.TabletInfo, map[string]*topo.TabletInfo)

SortedTabletMap returns two maps: - The slaveMap contains all the non-master non-scrapped hosts.

This can be used as a list of slaves to fix up for reparenting

- The masterMap contains all the tablets without parents

(scrapped or not). This can be used to special case
the old master, and any tablet in a weird state, left over, ...

func TabletIdent Uses

func TabletIdent(tablet *topodatapb.Tablet) string

TabletIdent returns a concise string representation of this tablet.

func TargetIdent Uses

func TargetIdent(target *querypb.Target) string

TargetIdent returns a concise string representation of a query target

type OverlappingShards Uses

type OverlappingShards struct {
    Left  []*topo.ShardInfo
    Right []*topo.ShardInfo
}

OverlappingShards contains sets of shards that overlap which each-other. With this library, there is no guarantee of which set will be left or right.

func FindOverlappingShards Uses

func FindOverlappingShards(ctx context.Context, ts *topo.Server, keyspace string) ([]*OverlappingShards, error)

FindOverlappingShards will return an array of OverlappingShards for the provided keyspace. We do not support more than two overlapping shards (for instance, having 40-80, 40-60 and 40-50 in the same keyspace is not supported and will return an error). If shards don't perfectly overlap, they are not returned.

func OverlappingShardsForShard Uses

func OverlappingShardsForShard(os []*OverlappingShards, shardName string) *OverlappingShards

OverlappingShardsForShard returns the OverlappingShards object from the list that has he provided shard, or nil

func (*OverlappingShards) ContainsShard Uses

func (os *OverlappingShards) ContainsShard(shardName string) bool

ContainsShard returns true if either Left or Right lists contain the provided Shard.

Directories

PathSynopsis
eventsPackage events defines the structures used for events dispatched from the wrangler package.

Package topotools imports 19 packages (graph) and is imported by 20 packages. Updated 2019-06-13. Refresh now. Tools for package owners.