Documentation ¶
Index ¶
- func IsUnavailableError(err error) bool
- func MakePerNodeFixedPortsCfg(numNodes int) map[int]NodeConfig
- type Cluster
- func (c *Cluster) Client(idx int) *client.DB
- func (c *Cluster) Close()
- func (c *Cluster) HTTPPort(nodeIdx int) string
- func (c *Cluster) IPAddr(nodeIdx int) string
- func (c *Cluster) RPCPort(nodeIdx int) string
- func (c *Cluster) RandNode(f func(int) int) int
- func (c *Cluster) Split(nodeIdx int, splitKey roachpb.Key) error
- func (c *Cluster) Start(ctx context.Context)
- func (c *Cluster) TransferLease(nodeIdx int, r *rand.Rand, key roachpb.Key) (bool, error)
- func (c *Cluster) UpdateZoneConfig(rangeMinBytes, rangeMaxBytes int64)
- type ClusterConfig
- type LocalCluster
- func (b *LocalCluster) Addr(ctx context.Context, i int, port string) string
- func (b *LocalCluster) Assert(ctx context.Context, t testing.TB)
- func (b *LocalCluster) AssertAndStop(ctx context.Context, t testing.TB)
- func (b *LocalCluster) ExecCLI(ctx context.Context, i int, cmd []string) (string, string, error)
- func (b *LocalCluster) Hostname(i int) string
- func (b *LocalCluster) InternalIP(ctx context.Context, i int) net.IP
- func (b *LocalCluster) Kill(ctx context.Context, i int) error
- func (b *LocalCluster) NewClient(ctx context.Context, i int) (*client.DB, error)
- func (b *LocalCluster) NumNodes() int
- func (b *LocalCluster) PGUrl(ctx context.Context, i int) string
- func (b *LocalCluster) Port(ctx context.Context, i int) string
- func (b *LocalCluster) Restart(ctx context.Context, i int) error
- func (b *LocalCluster) RestartAsync(ctx context.Context, i int) <-chan error
- func (b *LocalCluster) URL(ctx context.Context, i int) string
- type Node
- func (n *Node) Alive() bool
- func (n *Node) Client() *client.DB
- func (n *Node) DB() *gosql.DB
- func (n *Node) HTTPPort() string
- func (n *Node) IPAddr() string
- func (n *Node) Kill()
- func (n *Node) PGUrl() string
- func (n *Node) RPCAddr() string
- func (n *Node) RPCPort() string
- func (n *Node) Start(ctx context.Context, joins ...string)
- func (n *Node) StartAsync(ctx context.Context, joins ...string) <-chan error
- func (n *Node) StatusClient() serverpb.StatusClient
- type NodeConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsUnavailableError ¶
IsUnavailableError returns true iff the error corresponds to a GRPC connection unavailable error.
func MakePerNodeFixedPortsCfg ¶
func MakePerNodeFixedPortsCfg(numNodes int) map[int]NodeConfig
MakePerNodeFixedPortsCfg makes a PerNodeCfg map of the given number of nodes with odd ports starting at 26257 for the RPC endpoint, and even points for the ui.
Types ¶
type Cluster ¶
type Cluster struct { Nodes []*Node // 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 (*Cluster) Close ¶
func (c *Cluster) Close()
Close stops the cluster, killing all of the nodes.
func (*Cluster) HTTPPort ¶
HTTPPort returns the HTTP port of the specified node. Returns zero if unknown.
func (*Cluster) RPCPort ¶
RPCPort returns the RPC port of the specified node. Returns zero if unknown.
func (*Cluster) Start ¶
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 ¶
TransferLease transfers the lease for the range containing key to a random alive node in the range.
func (*Cluster) UpdateZoneConfig ¶
UpdateZoneConfig updates the default zone config for the cluster.
type ClusterConfig ¶
type ClusterConfig struct { Ephemeral bool // when true, wipe DataDir on Close() Binary string // path to cockroach, defaults go <cockroach_repo>/cockroach AllNodeArgs []string // args to pass to ./cockroach on all nodes NumNodes int // number of nodes in the cluster DataDir string // node i will use storage DataDir/<i> LogDir string // when empty, node i defaults to DataDir/<i>/logs PerNodeCfg map[int]NodeConfig // optional map of nodeIndex -> configuration DB string // database to configure DB connection for NumWorkers int // SetMaxOpenConns to use for DB connection }
A ClusterConfig holds the configuration for a Cluster.
type LocalCluster ¶
type LocalCluster struct {
*Cluster
}
LocalCluster implements cluster.Cluster.
func (*LocalCluster) Assert ¶
func (b *LocalCluster) Assert(ctx context.Context, t testing.TB)
Assert implements cluster.Cluster.
func (*LocalCluster) AssertAndStop ¶
func (b *LocalCluster) AssertAndStop(ctx context.Context, t testing.TB)
AssertAndStop implements cluster.Cluster.
func (*LocalCluster) Hostname ¶
func (b *LocalCluster) Hostname(i int) string
Hostname implements cluster.Cluster.
func (*LocalCluster) InternalIP ¶
InternalIP implements cluster.Cluster.
func (*LocalCluster) Kill ¶
func (b *LocalCluster) Kill(ctx context.Context, i int) error
Kill implements cluster.Cluster.
func (*LocalCluster) NumNodes ¶
func (b *LocalCluster) NumNodes() int
NumNodes implements cluster.Cluster.
func (*LocalCluster) PGUrl ¶
func (b *LocalCluster) PGUrl(ctx context.Context, i int) string
PGUrl implements cluster.Cluster.
func (*LocalCluster) Port ¶
func (b *LocalCluster) Port(ctx context.Context, i int) string
Port implements cluster.Cluster.
func (*LocalCluster) Restart ¶
func (b *LocalCluster) Restart(ctx context.Context, i int) error
Restart implements cluster.Cluster.
func (*LocalCluster) RestartAsync ¶
func (b *LocalCluster) RestartAsync(ctx context.Context, i int) <-chan error
RestartAsync restarts the node. The returned channel receives an error or, once the node is successfully connected to the cluster and serving, nil.
type Node ¶
type Node struct { Cfg NodeConfig 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 ¶
Alive returns true if the node is alive (i.e. not stopped). Note that a paused node is considered alive.
func (*Node) IPAddr ¶
IPAddr returns the node's listening address (for ui, inter-node, cli, and Postgres alike).
func (*Node) RPCAddr ¶
RPCAddr returns the RPC + Postgres address, or an empty string if it is not known (for instance since the node is down).
func (*Node) StartAsync ¶
StartAsync starts a node asynchronously. It returns a channel that receives either an error, or, once the node has started up and is fully functional, `nil`.
StartAsync is a no-op if the node is already running.
func (*Node) StatusClient ¶
func (n *Node) StatusClient() serverpb.StatusClient
StatusClient returns a StatusClient set up to talk to this node.
type NodeConfig ¶
type NodeConfig struct { Binary string // when specified, overrides the node's binary DataDir string // when specified, overrides the node's data dir LogDir string // when specified, overrides the node's log dir Addr string // listening host, defaults to 127.0.0.1 ExtraArgs []string // extra arguments for ./cockroach start ExtraEnv []string // environment variables in format key=value RPCPort, HTTPPort int // zero for auto-assign DB string // see ClusterConfig NumWorkers int // see ClusterConfig }
NodeConfig is a configuration for a node in a Cluster. Options with the zero value are typically populated from the corresponding Cluster's ClusterConfig.
Directories ¶
Path | Synopsis |
---|---|
Package tc contains utility methods for using the Linux tc (traffic control) command to mess with the network links between cockroach nodes running on the local machine.
|
Package tc contains utility methods for using the Linux tc (traffic control) command to mess with the network links between cockroach nodes running on the local machine. |