shiftmanager

package
v0.0.0-...-2d50ede Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2023 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MockShiftInfo = &ShiftInfo{
	From:         "src",
	FromUser:     "test",
	FromPassword: "test",
	FromDatabase: "testdb",
	FromTable:    "tbl",

	To:         "dst",
	ToUser:     "user",
	ToPassword: "user",
	ToDatabase: "todb",
	ToTable:    "totbl",

	Cleanup:                false,
	Checksum:               true,
	MysqlDump:              "mysqldump",
	Threads:                128,
	PosBehinds:             2048,
	WaitTimeBeforeChecksum: 10,
	NeoDBURL:               "",
}

MockShiftInfo used to mock a shift info

Functions

func NewMockShift

func NewMockShift(log *xlog.Log) shift.ShiftHandler

NewMockShift used to new a mockshift

Types

type MockShift

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

MockShift used to mock a shift for test

func (*MockShift) ChecksumTable

func (mockShift *MockShift) ChecksumTable() error

ChecksumTable used to checksum data src tbl and dst tbl.

func (*MockShift) SetStopSignal

func (mockShift *MockShift) SetStopSignal()

SetStopSignal used set a stop signal to stop a shift work.

func (*MockShift) Start

func (mockShift *MockShift) Start() error

Start used to start a shift work.

func (*MockShift) WaitFinish

func (mockShift *MockShift) WaitFinish() error

WaitFinish used to wait success or fail signal to finish.

type ShiftInfo

type ShiftInfo struct {
	From         string
	FromUser     string
	FromPassword string
	FromDatabase string
	FromTable    string

	To         string
	ToUser     string
	ToPassword string
	ToDatabase string
	ToTable    string

	Rebalance              bool
	Cleanup                bool // if Cleanup is true, drop the FromTable.
	Checksum               bool
	MysqlDump              string
	Threads                int
	PosBehinds             int
	WaitTimeBeforeChecksum int
	NeoDBURL               string
}

ShiftInfo used to record basic infos used by shift

type ShiftManager

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

ShiftManager used to manager the infos about the shift Called by reshard/rebalance

func (*ShiftManager) Close

func (shiftMgr *ShiftManager) Close() error

Close -- used to close all the shift instances that are on working When call Close(), WaitInstanceFinishThread will get err and exit goroutine

func (*ShiftManager) GetProgress

func (shiftMgr *ShiftManager) GetProgress(key string) *sqltypes.Result

GetProgress -- used to get shift progress specified by key key: for reshard, key is `db`.`table`, for rebalance, key is `db`.`table`_backend

func (*ShiftManager) GetShiftType

func (shiftMgr *ShiftManager) GetShiftType(key string) ShiftType

GetShiftType -- used to get shift type specified by key

func (*ShiftManager) GetStatus

func (shiftMgr *ShiftManager) GetStatus(key string) ShiftStatus

GetStatus -- used to get shift status specified by key key: for reshard, key is `db`.`table`, for rebalance, key is `db`.`table`_backend

func (*ShiftManager) Init

func (shiftMgr *ShiftManager) Init() error

Init -- used to init the plug module.

func (*ShiftManager) NewShiftInstance

func (shiftMgr *ShiftManager) NewShiftInstance(shiftInfo *ShiftInfo, typ ShiftType) (shift.ShiftHandler, error)

NewShiftInstance -- used to new a shift instance

func (*ShiftManager) StartShiftInstance

func (shiftMgr *ShiftManager) StartShiftInstance(key string, shift shift.ShiftHandler, typ ShiftType) error

StartShiftInstance -- used to start a new shift instance

func (*ShiftManager) StopAllInstance

func (shiftMgr *ShiftManager) StopAllInstance() error

StopAllInstance used to stop all shift instances When call Close(), WaitInstanceFinishThread will get err and exit goroutine

func (*ShiftManager) StopOneInstance

func (shiftMgr *ShiftManager) StopOneInstance(key string) error

StopOneInstance used to stop one shift instance specified by key key: for reshard, key is `db`.`table`, for rebalance, key is `db`.`table`_backend

func (*ShiftManager) WaitInstanceFinish

func (shiftMgr *ShiftManager) WaitInstanceFinish(key string) error

WaitInstanceFinish -- used to wait instance run until finished.

func (*ShiftManager) WaitInstanceFinishThread

func (shiftMgr *ShiftManager) WaitInstanceFinishThread(key string) error

WaitInstanceFinishThread -- used to start a thread to excute wait finish in background.

type ShiftMgrHandler

type ShiftMgrHandler interface {
	Init() error
	NewShiftInstance(shiftInfo *ShiftInfo, typ ShiftType) (shift.ShiftHandler, error)
	StartShiftInstance(key string, shift shift.ShiftHandler, typ ShiftType) error
	WaitInstanceFinishThread(key string) error
	WaitInstanceFinish(key string) error
	StopOneInstance(key string) error
	StopAllInstance() error
	GetStatus(key string) ShiftStatus
	GetProgress(key string) *sqltypes.Result
	GetShiftType(key string) ShiftType
	Close() error
}

func NewShiftManager

func NewShiftManager(log *xlog.Log) ShiftMgrHandler

NewShiftManager -- used to create a new shift manager.

type ShiftStatus

type ShiftStatus int

ShiftStatus used to indicates shift instance's status.

const (
	// ShiftStatusNone enum, if status is none, some errors happen
	ShiftStatusNone ShiftStatus = iota

	// ShiftStatusMigrating enum
	ShiftStatusMigrating

	// ShiftStatusSuccess enum
	ShiftStatusSuccess

	// ShiftStatusFail enum
	ShiftStatusFail
)

type ShiftType

type ShiftType int

ShiftType is used to distinguish what different type of shift If it is called by reshard, the type will be ShiftTypeReshard If it is called by rebalance, the type will be ShiftTypeRebalance

const (
	// ShiftTypeNone enum, a shift type should not be none
	ShiftTypeNone ShiftType = iota

	// ShiftTypeReshard enum
	ShiftTypeReshard

	// ShiftTypeRebalance enum
	ShiftTypeRebalance
)

Jump to

Keyboard shortcuts

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