preparesnap

package
v1.1.0-beta.0...-70f5218 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: Apache-2.0, Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CliEnv

type CliEnv struct {
	Cache *tikv.RegionCache
	Mgr   *utils.StoreManager
}

func (CliEnv) ConnectToStore

func (c CliEnv) ConnectToStore(ctx context.Context, storeID uint64) (PrepareClient, error)

func (CliEnv) GetAllLiveStores

func (c CliEnv) GetAllLiveStores(ctx context.Context) ([]*metapb.Store, error)

func (CliEnv) LoadRegionsInKeyRange

func (c CliEnv) LoadRegionsInKeyRange(ctx context.Context, startKey []byte, endKey []byte) (regions []Region, err error)

type Env

type Env interface {
	ConnectToStore(ctx context.Context, storeID uint64) (PrepareClient, error)
	GetAllLiveStores(ctx context.Context) ([]*metapb.Store, error)

	LoadRegionsInKeyRange(ctx context.Context, startKey, endKey []byte) (regions []Region, err error)
}

type PrepareClient

type PrepareClient interface {
	Send(*brpb.PrepareSnapshotBackupRequest) error
	Recv() (*brpb.PrepareSnapshotBackupResponse, error)
}

func AdaptForGRPCInTest

func AdaptForGRPCInTest(p PrepareClient) PrepareClient

type Preparer

type Preparer struct {

	/* Some configurations. They aren't thread safe.
	   You may need to configure them before starting the Preparer. */
	RetryBackoff  time.Duration
	RetryLimit    int
	LeaseDuration time.Duration

	/* Observers. Initialize them before starting.*/
	AfterConnectionsEstablished func()
	// contains filtered or unexported fields
}

func New

func New(env Env) *Preparer

func (*Preparer) AdvanceState

func (p *Preparer) AdvanceState(ctx context.Context) error

AdvanceState is exported for test usage. This call will check whether now we are safe to forward the whole procedure. If we can, this will set `p.waitApplyFinished` to true. Generally `DriveLoopAndWaitPrepare` is all you need, you may not want to call this.

func (*Preparer) DriveLoopAndWaitPrepare

func (p *Preparer) DriveLoopAndWaitPrepare(ctx context.Context) error

DriveLoopAndWaitPrepare drives the state machine and block the current goroutine until we are safe to start taking snapshot.

After this invoked, you shouldn't share this `Preparer` with any other goroutines.

After this the cluster will enter the land between normal and taking snapshot. This state will continue even this function returns, until `Finalize` invoked. Splitting, ingesting and conf changing will all be blocked.

func (*Preparer) Finalize

func (p *Preparer) Finalize(ctx context.Context) error

Finalize notify the cluster to go back to the normal mode. This will return an error if the cluster has already entered the normal mode when this is called.

func (*Preparer) MarshalLogObject

func (p *Preparer) MarshalLogObject(om zapcore.ObjectEncoder) error

func (*Preparer) PrepareConnections

func (p *Preparer) PrepareConnections(ctx context.Context) error

PrepareConnections prepares the connections for each store. This will pause the admin commands for each store.

func (*Preparer) WaitAndHandleNextEvent

func (p *Preparer) WaitAndHandleNextEvent(ctx context.Context) error

WaitAndHandleNextEvent is exported for test usage. This waits the next event (wait apply done, errors, etc..) of preparing. Generally `DriveLoopAndWaitPrepare` is all you need.

type Region

type Region interface {
	GetMeta() *metapb.Region
	GetLeaderStoreID() uint64
}

type RetryAndSplitRequestEnv

type RetryAndSplitRequestEnv struct {
	Env
	GetBackoffStrategy func() utils.BackoffStrategy
}

func (RetryAndSplitRequestEnv) ConnectToStore

func (r RetryAndSplitRequestEnv) ConnectToStore(ctx context.Context, storeID uint64) (PrepareClient, error)

type SplitRequestClient

type SplitRequestClient struct {
	PrepareClient
	MaxRequestSize int
}

func (SplitRequestClient) Send

Jump to

Keyboard shortcuts

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