Documentation
¶
Overview ¶
Package mock_controller is a generated GoMock package.
Index ¶
- Constants
- type DiagnoseType
- type GRShard
- func (shard *GRShard) Diagnose(ctx context.Context) (DiagnoseType, error)
- func (shard *GRShard) Failover(ctx context.Context) error
- func (shard *GRShard) GetCurrentShardStatuses() ShardStatus
- func (shard *GRShard) GetUnlock() func(*error)
- func (shard *GRShard) LockShard(ctx context.Context, action string) (context.Context, error)
- func (shard *GRShard) Repair(ctx context.Context, status DiagnoseType) (RepairResultCode, error)
- func (shard *GRShard) ScanAndRepairShard(ctx context.Context)
- func (shard *GRShard) SetIsActive(isActive bool)
- func (shard *GRShard) UnlockShard()
- func (shard *GRShard) UpdateTabletsInShardWithLock(ctx context.Context)
- type GRTmcClient
- type GRTopo
- type MockGRTmcClient
- type MockGRTmcClientMockRecorder
- type MockGRTopo
- func (m *MockGRTopo) EXPECT() *MockGRTopoMockRecorder
- func (m *MockGRTopo) GetShardNames(ctx context.Context, keyspace string) ([]string, error)
- func (m *MockGRTopo) GetTabletMapForShardByCell(ctx context.Context, keyspace, shard string, cells []string) (map[string]*topo.TabletInfo, error)
- func (m *MockGRTopo) LockShard(ctx context.Context, keyspace, shard, action string) (context.Context, func(*error), error)
- type MockGRTopoMockRecorder
- func (mr *MockGRTopoMockRecorder) GetShardNames(ctx, keyspace interface{}) *gomock.Call
- func (mr *MockGRTopoMockRecorder) GetTabletMapForShardByCell(ctx, keyspace, shard, cells interface{}) *gomock.Call
- func (mr *MockGRTopoMockRecorder) LockShard(ctx, keyspace, shard, action interface{}) *gomock.Call
- type RepairResultCode
- type ResolvedView
- type SQLGroup
- func (group *SQLGroup) GetGroupName() string
- func (group *SQLGroup) GetOnlineGroupInfo() (int, bool)
- func (group *SQLGroup) GetPrimary() (string, int, bool)
- func (group *SQLGroup) GetStatus(instanceKey *inst.InstanceKey) *db.GroupMember
- func (group *SQLGroup) GetViews() []*db.GroupView
- func (group *SQLGroup) IsAllOfflineOrError() bool
- func (group *SQLGroup) IsSafeToBootstrap() bool
- func (group *SQLGroup) IsUnconnectedReplica(instanceKey *inst.InstanceKey) bool
- func (group *SQLGroup) Resolve() error
- func (group *SQLGroup) ToString() string
- type ShardStatus
Constants ¶
const ( // DiagnoseTypeError represents an DiagnoseTypeError status DiagnoseTypeError DiagnoseType = "error" // DiagnoseTypeHealthy represents everything is DiagnoseTypeHealthy DiagnoseTypeHealthy = "Healthy" // DiagnoseTypeShardHasNoGroup represents the cluster has not init yet DiagnoseTypeShardHasNoGroup = "ShardHasNoGroup" // DiagnoseTypeShardHasInactiveGroup represents the status where we have a group name but no member in it DiagnoseTypeShardHasInactiveGroup = "ShardHasInactiveGroup" // DiagnoseTypeInsufficientGroupSize represents the cluster has insufficient group members DiagnoseTypeInsufficientGroupSize = "InsufficientGroupSize" // DiagnoseTypeReadOnlyShard represents the cluster who has a read only node DiagnoseTypeReadOnlyShard = "ReadOnlyShard" // DiagnoseTypeUnreachablePrimary represents the primary tablet is unreachable DiagnoseTypeUnreachablePrimary = "UnreachablePrimary" // DiagnoseTypeWrongPrimaryTablet represents the primary tablet is incorrect based on mysql group DiagnoseTypeWrongPrimaryTablet = "WrongPrimaryTablet" // DiagnoseTypeUnconnectedReplica represents cluster with primary tablet, but a node is not connected to it DiagnoseTypeUnconnectedReplica = "UnconnectedReplica" // DiagnoseTypeBackoffError represents a transient error e.g., the primary is unreachable DiagnoseTypeBackoffError = "BackoffError" // DiagnoseTypeBootstrapBackoff represents an ongoing bootstrap DiagnoseTypeBootstrapBackoff = "BootstrapBackoff" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GRShard ¶
type GRShard struct { KeyspaceShard *topo.KeyspaceShard // lock prevents multiple go routine fights with each other sync.Mutex // contains filtered or unexported fields }
GRShard stores the information about a Vitess shard that's running MySQL GR
func NewGRShard ¶
func NewGRShard( keyspace, shard string, cells []string, tmc GRTmcClient, ts GRTopo, dbAgent db.Agent, config *config.VTGRConfig, localDbPort int, isActive bool) *GRShard
NewGRShard creates a new GRShard
func (*GRShard) Diagnose ¶
func (shard *GRShard) Diagnose(ctx context.Context) (DiagnoseType, error)
Diagnose the shard in the following order: TODO: use FSM to make sure the status transition is correct 1. if the shard has a group that every node agreed on 2. if the group has any active (online / recovering) member 3. if the shard has initialized a Vitess primary 4. if primary tablet is reachable 5. if Vitess primary and mysql primary reconciled 6. if we have enough group members 7. if the primary node has read_only=OFF 8. if there is a node that is not in Mysql group
func (*GRShard) Failover ¶
Failover takes a shard and find an node with largest GTID as the mysql primary of the group
func (*GRShard) GetCurrentShardStatuses ¶
func (shard *GRShard) GetCurrentShardStatuses() ShardStatus
GetCurrentShardStatuses returns the status collector has
func (*GRShard) LockShard ¶
LockShard locks the keyspace-shard on topo server to prevent others from executing conflicting actions.
func (*GRShard) Repair ¶
func (shard *GRShard) Repair(ctx context.Context, status DiagnoseType) (RepairResultCode, error)
Repair tries to fix shard based on the diagnose type
func (*GRShard) ScanAndRepairShard ¶
ScanAndRepairShard scans a particular shard by first Diagnose the shard with info from grShard and then repair the probelm if the shard is unhealthy
func (*GRShard) SetIsActive ¶
SetIsActive sets isActive for the shard
func (*GRShard) UnlockShard ¶
func (shard *GRShard) UnlockShard()
UnlockShard unlocks the keyspace-shard on topo server and set the unlock function to nil in the container
func (*GRShard) UpdateTabletsInShardWithLock ¶
UpdateTabletsInShardWithLock updates the shard instances with a lock
type GRTmcClient ¶
type GRTmcClient interface { ChangeType(ctx context.Context, tablet *topodatapb.Tablet, dbType topodatapb.TabletType) error Ping(ctx context.Context, tablet *topodatapb.Tablet) error }
GRTmcClient is VTGR wrapper for tmc client
type GRTopo ¶
type GRTopo interface { GetShardNames(ctx context.Context, keyspace string) ([]string, error) GetTabletMapForShardByCell(ctx context.Context, keyspace, shard string, cells []string) (map[string]*topo.TabletInfo, error) LockShard(ctx context.Context, keyspace, shard, action string) (context.Context, func(*error), error) }
GRTopo is VTGR wrapper for topo server
type MockGRTmcClient ¶
type MockGRTmcClient struct {
// contains filtered or unexported fields
}
MockGRTmcClient is a mock of GRTmcClient interface
func NewMockGRTmcClient ¶
func NewMockGRTmcClient(ctrl *gomock.Controller) *MockGRTmcClient
NewMockGRTmcClient creates a new mock instance
func (*MockGRTmcClient) ChangeType ¶
func (m *MockGRTmcClient) ChangeType(ctx context.Context, tablet *topodata.Tablet, dbType topodata.TabletType) error
ChangeType mocks base method
func (*MockGRTmcClient) EXPECT ¶
func (m *MockGRTmcClient) EXPECT() *MockGRTmcClientMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
type MockGRTmcClientMockRecorder ¶
type MockGRTmcClientMockRecorder struct {
// contains filtered or unexported fields
}
MockGRTmcClientMockRecorder is the mock recorder for MockGRTmcClient
func (*MockGRTmcClientMockRecorder) ChangeType ¶
func (mr *MockGRTmcClientMockRecorder) ChangeType(ctx, tablet, dbType interface{}) *gomock.Call
ChangeType indicates an expected call of ChangeType
func (*MockGRTmcClientMockRecorder) Ping ¶
func (mr *MockGRTmcClientMockRecorder) Ping(ctx, tablet interface{}) *gomock.Call
Ping indicates an expected call of Ping
type MockGRTopo ¶
type MockGRTopo struct {
// contains filtered or unexported fields
}
MockGRTopo is a mock of GRTopo interface
func NewMockGRTopo ¶
func NewMockGRTopo(ctrl *gomock.Controller) *MockGRTopo
NewMockGRTopo creates a new mock instance
func (*MockGRTopo) EXPECT ¶
func (m *MockGRTopo) EXPECT() *MockGRTopoMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockGRTopo) GetShardNames ¶
GetShardNames mocks base method
func (*MockGRTopo) GetTabletMapForShardByCell ¶
func (m *MockGRTopo) GetTabletMapForShardByCell(ctx context.Context, keyspace, shard string, cells []string) (map[string]*topo.TabletInfo, error)
GetTabletMapForShardByCell mocks base method
type MockGRTopoMockRecorder ¶
type MockGRTopoMockRecorder struct {
// contains filtered or unexported fields
}
MockGRTopoMockRecorder is the mock recorder for MockGRTopo
func (*MockGRTopoMockRecorder) GetShardNames ¶
func (mr *MockGRTopoMockRecorder) GetShardNames(ctx, keyspace interface{}) *gomock.Call
GetShardNames indicates an expected call of GetShardNames
func (*MockGRTopoMockRecorder) GetTabletMapForShardByCell ¶
func (mr *MockGRTopoMockRecorder) GetTabletMapForShardByCell(ctx, keyspace, shard, cells interface{}) *gomock.Call
GetTabletMapForShardByCell indicates an expected call of GetTabletMapForShardByCell
func (*MockGRTopoMockRecorder) LockShard ¶
func (mr *MockGRTopoMockRecorder) LockShard(ctx, keyspace, shard, action interface{}) *gomock.Call
LockShard indicates an expected call of LockShard
type RepairResultCode ¶
type RepairResultCode string
RepairResultCode is the code for repair
const ( // Success means successfully repaired Success RepairResultCode = "Success" // Fail means failed to repaire Fail RepairResultCode = "Fail" // Noop means do nothing Noop RepairResultCode = "Noop" )
type ResolvedView ¶
type ResolvedView struct {
// contains filtered or unexported fields
}
ResolvedView is the resolved view
type SQLGroup ¶
SQLGroup contains views from all the nodes within the shard
func NewSQLGroup ¶
NewSQLGroup creates a new SQLGroup
func (*SQLGroup) GetGroupName ¶
GetGroupName returns the group name
func (*SQLGroup) GetOnlineGroupInfo ¶
GetOnlineGroupInfo returns number of online members in the group and also if the primary is read only
func (*SQLGroup) GetPrimary ¶
GetPrimary returns the hostname, port of the primary that everyone agreed on isActive bool indicates if there is any node in the group whose primary is "ONLINE"
func (*SQLGroup) GetStatus ¶
func (group *SQLGroup) GetStatus(instanceKey *inst.InstanceKey) *db.GroupMember
GetStatus returns GroupMember status for given a host
func (*SQLGroup) IsAllOfflineOrError ¶
IsAllOfflineOrError returns true if all the nodes are in offline mode
func (*SQLGroup) IsSafeToBootstrap ¶
IsSafeToBootstrap checks if it is safe to bootstrap a mysql group
func (*SQLGroup) IsUnconnectedReplica ¶
func (group *SQLGroup) IsUnconnectedReplica(instanceKey *inst.InstanceKey) bool
IsUnconnectedReplica checks if the node is connected to a group
type ShardStatus ¶
type ShardStatus struct { Keyspace string Shard string Instances []string Unreachables []string Problematics []string Primary string DiagnoseResult DiagnoseType }
ShardStatus is used for debugging purpose to get current status of a shard