unistore

package
v0.0.0-...-503c688 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CheckResourceTagForTopSQLInGoTest bool

CheckResourceTagForTopSQLInGoTest is used to identify whether check resource tag for TopSQL.

View Source
var UnistoreRPCClientSendHook atomic.Pointer[func(*tikvrpc.Request)]

UnistoreRPCClientSendHook exports for test.

Functions

func BootstrapWithMultiRegions

func BootstrapWithMultiRegions(cluster *Cluster, splitKeys ...[]byte) (storeID uint64, regionIDs, peerIDs []uint64)

BootstrapWithMultiRegions initializes a Cluster with multiple Regions and 1 Store. The number of Regions will be len(splitKeys) + 1.

func BootstrapWithMultiStores

func BootstrapWithMultiStores(cluster *Cluster, n int) (storeIDs, peerIDs []uint64, regionID uint64, leaderPeer uint64)

BootstrapWithMultiStores initializes a Cluster with 1 Region and n Stores.

func BootstrapWithSingleStore

func BootstrapWithSingleStore(cluster *Cluster) (storeID, peerID, regionID uint64)

BootstrapWithSingleStore initializes a Cluster with 1 Region and 1 Store.

func New

func New(path string) (*RPCClient, pd.Client, *Cluster, error)

New creates an embed unistore client, pd client and cluster handler.

Types

type Cluster

type Cluster struct {
	*us.MockRegionManager
	// contains filtered or unexported fields
}

Cluster simulates a TiKV cluster. It focuses on management and the change of meta data. A Cluster mainly includes following 3 kinds of meta data:

  1. Region: A Region is a fragment of TiKV's data whose range is [start, end). The data of a Region is duplicated to multiple Peers and distributed in multiple Stores.
  2. Peer: A Peer is a replica of a Region's data. All peers of a Region form a group, each group elects a Leader to provide services.
  3. Store: A Store is a storage/service node. Try to think it as a TiKV server process. Only the store with request's Region's leader Peer could respond to client's request.

func (*Cluster) ScheduleDelay

func (c *Cluster) ScheduleDelay(startTS, regionID uint64, dur time.Duration)

ScheduleDelay schedules a delay event for a transaction on a region.

func (*Cluster) SplitKeys

func (c *Cluster) SplitKeys(start, end []byte, count int)

SplitKeys evenly splits the start, end key into "count" regions.

func (*Cluster) SplitRaw

func (c *Cluster) SplitRaw(regionID, newRegionID uint64, rawKey []byte, peerIDs []uint64, leaderPeerID uint64) *metapb.Region

SplitRaw splits region for raw KV.

type RPCClient

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

RPCClient sends kv RPC calls to mock cluster. RPCClient mocks the behavior of a rpc client at tikv's side.

func (*RPCClient) Close

func (c *RPCClient) Close() error

Close closes RPCClient and cleanup temporal resources.

func (*RPCClient) CloseAddr

func (c *RPCClient) CloseAddr(addr string) error

CloseAddr implements tikv.Client interface and it does nothing.

func (*RPCClient) SendRequest

func (c *RPCClient) SendRequest(ctx context.Context, addr string, req *tikvrpc.Request, timeout time.Duration) (*tikvrpc.Response, error)

SendRequest sends a request to mock cluster.

Directories

Path Synopsis
util

Jump to

Keyboard shortcuts

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