localcluster

package
v0.0.0-...-b3f1699 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2017 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsUnavailableError

func IsUnavailableError(err error) bool

IsUnavailableError returns true iff the error corresponds to a GRPC connection unavailable error.

Types

type Cluster

type Cluster struct {
	Nodes   []*Node
	Clients []*client.DB
	Status  []serverpb.StatusClient
	DB      []*gosql.DB
	// contains filtered or unexported fields
}

Cluster holds the state for a local cluster, providing methods for common operations, access to the underlying nodes and per-node KV and SQL clients.

func New

func New(size int) *Cluster

New creates a cluster of size nodes.

func (*Cluster) Close

func (c *Cluster) Close()

Close stops the cluster, killing all of the nodes.

func (*Cluster) Freeze

func (c *Cluster) Freeze(nodeIdx int, freeze bool)

Freeze freezes (or thaws) the cluster. The freeze request is sent to the specified node.

func (*Cluster) HTTPPort

func (c *Cluster) HTTPPort(nodeIdx int) int

HTTPPort returns the HTTP port of the specified node.

func (*Cluster) RPCAddr

func (c *Cluster) RPCAddr(nodeIdx int) string

RPCAddr returns the RPC address of the specified node.

func (*Cluster) RPCPort

func (c *Cluster) RPCPort(nodeIdx int) int

RPCPort returns the RPC port of the specified node.

func (*Cluster) RandNode

func (c *Cluster) RandNode(f func(int) int) int

RandNode returns the index of a random alive node.

func (*Cluster) Split

func (c *Cluster) Split(nodeIdx int, splitKey roachpb.Key) error

Split splits the range containing the split key at the specified split key.

func (*Cluster) Start

func (c *Cluster) Start(
	db string, numWorkers int, env, allNodeArgs []string, perNodeArgs map[int][]string,
)

Start starts a cluster. The numWorkers parameter controls the SQL connection settings to avoid unnecessary connection creation. The allNodeArgs parameter can be used to pass extra arguments to every node. The perNodeArgs parameter can be used to pass extra arguments to an individual node. If not nil, its size must equal the number of nodes.

func (*Cluster) TransferLease

func (c *Cluster) TransferLease(nodeIdx int, r *rand.Rand, key roachpb.Key) (bool, error)

TransferLease transfers the lease for the range containing key to a random alive node in the range.

func (*Cluster) UpdateZoneConfig

func (c *Cluster) UpdateZoneConfig(rangeMinBytes, rangeMaxBytes int64)

UpdateZoneConfig updates the default zone config for the cluster.

type Node

type Node struct {
	syncutil.Mutex
	// contains filtered or unexported fields
}

Node holds the state for a single node in a local cluster and provides methods for starting, pausing, resuming and stopping the node.

func (*Node) Alive

func (n *Node) Alive() bool

Alive returns true if the node is alive (i.e. not stopped). Note that a paused node is considered alive.

func (*Node) Kill

func (n *Node) Kill()

Kill stops a node abruptly by sending it SIGKILL.

func (*Node) Pause

func (n *Node) Pause()

Pause pauses a node by sending it SIGSTOP.

func (*Node) Resume

func (n *Node) Resume()

Resume resumes a node by sending it SIGCONT.

func (*Node) Start

func (n *Node) Start()

Start starts a node.

Jump to

Keyboard shortcuts

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