Documentation
¶
Index ¶
- Constants
- Variables
- func IsContains(slice []string, target string) bool
- func IsSubSlice(subSlice []string, slice []string) bool
- func Max(x, y int) int
- type CreateNormalTableProcedure
- type CreatePartitionTableCallbackRequest
- type CreatePartitionTableProcedure
- func (p *CreatePartitionTableProcedure) Cancel(_ context.Context) error
- func (p *CreatePartitionTableProcedure) ID() uint64
- func (p *CreatePartitionTableProcedure) Start(ctx context.Context) error
- func (p *CreatePartitionTableProcedure) State() State
- func (p *CreatePartitionTableProcedure) Typ() Typ
- type CreatePartitionTableProcedureRequest
- type CreatePartitionTableRawData
- type CreatePartitionTableRequest
- type CreateTableProcedure
- type CreateTableRequest
- type DropTableProcedure
- type DropTableRequest
- type EtcdStorageImpl
- type Factory
- func (f *Factory) CreateDropTableProcedure(ctx context.Context, request DropTableRequest) (Procedure, error)
- func (f *Factory) CreateScatterProcedure(ctx context.Context, request ScatterRequest) (Procedure, error)
- func (f *Factory) CreateSplitProcedure(ctx context.Context, request SplitRequest) (Procedure, error)
- func (f *Factory) CreateTransferLeaderProcedure(ctx context.Context, request TransferLeaderRequest) (Procedure, error)
- func (f *Factory) MakeCreateTableProcedure(ctx context.Context, request CreateTableRequest) (Procedure, error)
- type Info
- type Manager
- type ManagerImpl
- func (m *ManagerImpl) Cancel(ctx context.Context, procedureID uint64) error
- func (m *ManagerImpl) ListRunningProcedure(_ context.Context) ([]*Info, error)
- func (m *ManagerImpl) Start(ctx context.Context) error
- func (m *ManagerImpl) Stop(ctx context.Context) error
- func (m *ManagerImpl) Submit(_ context.Context, procedure Procedure) error
- type Meta
- type Procedure
- func NewCreateNormalTableProcedure(dispatch eventdispatch.Dispatch, cluster *cluster.Cluster, id uint64, ...) Procedure
- func NewCreateTableProcedure(ctx context.Context, factory *Factory, c *cluster.Cluster, ...) (Procedure, error)
- func NewDropTableProcedure(dispatch eventdispatch.Dispatch, cluster *cluster.Cluster, id uint64, ...) Procedure
- func NewScatterProcedure(dispatch eventdispatch.Dispatch, cluster *cluster.Cluster, id uint64, ...) Procedure
- func NewTransferLeaderProcedure(dispatch eventdispatch.Dispatch, c *cluster.Cluster, s Storage, ...) (Procedure, error)
- type RandomShardPicker
- type ScatterCallbackRequest
- type ScatterProcedure
- type ScatterRequest
- type ShardPicker
- type SplitProcedure
- type SplitProcedurePersistRawData
- type SplitRequest
- type State
- type Storage
- type TransferLeaderCallbackRequest
- type TransferLeaderProcedure
- type TransferLeaderProcedurePersistRawData
- type TransferLeaderRequest
- type Typ
- type Write
Constants ¶
const ( StateInit = "init" StateRunning = "running" StateFinished = "finished" StateFailed = "failed" StateCancelled = "cancelled" )
const ( Version = "v1" PathProcedure = "procedure" PathDeletedProcedure = "deletedProcedure" )
Variables ¶
var ( ErrShardLeaderNotFound = coderr.NewCodeError(coderr.Internal, "shard leader not found") ErrProcedureNotFound = coderr.NewCodeError(coderr.Internal, "procedure not found") ErrClusterConfigChanged = coderr.NewCodeError(coderr.Internal, "cluster config changed") ErrTableAlreadyExists = coderr.NewCodeError(coderr.Internal, "table already exists") ErrProcedureTypeNotMatch = coderr.NewCodeError(coderr.Internal, "procedure type not match") ErrDecodeRawData = coderr.NewCodeError(coderr.Internal, "decode raw data") ErrEncodeRawData = coderr.NewCodeError(coderr.Internal, "encode raw data") ErrGetRequest = coderr.NewCodeError(coderr.Internal, "get request from event") ErrNodeNumberNotEnough = coderr.NewCodeError(coderr.Internal, "node number not enough") ErrEmptyPartitionNames = coderr.NewCodeError(coderr.Internal, "partition names is empty") ErrShardNumberNotEnough = coderr.NewCodeError(coderr.Internal, "shard number not enough") )
Functions ¶
func IsContains ¶ added in v1.0.0
func IsSubSlice ¶ added in v1.0.0
Types ¶
type CreateNormalTableProcedure ¶
type CreateNormalTableProcedure struct {
// contains filtered or unexported fields
}
func (*CreateNormalTableProcedure) Cancel ¶
func (p *CreateNormalTableProcedure) Cancel(_ context.Context) error
func (*CreateNormalTableProcedure) ID ¶
func (p *CreateNormalTableProcedure) ID() uint64
func (*CreateNormalTableProcedure) Start ¶
func (p *CreateNormalTableProcedure) Start(ctx context.Context) error
func (*CreateNormalTableProcedure) State ¶
func (p *CreateNormalTableProcedure) State() State
func (*CreateNormalTableProcedure) Typ ¶
func (p *CreateNormalTableProcedure) Typ() Typ
type CreatePartitionTableCallbackRequest ¶
type CreatePartitionTableCallbackRequest struct {
// contains filtered or unexported fields
}
type CreatePartitionTableProcedure ¶
type CreatePartitionTableProcedure struct {
// contains filtered or unexported fields
}
func NewCreatePartitionTableProcedure ¶
func NewCreatePartitionTableProcedure(request CreatePartitionTableProcedureRequest) *CreatePartitionTableProcedure
func (*CreatePartitionTableProcedure) Cancel ¶
func (p *CreatePartitionTableProcedure) Cancel(_ context.Context) error
func (*CreatePartitionTableProcedure) ID ¶
func (p *CreatePartitionTableProcedure) ID() uint64
func (*CreatePartitionTableProcedure) Start ¶
func (p *CreatePartitionTableProcedure) Start(ctx context.Context) error
func (*CreatePartitionTableProcedure) State ¶
func (p *CreatePartitionTableProcedure) State() State
func (*CreatePartitionTableProcedure) Typ ¶
func (p *CreatePartitionTableProcedure) Typ() Typ
type CreatePartitionTableProcedureRequest ¶
type CreatePartitionTableProcedureRequest struct {
// contains filtered or unexported fields
}
type CreatePartitionTableRawData ¶
type CreatePartitionTableRawData struct {
ID uint64
FsmState string
State State
CreateTableResult cluster.CreateTableResult
PartitionTableShards []cluster.ShardNodeWithVersion
DataTablesShards []cluster.ShardNodeWithVersion
}
type CreatePartitionTableRequest ¶
type CreatePartitionTableRequest struct {
ClusterName string
SourceReq *metaservicepb.CreateTableRequest
PartitionTableRatioOfNodes float32
OnSucceeded func(cluster.CreateTableResult) error
OnFailed func(error) error
}
type CreateTableProcedure ¶
type CreateTableProcedure struct {
// contains filtered or unexported fields
}
CreateTableProcedure is a proxy procedure, it determines the actual procedure created according to the request type.
func (CreateTableProcedure) Cancel ¶
func (p CreateTableProcedure) Cancel(ctx context.Context) error
func (CreateTableProcedure) ID ¶
func (p CreateTableProcedure) ID() uint64
func (CreateTableProcedure) State ¶
func (p CreateTableProcedure) State() State
func (CreateTableProcedure) Typ ¶
func (p CreateTableProcedure) Typ() Typ
type CreateTableRequest ¶
type CreateTableRequest struct {
Cluster *cluster.Cluster
SourceReq *metaservicepb.CreateTableRequest
OnSucceeded func(cluster.CreateTableResult) error
OnFailed func(error) error
}
type DropTableProcedure ¶
type DropTableProcedure struct {
// contains filtered or unexported fields
}
func (*DropTableProcedure) ID ¶
func (p *DropTableProcedure) ID() uint64
func (*DropTableProcedure) State ¶
func (p *DropTableProcedure) State() State
func (*DropTableProcedure) Typ ¶
func (p *DropTableProcedure) Typ() Typ
type DropTableRequest ¶
type DropTableRequest struct {
Cluster *cluster.Cluster
SourceReq *metaservicepb.DropTableRequest
OnSucceeded func(cluster.TableInfo) error
OnFailed func(error) error
}
type EtcdStorageImpl ¶
type EtcdStorageImpl struct {
// contains filtered or unexported fields
}
func (EtcdStorageImpl) CreateOrUpdate ¶
func (e EtcdStorageImpl) CreateOrUpdate(ctx context.Context, meta Meta) error
CreateOrUpdate example: /{rootPath}/v1/procedure/{procedureID} -> {procedureType} + {procedureState} + {data}
func (EtcdStorageImpl) MarkDeleted ¶
func (e EtcdStorageImpl) MarkDeleted(ctx context.Context, id uint64) error
MarkDeleted Do a soft deletion, and the deleted key's format is: /{rootPath}/v1/historyProcedure/{clusterID}/{procedureID}
type Factory ¶
type Factory struct {
// contains filtered or unexported fields
}
func NewFactory ¶
func (*Factory) CreateDropTableProcedure ¶
func (*Factory) CreateScatterProcedure ¶
func (*Factory) CreateSplitProcedure ¶
func (*Factory) CreateTransferLeaderProcedure ¶
func (*Factory) MakeCreateTableProcedure ¶
type Manager ¶
type Manager interface {
// Start must be called before manager is used.
Start(ctx context.Context) error
// Stop must be called before manager is dropped.
Stop(ctx context.Context) error
// Submit procedure to be executed asynchronously.
// TODO: change result type, add channel to get whether the procedure executed successfully
Submit(ctx context.Context, procedure Procedure) error
// Cancel procedure that has been submitted.
Cancel(ctx context.Context, procedureID uint64) error
ListRunningProcedure(ctx context.Context) ([]*Info, error)
}
func NewManagerImpl ¶
type ManagerImpl ¶
type ManagerImpl struct {
// contains filtered or unexported fields
}
func (*ManagerImpl) Cancel ¶
func (m *ManagerImpl) Cancel(ctx context.Context, procedureID uint64) error
func (*ManagerImpl) ListRunningProcedure ¶
func (m *ManagerImpl) ListRunningProcedure(_ context.Context) ([]*Info, error)
type Procedure ¶
type Procedure interface {
// ID of the procedure.
ID() uint64
// Typ of the procedure.
Typ() Typ
// Start the procedure.
Start(ctx context.Context) error
// Cancel the procedure.
Cancel(ctx context.Context) error
// State of the procedure. Retrieve the state of this procedure.
State() State
}
Procedure is used to describe how to execute a set of operations from the scheduler, e.g. SwitchLeaderProcedure, MergeShardProcedure.
func NewCreateNormalTableProcedure ¶
func NewCreateNormalTableProcedure(dispatch eventdispatch.Dispatch, cluster *cluster.Cluster, id uint64, req *metaservicepb.CreateTableRequest, onSucceeded func(cluster.CreateTableResult) error, onFailed func(error) error) Procedure
func NewCreateTableProcedure ¶
func NewCreateTableProcedure(ctx context.Context, factory *Factory, c *cluster.Cluster, sourceReq *metaservicepb.CreateTableRequest, onSucceeded func(cluster.CreateTableResult) error, onFailed func(error) error) (Procedure, error)
func NewDropTableProcedure ¶
func NewDropTableProcedure(dispatch eventdispatch.Dispatch, cluster *cluster.Cluster, id uint64, req *metaservicepb.DropTableRequest, onSucceeded func(cluster.TableInfo) error, onFailed func(error) error) Procedure
func NewScatterProcedure ¶
type RandomShardPicker ¶
type RandomShardPicker struct {
// contains filtered or unexported fields
}
RandomShardPicker randomly pick up shards that are not on the same node in the current cluster.
func (*RandomShardPicker) PickShards ¶
func (p *RandomShardPicker) PickShards(ctx context.Context, clusterName string, expectShardNum int, enableDuplicateNode bool) ([]cluster.ShardNodeWithVersion, error)
PickShards will pick a specified number of shards as expectShardNum.
type ScatterCallbackRequest ¶
type ScatterCallbackRequest struct {
// contains filtered or unexported fields
}
ScatterCallbackRequest is fsm callbacks param.
type ScatterProcedure ¶
type ScatterProcedure struct {
// contains filtered or unexported fields
}
func (*ScatterProcedure) ID ¶
func (p *ScatterProcedure) ID() uint64
func (*ScatterProcedure) State ¶
func (p *ScatterProcedure) State() State
func (*ScatterProcedure) Typ ¶
func (p *ScatterProcedure) Typ() Typ
type ScatterRequest ¶
type ShardPicker ¶
type ShardPicker interface {
PickShards(ctx context.Context, clusterName string, expectShardNum int, enableDuplicateNode bool) ([]cluster.ShardNodeWithVersion, error)
}
ShardPicker is used to pick up the shards suitable for scheduling in the cluster. If expectShardNum bigger than cluster node number, the result depends on enableDuplicateNode: If enableDuplicateNode is false, pick shards will be failed and return error. If enableDuplicateNode is true, pick shard will return shards on the same node. TODO: Consider refactor this interface, abstracts the parameters of PickShards as PickStrategy.
func NewRandomShardPicker ¶
func NewRandomShardPicker(manager cluster.Manager) ShardPicker
type SplitProcedure ¶
type SplitProcedure struct {
// contains filtered or unexported fields
}
SplitProcedure fsm: Update ShardTable Metadata -> OpenNewShard -> CloseTable
func NewSplitProcedure ¶
func (*SplitProcedure) ID ¶
func (p *SplitProcedure) ID() uint64
func (*SplitProcedure) State ¶
func (p *SplitProcedure) State() State
func (*SplitProcedure) Typ ¶
func (p *SplitProcedure) Typ() Typ
type SplitRequest ¶
type Storage ¶
type TransferLeaderCallbackRequest ¶
type TransferLeaderCallbackRequest struct {
// contains filtered or unexported fields
}
TransferLeaderCallbackRequest is fsm callbacks param.
type TransferLeaderProcedure ¶
type TransferLeaderProcedure struct {
// contains filtered or unexported fields
}
func (*TransferLeaderProcedure) Cancel ¶
func (p *TransferLeaderProcedure) Cancel(_ context.Context) error
func (*TransferLeaderProcedure) ID ¶
func (p *TransferLeaderProcedure) ID() uint64
func (*TransferLeaderProcedure) Start ¶
func (p *TransferLeaderProcedure) Start(ctx context.Context) error
func (*TransferLeaderProcedure) State ¶
func (p *TransferLeaderProcedure) State() State
func (*TransferLeaderProcedure) Typ ¶
func (p *TransferLeaderProcedure) Typ() Typ
type TransferLeaderProcedurePersistRawData ¶
type TransferLeaderProcedurePersistRawData struct {
ID uint64
FsmState string
State State
ShardID storage.ShardID
OldLeaderNodeName string
NewLeaderNodeName string
}
TransferLeaderProcedurePersistRawData used for storage, procedure will be converted to persist raw data before saved in storage.