faketikv

package
v2.0.5+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2018 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	GetClusterID(ctx context.Context) uint64
	AllocID(ctx context.Context) (uint64, error)
	Bootstrap(ctx context.Context, store *metapb.Store, region *metapb.Region) error
	PutStore(ctx context.Context, store *metapb.Store) error
	StoreHeartbeat(ctx context.Context, stats *pdpb.StoreStats) error
	RegionHeartbeat(ctx context.Context, region *core.RegionInfo) error
	Close()
}

Client is a PD (Placement Driver) client. It should not be used after calling Close().

func NewClient

func NewClient(pdAddr string, tag string) (Client, <-chan *pdpb.RegionHeartbeatResponse, error)

NewClient creates a PD client.

type ClusterInfo

type ClusterInfo struct {
	*core.RegionsInfo
	Nodes map[uint64]*Node
	// contains filtered or unexported fields
}

ClusterInfo records all cluster information.

func NewClusterInfo

func NewClusterInfo(pdAddr string, conf *cases.Conf) (*ClusterInfo, error)

NewClusterInfo creates the initialized cluster with config.

func (*ClusterInfo) AddTask

func (c *ClusterInfo) AddTask(task Task)

AddTask adds task in specify node.

func (*ClusterInfo) GetBootstrapInfo

func (c *ClusterInfo) GetBootstrapInfo() (*metapb.Store, *metapb.Region, error)

GetBootstrapInfo returns a valid bootstrap store and region.

type Config

type Config struct {
}

Config is the faketikv configuration.

type Driver

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

Driver promotes the cluster status change.

func NewDriver

func NewDriver(addr string, confName string) *Driver

NewDriver returns a driver.

func (*Driver) AddNode

func (d *Driver) AddNode(id uint64)

AddNode adds new node.

func (*Driver) Check

func (d *Driver) Check() bool

Check checks if the simulation is completed.

func (*Driver) DeleteNode

func (d *Driver) DeleteNode()

DeleteNode deletes a node.

func (*Driver) Prepare

func (d *Driver) Prepare() error

Prepare initializes cluster information, bootstraps cluster and starts nodes.

func (*Driver) Stop

func (d *Driver) Stop()

Stop stops all nodes.

func (*Driver) Tick

func (d *Driver) Tick()

Tick invokes nodes' Tick.

func (*Driver) TickCount

func (d *Driver) TickCount() int64

TickCount returns the simulation's tick count.

type Node

type Node struct {
	*metapb.Store
	sync.RWMutex
	// contains filtered or unexported fields
}

Node simulates a TiKV.

func NewNode

func NewNode(id uint64, addr string, pdAddr string) (*Node, error)

NewNode returns a Node.

func (*Node) AddTask

func (n *Node) AddTask(task Task)

AddTask adds task in this node.

func (*Node) GetState

func (n *Node) GetState() NodeState

GetState returns current node state.

func (*Node) Start

func (n *Node) Start() error

Start starts the node.

func (*Node) Stop

func (n *Node) Stop()

Stop stops this node.

func (*Node) Tick

func (n *Node) Tick()

Tick steps node status change.

type NodeState

type NodeState int

NodeState node's state.

const (
	Up NodeState = iota
	Down
	LossConnect
	Block
)

some state

type Task

type Task interface {
	Desc() string
	RegionID() uint64
	Step(cluster *ClusterInfo)
	TargetStoreID() uint64
	IsFinished() bool
}

Task running in node.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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