component

package
v0.7.2-beta.5 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2023 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// types for probe
	CheckRunningType int = iota
	CheckStatusType
	CheckRoleChangedType
)

Variables

View Source
var Name2Property = map[string]Properties{}

Functions

func GetAllComponent

func GetAllComponent(dir string) error

func GetIndex

func GetIndex(memberName string) (int, error)

func GetSQLChannelProc

func GetSQLChannelProc() (*os.Process, error)

func MaxInt64

func MaxInt64(x, y int64) int64

func RegisterManager

func RegisterManager(characterType, workloadType string, manager DBManager)

Types

type Component

type Component struct {
	Name string
	Spec ComponentSpec
}

type ComponentSpec

type ComponentSpec struct {
	Version  string
	Metadata []kv
}

type DBManager

type DBManager interface {
	IsRunning() bool

	IsDBStartupReady() bool

	// Functions related to cluster initialization.
	InitializeCluster(context.Context, *dcs.Cluster) error
	IsClusterInitialized(context.Context, *dcs.Cluster) (bool, error)
	// IsCurrentMemberInCluster checks if current member is configured in cluster for consensus.
	// it will always return true for replicationset.
	IsCurrentMemberInCluster(context.Context, *dcs.Cluster) bool

	// IsClusterHealthy is only for consensus cluster healthy check.
	// For Replication cluster IsClusterHealthy will always return true,
	// and its cluster's healthy is equal to leader member's healthy.
	IsClusterHealthy(context.Context, *dcs.Cluster) bool

	// Member healthy check
	// IsMemberHealthy focuses on the database's read and write capabilities.
	IsMemberHealthy(context.Context, *dcs.Cluster, *dcs.Member) bool
	IsCurrentMemberHealthy(context.Context, *dcs.Cluster) bool
	// IsMemberLagging focuses on the latency between the leader and standby
	IsMemberLagging(context.Context, *dcs.Cluster, *dcs.Member) (bool, int64)

	// GetDBState will get most required database kernel states of current member in one HA loop to Avoiding duplicate queries and conserve I/O.
	// We believe that the states of database kernel remains unchanged within a single HA loop.
	GetDBState(context.Context, *dcs.Cluster) *dcs.DBState

	// HasOtherHealthyLeader is applicable only to consensus cluster,
	// where the db's internal role services as the source of truth.
	// for replicationset cluster,  HasOtherHealthyLeader will always be nil.
	HasOtherHealthyLeader(context.Context, *dcs.Cluster) *dcs.Member
	HasOtherHealthyMembers(context.Context, *dcs.Cluster, string) []*dcs.Member

	// Functions related to member check.
	IsLeader(context.Context, *dcs.Cluster) (bool, error)
	IsLeaderMember(context.Context, *dcs.Cluster, *dcs.Member) (bool, error)
	IsFirstMember() bool

	JoinCurrentMemberToCluster(context.Context, *dcs.Cluster) error
	LeaveMemberFromCluster(context.Context, *dcs.Cluster, string) error

	// IsPromoted is applicable only to consensus cluster, which is used to
	// check if DB has complete switchover.
	// for replicationset cluster,  it will always be true.
	IsPromoted(context.Context) bool
	// Functions related to HA
	// The functions should be idempotent, indicating that if they have been executed in one ha cycle,
	// any subsequent calls during that cycle will have no effect.
	Promote(context.Context, *dcs.Cluster) error
	Demote(context.Context) error
	Follow(context.Context, *dcs.Cluster) error
	Recover(context.Context) error

	// Start and Stop just send signal to sqlChannel
	Start(context.Context, *dcs.Cluster) error
	Stop() error

	GetHealthiestMember(*dcs.Cluster, string) *dcs.Member

	GetCurrentMemberName() string
	GetMemberAddrs(context.Context, *dcs.Cluster) []string

	// Functions related to account manage
	IsRootCreated(context.Context) (bool, error)
	CreateRoot(context.Context) error

	// Readonly lock for disk full
	Lock(context.Context, string) error
	Unlock(context.Context) error

	MoveData(context.Context, *dcs.Cluster) error

	GetLogger() logr.Logger

	ShutDownWithWait()
}

func GetDefaultManager

func GetDefaultManager() (DBManager, error)

func GetManager

func GetManager(characterType, workloadType string) DBManager

type DBManagerBase

type DBManagerBase struct {
	CurrentMemberName string
	ClusterCompName   string
	Namespace         string
	DataDir           string
	Logger            logr.Logger
	DBStartupReady    bool
	IsLocked          bool
	DBState           *dcs.DBState
}

func (*DBManagerBase) CreateRoot

func (mgr *DBManagerBase) CreateRoot(context.Context) error

func (*DBManagerBase) Demote

func (mgr *DBManagerBase) Demote(context.Context) error

func (*DBManagerBase) Follow

func (mgr *DBManagerBase) Follow(context.Context, *dcs.Cluster) error

func (*DBManagerBase) GetCurrentMemberName

func (mgr *DBManagerBase) GetCurrentMemberName() string

func (*DBManagerBase) GetDBState

func (mgr *DBManagerBase) GetDBState(context.Context, *dcs.Cluster) *dcs.DBState

func (*DBManagerBase) GetLogger

func (mgr *DBManagerBase) GetLogger() logr.Logger

func (*DBManagerBase) HasOtherHealthyLeader

func (mgr *DBManagerBase) HasOtherHealthyLeader(context.Context, *dcs.Cluster) *dcs.Member

func (*DBManagerBase) IsClusterHealthy

func (mgr *DBManagerBase) IsClusterHealthy(context.Context, *dcs.Cluster) bool

func (*DBManagerBase) IsDBStartupReady

func (mgr *DBManagerBase) IsDBStartupReady() bool

func (*DBManagerBase) IsFirstMember

func (mgr *DBManagerBase) IsFirstMember() bool

func (*DBManagerBase) IsMemberLagging

func (mgr *DBManagerBase) IsMemberLagging(context.Context, *dcs.Cluster, *dcs.Member) (bool, int64)

func (*DBManagerBase) IsPromoted

func (mgr *DBManagerBase) IsPromoted(context.Context) bool

func (*DBManagerBase) IsRootCreated

func (mgr *DBManagerBase) IsRootCreated(context.Context) (bool, error)

func (*DBManagerBase) JoinCurrentMemberToCluster

func (*DBManagerBase) JoinCurrentMemberToCluster(context.Context, *dcs.Cluster) error

func (*DBManagerBase) LeaveMemberFromCluster

func (*DBManagerBase) LeaveMemberFromCluster(context.Context, *dcs.Cluster, string) error

func (*DBManagerBase) MoveData

func (mgr *DBManagerBase) MoveData(context.Context, *dcs.Cluster) error

func (*DBManagerBase) ShutDownWithWait

func (mgr *DBManagerBase) ShutDownWithWait()

func (*DBManagerBase) Start

func (mgr *DBManagerBase) Start(context.Context, *dcs.Cluster) error

func (*DBManagerBase) Stop

func (mgr *DBManagerBase) Stop() error

type FakeManager

type FakeManager struct {
	DBManagerBase
}

func (*FakeManager) CreateRoot

func (*FakeManager) CreateRoot(context.Context) error

func (*FakeManager) Demote

func (*FakeManager) Demote(context.Context) error

func (*FakeManager) Follow

func (*FakeManager) GetHealthiestMember

func (*FakeManager) GetHealthiestMember(*dcs.Cluster, string) *dcs.Member

func (*FakeManager) GetMemberAddrs

func (*FakeManager) GetMemberAddrs(context.Context, *dcs.Cluster) []string

func (*FakeManager) HasOtherHealthyLeader

func (*FakeManager) HasOtherHealthyLeader(context.Context, *dcs.Cluster) *dcs.Member

func (*FakeManager) HasOtherHealthyMembers

func (*FakeManager) HasOtherHealthyMembers(context.Context, *dcs.Cluster, string) []*dcs.Member

func (*FakeManager) InitializeCluster

func (*FakeManager) InitializeCluster(context.Context, *dcs.Cluster) error

func (*FakeManager) IsClusterHealthy

func (*FakeManager) IsClusterHealthy(context.Context, *dcs.Cluster) bool

func (*FakeManager) IsClusterInitialized

func (*FakeManager) IsClusterInitialized(context.Context, *dcs.Cluster) (bool, error)

func (*FakeManager) IsCurrentMemberHealthy

func (*FakeManager) IsCurrentMemberHealthy(context.Context, *dcs.Cluster) bool

func (*FakeManager) IsCurrentMemberInCluster

func (*FakeManager) IsCurrentMemberInCluster(context.Context, *dcs.Cluster) bool

func (*FakeManager) IsDBStartupReady

func (*FakeManager) IsDBStartupReady() bool

func (*FakeManager) IsFirstMember

func (*FakeManager) IsFirstMember() bool

func (*FakeManager) IsLeader

func (*FakeManager) IsLeader(context.Context, *dcs.Cluster) (bool, error)

func (*FakeManager) IsLeaderMember

func (*FakeManager) IsLeaderMember(context.Context, *dcs.Cluster, *dcs.Member) (bool, error)

func (*FakeManager) IsMemberHealthy

func (*FakeManager) IsMemberHealthy(context.Context, *dcs.Cluster, *dcs.Member) bool

func (*FakeManager) IsPromoted

func (*FakeManager) IsPromoted(context.Context) bool

func (*FakeManager) IsRootCreated

func (*FakeManager) IsRootCreated(context.Context) (bool, error)

func (*FakeManager) IsRunning

func (*FakeManager) IsRunning() bool

func (*FakeManager) JoinCurrentMemberToCluster

func (*FakeManager) JoinCurrentMemberToCluster(context.Context, *dcs.Cluster) error

func (*FakeManager) LeaveMemberFromCluster

func (*FakeManager) LeaveMemberFromCluster(context.Context, *dcs.Cluster, string) error

func (*FakeManager) Lock

func (*FakeManager) Promote

func (*FakeManager) Recover

func (*FakeManager) Recover(context.Context) error

func (*FakeManager) Unlock

func (*FakeManager) Unlock(context.Context) error

type Properties

type Properties map[string]string

func GetProperties

func GetProperties(name string) Properties

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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