tabletmanager

package
v0.0.0-...-8e4f697 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2013 License: BSD-3-Clause Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FIXME(msolomon) why is ActionState a type, but Action is not?
	TABLET_ACTION_PING  = "Ping"
	TABLET_ACTION_SLEEP = "Sleep"

	TABLET_ACTION_SET_RDONLY  = "SetReadOnly"
	TABLET_ACTION_SET_RDWR    = "SetReadWrite"
	TABLET_ACTION_CHANGE_TYPE = "ChangeType"

	TABLET_ACTION_DEMOTE_MASTER       = "DemoteMaster"
	TABLET_ACTION_PROMOTE_SLAVE       = "PromoteSlave"
	TABLET_ACTION_SLAVE_WAS_PROMOTED  = "SlaveWasPromoted"
	TABLET_ACTION_RESTART_SLAVE       = "RestartSlave"
	TABLET_ACTION_SLAVE_WAS_RESTARTED = "SlaveWasRestarted"
	TABLET_ACTION_STOP_SLAVE          = "StopSlave"
	TABLET_ACTION_BREAK_SLAVES        = "BreakSlaves"
	TABLET_ACTION_MASTER_POSITION     = "MasterPosition"
	TABLET_ACTION_REPARENT_POSITION   = "ReparentPosition"
	TABLET_ACTION_SLAVE_POSITION      = "SlavePosition"
	TABLET_ACTION_WAIT_SLAVE_POSITION = "WaitSlavePosition"
	TABLET_ACTION_SCRAP               = "Scrap"
	TABLET_ACTION_GET_SCHEMA          = "GetSchema"
	TABLET_ACTION_PREFLIGHT_SCHEMA    = "PreflightSchema"
	TABLET_ACTION_APPLY_SCHEMA        = "ApplySchema"
	TABLET_ACTION_GET_PERMISSIONS     = "GetPermissions"
	TABLET_ACTION_EXECUTE_HOOK        = "ExecuteHook"
	TABLET_ACTION_GET_SLAVES          = "GetSlaves"

	TABLET_ACTION_SNAPSHOT            = "Snapshot"
	TABLET_ACTION_SNAPSHOT_SOURCE_END = "SnapshotSourceEnd"
	TABLET_ACTION_RESERVE_FOR_RESTORE = "ReserveForRestore"
	TABLET_ACTION_RESTORE             = "Restore"
	TABLET_ACTION_PARTIAL_SNAPSHOT    = "PartialSnapshot"
	TABLET_ACTION_MULTI_SNAPSHOT      = "MultiSnapshot"
	TABLET_ACTION_PARTIAL_RESTORE     = "PartialRestore"
	TABLET_ACTION_MULTI_RESTORE       = "MultiRestore"

	// Shard actions - involve all tablets in a shard
	SHARD_ACTION_REPARENT              = "ReparentShard"
	SHARD_ACTION_EXTERNALLY_REPARENTED = "ShardExternallyReparented"
	// Recompute derived shard-wise data
	SHARD_ACTION_REBUILD = "RebuildShard"
	// Generic read lock for inexpensive shard-wide actions.
	SHARD_ACTION_CHECK = "CheckShard"
	// Apply a schema change on an entire shard
	SHARD_ACTION_APPLY_SCHEMA = "ApplySchemaShard"

	// Keyspace actions - require very high level locking for consistency
	KEYSPACE_ACTION_REBUILD      = "RebuildKeyspace"
	KEYSPACE_ACTION_APPLY_SCHEMA = "ApplySchemaKeyspace"

	ACTION_STATE_QUEUED  = ActionState("")        // All actions are queued initially
	ACTION_STATE_RUNNING = ActionState("Running") // Running inside vtaction process
	ACTION_STATE_FAILED  = ActionState("Failed")  // Ended with a failure
	ACTION_STATE_DONE    = ActionState("Done")    // Ended with no failure
)

Variables

This section is empty.

Functions

func ActionNodeCanBePurged

func ActionNodeCanBePurged(data string) bool

func ActionNodeIsStale

func ActionNodeIsStale(data string) bool

func ActionNodeToJson

func ActionNodeToJson(n *ActionNode) string

func BackfillAlias

func BackfillAlias(zkPath string, alias *topo.TabletAlias) error

FIXME(alainjobart) remove after migration

func ChangeType

func ChangeType(ts topo.Server, tabletAlias topo.TabletAlias, newType topo.TabletType, runHooks bool) error

Make this external, since these transitions need to be forced from time to time.

func Scrap

func Scrap(ts topo.Server, tabletAlias topo.TabletAlias, force bool) error

Make this external, since in needs to be forced from time to time.

func SignalInterrupt

func SignalInterrupt()

In certain cases (vtctl most notably) having SIGINT manifest itself as an instant timeout lets us break out cleanly.

func StoreActionResponse

func StoreActionResponse(ts topo.Server, actionNode *ActionNode, actionPath string, actionErr error) error

Write the result of an action into topology server

func VtnsAddrForTablet

func VtnsAddrForTablet(tablet *topo.Tablet) (*topo.VtnsAddr, error)

func WaitForCompletion

func WaitForCompletion(ts topo.Server, actionPath string, waitTime time.Duration) (interface{}, error)

Types

type ActionAgent

type ActionAgent struct {
	MycnfFile         string // my.cnf file
	DbConfigsFile     string // File that contains db connection configs
	DbCredentialsFile string // File that contains db connection configs
	// contains filtered or unexported fields
}

func NewActionAgent

func NewActionAgent(topoServer topo.Server, tabletAlias topo.TabletAlias, mycnfFile, dbConfigsFile, dbCredentialsFile string) (*ActionAgent, error)

func (*ActionAgent) AddChangeCallback

func (agent *ActionAgent) AddChangeCallback(f TabletChangeCallback)

func (*ActionAgent) RegisterQueryService

func (agent *ActionAgent) RegisterQueryService(mysqld *mysqlctl.Mysqld)

func (*ActionAgent) Start

func (agent *ActionAgent) Start(bindAddr, secureAddr, mysqlAddr string) error

bindAddr: the address for the query service advertised by this agent

func (*ActionAgent) Stop

func (agent *ActionAgent) Stop()

func (*ActionAgent) Tablet

func (agent *ActionAgent) Tablet() *topo.TabletInfo

type ActionInitiator

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

func NewActionInitiator

func NewActionInitiator(ts topo.Server) *ActionInitiator

func (*ActionInitiator) ApplySchema

func (ai *ActionInitiator) ApplySchema(tabletAlias topo.TabletAlias, sc *mysqlctl.SchemaChange) (actionPath string, err error)

func (*ActionInitiator) ApplySchemaKeyspace

func (ai *ActionInitiator) ApplySchemaKeyspace(change string, simple bool) *ActionNode

func (*ActionInitiator) ApplySchemaShard

func (ai *ActionInitiator) ApplySchemaShard(masterTabletAlias topo.TabletAlias, change string, simple bool) *ActionNode

func (*ActionInitiator) BreakSlaves

func (ai *ActionInitiator) BreakSlaves(tabletAlias topo.TabletAlias) (actionPath string, err error)

func (*ActionInitiator) ChangeType

func (ai *ActionInitiator) ChangeType(tabletAlias topo.TabletAlias, dbType topo.TabletType) (actionPath string, err error)

func (*ActionInitiator) CheckShard

func (ai *ActionInitiator) CheckShard() *ActionNode

func (*ActionInitiator) DemoteMaster

func (ai *ActionInitiator) DemoteMaster(tabletAlias topo.TabletAlias) (actionPath string, err error)

func (*ActionInitiator) ExecuteHook

func (ai *ActionInitiator) ExecuteHook(tabletAlias topo.TabletAlias, _hook *hook.Hook) (actionPath string, err error)

func (*ActionInitiator) GetSchema

func (ai *ActionInitiator) GetSchema(tabletAlias topo.TabletAlias, tables []string, includeViews bool) (actionPath string, err error)

func (*ActionInitiator) GetSlaves

func (ai *ActionInitiator) GetSlaves(tabletAlias topo.TabletAlias) (actionPath string, err error)

func (*ActionInitiator) MasterPosition

func (ai *ActionInitiator) MasterPosition(tabletAlias topo.TabletAlias) (actionPath string, err error)

func (*ActionInitiator) MultiSnapshot

func (ai *ActionInitiator) MultiSnapshot(tabletAlias topo.TabletAlias, args *MultiSnapshotArgs) (actionPath string, err error)

func (*ActionInitiator) PartialRestore

func (ai *ActionInitiator) PartialRestore(dstTabletAlias topo.TabletAlias, args *RestoreArgs) (actionPath string, err error)

func (*ActionInitiator) PartialSnapshot

func (ai *ActionInitiator) PartialSnapshot(tabletAlias topo.TabletAlias, args *PartialSnapshotArgs) (actionPath string, err error)

func (*ActionInitiator) Ping

func (ai *ActionInitiator) Ping(tabletAlias topo.TabletAlias) (actionPath string, err error)

func (*ActionInitiator) PreflightSchema

func (ai *ActionInitiator) PreflightSchema(tabletAlias topo.TabletAlias, change string) (actionPath string, err error)

func (*ActionInitiator) PromoteSlave

func (ai *ActionInitiator) PromoteSlave(tabletAlias topo.TabletAlias) (actionPath string, err error)

func (*ActionInitiator) RebuildKeyspace

func (ai *ActionInitiator) RebuildKeyspace() *ActionNode

func (*ActionInitiator) RebuildShard

func (ai *ActionInitiator) RebuildShard() *ActionNode

func (*ActionInitiator) ReparentPosition

func (ai *ActionInitiator) ReparentPosition(tabletAlias topo.TabletAlias, slavePos *mysqlctl.ReplicationPosition) (actionPath string, err error)

func (*ActionInitiator) ReparentShard

func (ai *ActionInitiator) ReparentShard(tabletAlias topo.TabletAlias) *ActionNode

func (*ActionInitiator) ReserveForRestore

func (ai *ActionInitiator) ReserveForRestore(dstTabletAlias topo.TabletAlias, args *ReserveForRestoreArgs) (actionPath string, err error)

func (*ActionInitiator) RestartSlave

func (ai *ActionInitiator) RestartSlave(tabletAlias topo.TabletAlias, args *RestartSlaveData) (actionPath string, err error)

func (*ActionInitiator) Restore

func (ai *ActionInitiator) Restore(dstTabletAlias topo.TabletAlias, args *RestoreArgs) (actionPath string, err error)

func (*ActionInitiator) RestoreFromMultiSnapshot

func (ai *ActionInitiator) RestoreFromMultiSnapshot(tabletAlias topo.TabletAlias, args *MultiRestoreArgs) (actionPath string, err error)

func (*ActionInitiator) RpcGetPermissions

func (ai *ActionInitiator) RpcGetPermissions(tabletAlias topo.TabletAlias, waitTime time.Duration) (*mysqlctl.Permissions, error)

func (*ActionInitiator) RpcGetSchemaTablet

func (ai *ActionInitiator) RpcGetSchemaTablet(tablet *topo.TabletInfo, tables []string, includeViews bool, waitTime time.Duration) (*mysqlctl.SchemaDefinition, error)

func (*ActionInitiator) RpcPing

func (ai *ActionInitiator) RpcPing(tabletAlias topo.TabletAlias, waitTime time.Duration) error

func (*ActionInitiator) Scrap

func (ai *ActionInitiator) Scrap(tabletAlias topo.TabletAlias) (actionPath string, err error)

func (*ActionInitiator) SetReadOnly

func (ai *ActionInitiator) SetReadOnly(tabletAlias topo.TabletAlias) (actionPath string, err error)

func (*ActionInitiator) SetReadWrite

func (ai *ActionInitiator) SetReadWrite(tabletAlias topo.TabletAlias) (actionPath string, err error)

func (*ActionInitiator) ShardExternallyReparented

func (ai *ActionInitiator) ShardExternallyReparented(tabletAlias topo.TabletAlias) *ActionNode

func (*ActionInitiator) SlavePosition

func (ai *ActionInitiator) SlavePosition(tabletAlias topo.TabletAlias) (actionPath string, err error)

func (*ActionInitiator) SlaveWasPromoted

func (ai *ActionInitiator) SlaveWasPromoted(tabletAlias topo.TabletAlias) (actionPath string, err error)

func (*ActionInitiator) SlaveWasRestarted

func (ai *ActionInitiator) SlaveWasRestarted(tabletAlias topo.TabletAlias, args *SlaveWasRestartedData) (actionPath string, err error)

func (*ActionInitiator) Sleep

func (ai *ActionInitiator) Sleep(tabletAlias topo.TabletAlias, duration time.Duration) (actionPath string, err error)

func (*ActionInitiator) Snapshot

func (ai *ActionInitiator) Snapshot(tabletAlias topo.TabletAlias, args *SnapshotArgs) (actionPath string, err error)

func (*ActionInitiator) SnapshotSourceEnd

func (ai *ActionInitiator) SnapshotSourceEnd(tabletAlias topo.TabletAlias, args *SnapshotSourceEndArgs) (actionPath string, err error)

func (*ActionInitiator) StopSlave

func (ai *ActionInitiator) StopSlave(tabletAlias topo.TabletAlias) (actionPath string, err error)

func (*ActionInitiator) WaitForCompletion

func (ai *ActionInitiator) WaitForCompletion(actionPath string, waitTime time.Duration) error

func (*ActionInitiator) WaitForCompletionReply

func (ai *ActionInitiator) WaitForCompletionReply(actionPath string, waitTime time.Duration) (interface{}, error)

func (*ActionInitiator) WaitSlavePosition

func (ai *ActionInitiator) WaitSlavePosition(tabletAlias topo.TabletAlias, args *SlavePositionReq) (actionPath string, err error)

type ActionNode

type ActionNode struct {
	Action     string
	ActionGuid string
	Error      string
	State      ActionState
	Pid        int // only != 0 if State == ACTION_STATE_RUNNING
	// contains filtered or unexported fields
}

func ActionNodeFromJson

func ActionNodeFromJson(data, path string) (*ActionNode, error)

func (*ActionNode) Path

func (n *ActionNode) Path() string

type ActionState

type ActionState string

type ApplySchemaKeyspaceArgs

type ApplySchemaKeyspaceArgs struct {
	Change string
	Simple bool
}

parameters are stored for debug purposes

type ApplySchemaShardArgs

type ApplySchemaShardArgs struct {
	MasterTabletAlias topo.TabletAlias
	Change            string
	Simple            bool
}

parameters are stored for debug purposes

type GetSchemaArgs

type GetSchemaArgs struct {
	Tables       []string
	IncludeViews bool
}

type InitiatorError

type InitiatorError string

func (InitiatorError) Error

func (e InitiatorError) Error() string

type MultiRestoreArgs

type MultiRestoreArgs struct {
	SrcTabletAliases       []topo.TabletAlias
	Concurrency            int
	FetchConcurrency       int
	InsertTableConcurrency int
	FetchRetryCount        int
	Strategy               string
}

type MultiSnapshotArgs

type MultiSnapshotArgs struct {
	KeyName          string
	KeyRanges        []key.KeyRange
	Tables           []string
	Concurrency      int
	SkipSlaveRestart bool
	MaximumFilesize  uint64
}

type MultiSnapshotReply

type MultiSnapshotReply struct {
	ParentAlias   topo.TabletAlias
	ManifestPaths []string
}

type PartialSnapshotArgs

type PartialSnapshotArgs struct {
	KeyName     string
	StartKey    key.HexKeyspaceId
	EndKey      key.HexKeyspaceId
	Concurrency int
}

type ReserveForRestoreArgs

type ReserveForRestoreArgs struct {
	ZkSrcTabletPath string // XXX
	SrcTabletAlias  topo.TabletAlias
}

type RestartSlaveData

type RestartSlaveData struct {
	ReplicationState *mysqlctl.ReplicationState
	WaitPosition     *mysqlctl.ReplicationPosition
	TimePromoted     int64 // used to verify replication - a row will be inserted with this timestamp
	Parent           topo.TabletAlias
	Force            bool
}

func (*RestartSlaveData) String

func (rsd *RestartSlaveData) String() string

type RestoreArgs

type RestoreArgs struct {
	ZkSrcTabletPath       string // XXX
	SrcTabletAlias        topo.TabletAlias
	SrcFilePath           string
	ZkParentPath          string // XXX
	ParentAlias           topo.TabletAlias
	FetchConcurrency      int
	FetchRetryCount       int
	WasReserved           bool
	DontWaitForSlaveStart bool
}

used for both Restore and PartialRestore

type SlaveList

type SlaveList struct {
	Addrs []string
}

type SlavePositionReq

type SlavePositionReq struct {
	ReplicationPosition mysqlctl.ReplicationPosition
	WaitTimeout         int // seconds, zero to wait indefinitely
}

type SlaveWasRestartedData

type SlaveWasRestartedData struct {
	Parent               topo.TabletAlias
	ExpectedMasterAddr   string
	ExpectedMasterIpAddr string
	ScrapStragglers      bool
}

type SnapshotArgs

type SnapshotArgs struct {
	Concurrency int
	ServerMode  bool
}

type SnapshotReply

type SnapshotReply struct {
	ZkParentPath string // XXX
	ParentAlias  topo.TabletAlias
	ManifestPath string

	// these two are only used for ServerMode=true full snapshot
	SlaveStartRequired bool
	ReadOnly           bool
}

used by both Snapshot and PartialSnapshot

type SnapshotSourceEndArgs

type SnapshotSourceEndArgs struct {
	SlaveStartRequired bool
	ReadOnly           bool
}

type TabletActor

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

func NewTabletActor

func NewTabletActor(mysqld *mysqlctl.Mysqld, topoServer topo.Server) *TabletActor

func (*TabletActor) HandleAction

func (ta *TabletActor) HandleAction(actionPath, action, actionGuid string, forceRerun bool) error

This function should be protected from unforseen panics, as dispatchAction will catch everything. The rest of the code in this function should not panic.

type TabletActorError

type TabletActorError string

func (TabletActorError) Error

func (e TabletActorError) Error() string

type TabletChangeCallback

type TabletChangeCallback func(oldTablet, newTablet topo.Tablet)

Each TabletChangeCallback must be idempotent and "threadsafe". The agent will execute these in a new goroutine each time a change is triggered.

type TabletManager

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

we keep track of the agent so we can use its tabletAlias, ts, ...

var TabletManagerRpcService *TabletManager

func (*TabletManager) GetPermissions

func (tm *TabletManager) GetPermissions(context *rpcproto.Context, args *rpc.UnusedRequest, reply *mysqlctl.Permissions) error

func (*TabletManager) GetSchema

func (tm *TabletManager) GetSchema(context *rpcproto.Context, args *GetSchemaArgs, reply *mysqlctl.SchemaDefinition) error

func (*TabletManager) GetSlaves

func (tm *TabletManager) GetSlaves(context *rpcproto.Context, args *rpc.UnusedRequest, reply *SlaveList) (err error)

func (*TabletManager) MasterPosition

func (tm *TabletManager) MasterPosition(context *rpcproto.Context, args *rpc.UnusedRequest, reply *mysqlctl.ReplicationPosition) error

func (*TabletManager) Ping

func (tm *TabletManager) Ping(context *rpcproto.Context, args, reply *string) error

func (*TabletManager) SlavePosition

func (tm *TabletManager) SlavePosition(context *rpcproto.Context, args *rpc.UnusedRequest, reply *mysqlctl.ReplicationPosition) error

func (*TabletManager) StopSlave

func (tm *TabletManager) StopSlave(context *rpcproto.Context, args *rpc.UnusedRequest, reply *rpc.UnusedResponse) error

func (*TabletManager) WaitSlavePosition

func (tm *TabletManager) WaitSlavePosition(context *rpcproto.Context, args *SlavePositionReq, reply *mysqlctl.ReplicationPosition) error

Jump to

Keyboard shortcuts

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