actionnode

package
v0.0.0-...-4754828 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2014 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	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_SET_BLACKLISTED_TABLES = "SetBlacklistedTables"

	TABLET_ACTION_DEMOTE_MASTER = "DemoteMaster"
	TABLET_ACTION_PROMOTE_SLAVE = "PromoteSlave"

	// SlaveWasPromoted tells a tablet this previously slave
	// tablet is now the master. The tablet will update its
	// own topology record.
	TABLET_ACTION_SLAVE_WAS_PROMOTED = "SlaveWasPromoted"

	TABLET_ACTION_RESTART_SLAVE = "RestartSlave"

	// SlaveWasRestarted tells a tablet the mysql master was changed.
	// The tablet will check it is indeed the case, and update its own
	// topology record.
	TABLET_ACTION_SLAVE_WAS_RESTARTED = "SlaveWasRestarted"

	// StopSlave will stop MySQL replication.
	TABLET_ACTION_STOP_SLAVE = "StopSlave"

	// StopSlave will stop MySQL replication after it reaches a
	// minimum point.
	TABLET_ACTION_STOP_SLAVE_MINIMUM = "StopSlaveMinimum"

	// StartSlave will start MySQL replication.
	TABLET_ACTION_START_SLAVE = "StartSlave"

	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_WAIT_BLP_POSITION   = "WaitBlpPosition"
	TABLET_ACTION_STOP_BLP            = "StopBlp"
	TABLET_ACTION_START_BLP           = "StartBlp"
	TABLET_ACTION_RUN_BLP_UNTIL       = "RunBlpUntil"
	TABLET_ACTION_SCRAP               = "Scrap"
	TABLET_ACTION_GET_SCHEMA          = "GetSchema"
	TABLET_ACTION_PREFLIGHT_SCHEMA    = "PreflightSchema"
	TABLET_ACTION_APPLY_SCHEMA        = "ApplySchema"
	TABLET_ACTION_RELOAD_SCHEMA       = "ReloadSchema"
	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_MULTI_SNAPSHOT      = "MultiSnapshot"
	TABLET_ACTION_MULTI_RESTORE       = "MultiRestore"

	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"
	// Changes the ServedTypes inside a shard
	SHARD_ACTION_SET_SERVED_TYPES = "SetShardServedTypes"
	// Multi-restore on all tablets of a shard in parallel
	SHARD_ACTION_MULTI_RESTORE = "ShardMultiRestore"
	// Migrate served types from one shard to another
	SHARD_ACTION_MIGRATE_SERVED_TYPES = "MigrateServedTypes"
	// Update the Shard object (Cells, ...)
	SHARD_ACTION_UPDATE_SHARD = "UpdateShard"

	KEYSPACE_ACTION_REBUILD             = "RebuildKeyspace"
	KEYSPACE_ACTION_APPLY_SCHEMA        = "ApplySchemaKeyspace"
	KEYSPACE_ACTION_SET_SHARDING_INFO   = "SetKeyspaceShardingInfo"
	KEYSPACE_ACTION_MIGRATE_SERVED_FROM = "MigrateServedFrom"

	SRV_SHARD_ACTION_REBUILD = "RebuildSrvShard"

	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

View Source
var (
	// DefaultLockTimeout is a good value to use as a default for
	// locking a shard / keyspace.
	DefaultLockTimeout = 15 * time.Second
)

Functions

func ActionNodeCanBePurged

func ActionNodeCanBePurged(data string) bool

ActionNodeCanBePurged returns true if that ActionNode can be purged from the topology server.

func ActionNodeIsStale

func ActionNodeIsStale(data string) bool

ActionNodeIsStale returns true if that ActionNode is not Running

Types

type ActionNode

type ActionNode struct {
	Action     string
	ActionGuid string
	Error      string
	State      ActionState
	Pid        int // only != 0 if State == ACTION_STATE_RUNNING

	// do not serialize the next fields
	// path in topology server representing this action
	Path  string      `json:"-"`
	Args  interface{} `json:"-"`
	Reply interface{} `json:"-"`
}

ActionNode describes a long-running action on a tablet, or an action on a shard or keyspace that locks it.

func ActionNodeFromJson

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

ActionNodeFromJson interprets the data from JSON.

func ApplySchemaKeyspace

func ApplySchemaKeyspace(change string, simple bool) *ActionNode

func ApplySchemaShard

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

func CheckShard

func CheckShard() *ActionNode

func MigrateServedFrom

func MigrateServedFrom(servedType topo.TabletType) *ActionNode

func MigrateServedTypes

func MigrateServedTypes(servedType topo.TabletType) *ActionNode

func RebuildKeyspace

func RebuildKeyspace() *ActionNode

func RebuildShard

func RebuildShard() *ActionNode

func RebuildSrvShard

func RebuildSrvShard() *ActionNode

func ReparentShard

func ReparentShard(tabletAlias topo.TabletAlias) *ActionNode

func SetKeyspaceShardingInfo

func SetKeyspaceShardingInfo() *ActionNode

func SetShardServedTypes

func SetShardServedTypes(servedTypes []topo.TabletType) *ActionNode

func ShardExternallyReparented

func ShardExternallyReparented(tabletAlias topo.TabletAlias) *ActionNode

func ShardMultiRestore

func ShardMultiRestore(args *MultiRestoreArgs) *ActionNode

func UpdateShard

func UpdateShard() *ActionNode

func (*ActionNode) LockKeyspace

func (n *ActionNode) LockKeyspace(ts topo.Server, keyspace string, lockTimeout time.Duration, interrupted chan struct{}) (lockPath string, err error)

LockKeyspace will lock the keyspace in the topology server. UnlockKeyspace should be called if this returns no error.

func (*ActionNode) LockShard

func (n *ActionNode) LockShard(ts topo.Server, keyspace, shard string, lockTimeout time.Duration, interrupted chan struct{}) (lockPath string, err error)

LockShard will lock the shard in the topology server. UnlockShard should be called if this returns no error.

func (*ActionNode) LockSrvShard

func (n *ActionNode) LockSrvShard(ts topo.Server, cell, keyspace, shard string, lockTimeout time.Duration, interrupted chan struct{}) (lockPath string, err error)

LockSrvShard will lock the serving shard in the topology server. UnlockSrvShard should be called if this returns no error.

func (*ActionNode) SetGuid

func (n *ActionNode) SetGuid() *ActionNode

SetGuid will set the ActionGuid field for the action node and return the action node.

func (*ActionNode) ToJson

func (n *ActionNode) ToJson() string

ToJson returns a JSON representation of the object.

func (*ActionNode) UnlockKeyspace

func (n *ActionNode) UnlockKeyspace(ts topo.Server, keyspace string, lockPath string, actionError error) error

UnlockKeyspace unlocks a previously locked keyspace.

func (*ActionNode) UnlockShard

func (n *ActionNode) UnlockShard(ts topo.Server, keyspace, shard string, lockPath string, actionError error) error

UnlockShard unlocks a previously locked shard.

func (*ActionNode) UnlockSrvShard

func (n *ActionNode) UnlockSrvShard(ts topo.Server, cell, keyspace, shard string, lockPath string, actionError error) error

UnlockSrvShard unlocks a previously locked serving shard.

type ActionState

type ActionState string

ActionState is the state an ActionNode

type ApplySchemaKeyspaceArgs

type ApplySchemaKeyspaceArgs struct {
	Change string
	Simple bool
}

type ApplySchemaShardArgs

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

type MigrateServedFromArgs

type MigrateServedFromArgs struct {
	ServedType topo.TabletType
}

type MigrateServedTypesArgs

type MigrateServedTypesArgs struct {
	ServedType topo.TabletType
}

type MultiRestoreArgs

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

type MultiSnapshotArgs

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

type MultiSnapshotReply

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

type ReserveForRestoreArgs

type ReserveForRestoreArgs struct {
	SrcTabletAlias topo.TabletAlias
}

type RestartSlaveData

type RestartSlaveData struct {
	ReplicationState *myproto.ReplicationState
	WaitPosition     *myproto.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 {
	SrcTabletAlias        topo.TabletAlias
	SrcFilePath           string
	ParentAlias           topo.TabletAlias
	FetchConcurrency      int
	FetchRetryCount       int
	WasReserved           bool
	DontWaitForSlaveStart bool
}

type SetShardServedTypesArgs

type SetShardServedTypesArgs struct {
	ServedTypes []topo.TabletType
}

type SlaveWasRestartedArgs

type SlaveWasRestartedArgs struct {
	Parent topo.TabletAlias
}

type SnapshotArgs

type SnapshotArgs struct {
	Concurrency int
	ServerMode  bool
}

type SnapshotReply

type SnapshotReply struct {
	ParentAlias  topo.TabletAlias
	ManifestPath string

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

type SnapshotSourceEndArgs

type SnapshotSourceEndArgs struct {
	SlaveStartRequired bool
	ReadOnly           bool
}

Jump to

Keyboard shortcuts

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