keyspan

package
v0.0.0-...-be15534 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMockRegionCache

func NewMockRegionCache() *mockCache

NewMockRegionCache returns a new MockCache.

Types

type Reconciler

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

Reconciler reconciles span and table mapping, make sure spans are in a desired state and covers all table ranges.

func NewReconciler

func NewReconciler(
	changefeedID model.ChangeFeedID,
	up *upstream.Upstream,
	config *config.ChangefeedSchedulerConfig,
) (*Reconciler, error)

NewReconciler returns a Reconciler.

func NewReconcilerForTests

func NewReconcilerForTests(
	cache RegionCache, config *config.ChangefeedSchedulerConfig,
) *Reconciler

NewReconcilerForTests returns a Reconciler.

func (*Reconciler) Reconcile

func (m *Reconciler) Reconcile(
	ctx context.Context,
	currentTables *replication.TableRanges,
	replications *spanz.BtreeMap[*replication.ReplicationSet],
	aliveCaptures map[model.CaptureID]*member.CaptureStatus,
	compat *compat.Compat,
) []tablepb.Span

Reconcile spans that need to be replicated based on current cluster status. It handles following cases: 1. Changefeed initialization 2. Owner switch. 3. Owner switch after some captures fail. 4. Add table by DDL. 5. Drop table by DDL. 6. Some captures fail, does NOT affect spans.

type RegionCache

type RegionCache interface {
	// ListRegionIDsInKeyRange lists ids of regions in [startKey,endKey].
	ListRegionIDsInKeyRange(
		bo *tikv.Backoffer, startKey, endKey []byte,
	) (regionIDs []uint64, err error)
	// LocateRegionByID searches for the region with ID.
	LocateRegionByID(bo *tikv.Backoffer, regionID uint64) (*tikv.KeyLocation, error)
}

RegionCache is a simplified interface of tikv.RegionCache. It is useful to restrict RegionCache usage and mocking in tests.

Jump to

Keyboard shortcuts

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