localcluster

package
v0.0.0-...-005594a Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CockroachBin = func() string {
	bin := "./cockroach"
	if _, err := os.Stat(bin); os.IsNotExist(err) {
		bin = "cockroach"
	} else if err != nil {
		panic(err)
	}
	return bin
}()

CockroachBin is the path to the cockroach binary.

Functions

func HTTPPort

func HTTPPort(nodeIdx int) int

HTTPPort returns the HTTP port of the specified node.

func IsUnavailableError

func IsUnavailableError(err error) bool

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

func RPCPort

func RPCPort(nodeIdx int) int

RPCPort returns the RPC port of the specified node.

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, separateAddrs bool) *Cluster

New creates a cluster of size nodes. separateAddrs controls whether all the nodes use the same localhost IP address (127.0.0.1) or separate addresses (e.g. 127.1.1.1, 127.1.1.2, etc).

func (*Cluster) Close

func (c *Cluster) Close()

Close stops the cluster, killing all of the nodes.

func (*Cluster) IPAddr

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

IPAddr returns the IP address 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) 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,
	binary string,
	allNodeArgs []string,
	perNodeArgs, perNodeEnv 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) 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