server

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

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

Go to latest
Published: Mar 25, 2015 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Overview

Package server implements the Cockroach storage node. A node corresponds to a single instance of the cockroach binary, running on a single physical machine, which exports the "Node" Go RPC service. Each node multiplexes RPC requests to one or more stores, associated with physical storage devices.

Package server also provides access to administrative tools via the command line and also through a REST API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BootstrapCluster

func BootstrapCluster(clusterID string, eng engine.Engine) (*client.KV, error)

BootstrapCluster bootstraps a store using the provided engine and cluster ID. The bootstrapped store contains a single range spanning all keys. Initial range lookup metadata is populated for the range.

Returns a KV client for unittest purposes. Caller should close the returned client.

func RunGetAcct

func RunGetAcct(ctx *Context, keyPrefix string)

RunGetAcct gets the account from the given key.

func RunGetPerm

func RunGetPerm(ctx *Context, keyPrefix string)

RunGetPerm gets the permission from the given key.

func RunGetZone

func RunGetZone(ctx *Context, keyPrefix string)

RunGetZone gets the zone from the given key.

func RunLsAcct

func RunLsAcct(ctx *Context, pattern string)

RunLsAcct lists accounts.

func RunLsPerm

func RunLsPerm(ctx *Context, pattern string)

RunLsPerm lists permissions.

func RunLsZone

func RunLsZone(ctx *Context, pattern string)

RunLsZone lists zones.

func RunRmAcct

func RunRmAcct(ctx *Context, keyPrefix string)

RunRmAcct removes the account with the given key.

func RunRmPerm

func RunRmPerm(ctx *Context, keyPrefix string)

RunRmPerm removes the permission with the given key.

func RunRmZone

func RunRmZone(ctx *Context, keyPrefix string)

RunRmZone removes the zone with the given key.

func RunSetAcct

func RunSetAcct(ctx *Context, keyPrefix, configFileName string)

RunSetAcct sets the account to the key given the yaml filename.

func RunSetPerm

func RunSetPerm(ctx *Context, keyPrefix, configFileName string)

RunSetPerm sets the permission to the key given the yaml filename.

func RunSetZone

func RunSetZone(ctx *Context, keyPrefix, configFileName string)

RunSetZone sets the zone to the key given the yaml filename.

Types

type Context

type Context struct {
	// RPC is the "host:port" to bind for RPC traffic.
	RPC string

	// HTTP is the "host:port to bind for HTTP traffic.
	HTTP string

	// Addr is the address for connection to cockroach cluster.
	Addr string

	// Certs specifies a directory containing RSA key and x509 certs.
	Certs string

	// Stores is specified to enable durable key-value storage.
	// Memory-backed key value stores may be optionally specified
	// via mem=<integer byte size>.
	//
	// Stores specify a comma-separated list of stores specified by a
	// colon-separated list of device attributes followed by '=' and
	// either a filepath for a persistent store or an integer size in bytes for an
	// in-memory store. Device attributes typically include whether the store is
	// flash (ssd), spinny disk (hdd), fusion-io (fio), in-memory (mem); device
	// attributes might also include speeds and other specs (7200rpm, 200kiops, etc.).
	// For example, -store=hdd:7200rpm=/mnt/hda1,ssd=/mnt/ssd01,ssd=/mnt/ssd02,mem=1073741824
	Stores string

	// Attrs specifies a colon-separated list of node topography or machine
	// capabilities, used to match capabilities or location preferences specified
	// in zone configs.
	Attrs string

	// Maximum clock offset for the cluster.
	MaxOffset time.Duration

	// BootstrapOnly signals to only bootstrap and not start the server.
	BootstrapOnly bool

	// GossipBootstrap is a comma-separated list of node addresses that
	// act as bootstrap hosts for connecting to the gossip network.
	GossipBootstrap string

	// GossipInterval is a time interval specifying how often gossip is
	// communicated between hosts on the gossip network.
	GossipInterval time.Duration

	// Enables linearizable behaviour of operations on this node by making sure
	// that no commit timestamp is reported back to the client until all other
	// node clocks have necessarily passed it.
	Linearizable bool

	// CacheSize is the amount of memory in bytes to use for caching data.
	// The value is split evenly between the stores if there are more than one.
	CacheSize int64

	// Engines is the storage instances specified by Stores.
	Engines []engine.Engine

	// NodeAttributes is the parsed representation of Attrs.
	NodeAttributes proto.Attributes
}

Context holds parameters needed to setup a server. Calling "server/cli".InitFlags(ctx *Context) will initialize Context using command flags. Keep in sync with "server/cli/flags.go".

func NewContext

func NewContext() *Context

NewContext returns a Context with default values.

func (*Context) Init

func (ctx *Context) Init() error

Init interprets the stores parameter to initialize a slice of engine.Engine objects and parses node attributes.

type Node

type Node struct {
	ClusterID  string                 // UUID for Cockroach cluster
	Descriptor storage.NodeDescriptor // Node ID, network/physical topology
	// contains filtered or unexported fields
}

A Node manages a map of stores (by store ID) for which it serves traffic. A node is the top-level data structure. There is one node instance per process. A node accepts incoming RPCs and services them by directing the commands contained within RPCs to local stores, which in turn direct the commands to specific ranges. Each node has access to the global, monolithic Key-Value abstraction via its kv.DB reference. Nodes use this to allocate node and store IDs for bootstrapping the node itself or new stores as they're added on subsequent instantiations.

func NewNode

func NewNode(db *client.KV, gossip *gossip.Gossip, storeConfig storage.StoreConfig) *Node

NewNode returns a new instance of Node, interpreting command line flags to initialize the appropriate Store or set of Stores. Registers the storage instance for the RPC service "Node".

func (*Node) AdminSplit

func (n *Node) AdminSplit(args *proto.AdminSplitRequest, reply *proto.AdminSplitResponse) error

AdminSplit .

func (*Node) ConditionalPut

func (n *Node) ConditionalPut(args *proto.ConditionalPutRequest, reply *proto.ConditionalPutResponse) error

ConditionalPut .

func (*Node) Contains

func (n *Node) Contains(args *proto.ContainsRequest, reply *proto.ContainsResponse) error

Contains .

func (*Node) Delete

func (n *Node) Delete(args *proto.DeleteRequest, reply *proto.DeleteResponse) error

Delete .

func (*Node) DeleteRange

func (n *Node) DeleteRange(args *proto.DeleteRangeRequest, reply *proto.DeleteRangeResponse) error

DeleteRange .

func (*Node) EndTransaction

func (n *Node) EndTransaction(args *proto.EndTransactionRequest, reply *proto.EndTransactionResponse) error

EndTransaction .

func (*Node) EnqueueMessage

func (n *Node) EnqueueMessage(args *proto.EnqueueMessageRequest, reply *proto.EnqueueMessageResponse) error

EnqueueMessage .

func (*Node) EnqueueUpdate

func (n *Node) EnqueueUpdate(args *proto.EnqueueUpdateRequest, reply *proto.EnqueueUpdateResponse) error

EnqueueUpdate .

func (*Node) Get

func (n *Node) Get(args *proto.GetRequest, reply *proto.GetResponse) error

Get .

func (*Node) Increment

func (n *Node) Increment(args *proto.IncrementRequest, reply *proto.IncrementResponse) error

Increment .

func (*Node) InternalGC

func (n *Node) InternalGC(args *proto.InternalGCRequest, reply *proto.InternalGCResponse) error

InternalGC .

func (*Node) InternalHeartbeatTxn

func (n *Node) InternalHeartbeatTxn(args *proto.InternalHeartbeatTxnRequest, reply *proto.InternalHeartbeatTxnResponse) error

InternalHeartbeatTxn .

func (*Node) InternalMerge

func (n *Node) InternalMerge(args *proto.InternalMergeRequest, reply *proto.InternalMergeResponse) error

InternalMerge .

func (*Node) InternalPushTxn

func (n *Node) InternalPushTxn(args *proto.InternalPushTxnRequest, reply *proto.InternalPushTxnResponse) error

InternalPushTxn .

func (*Node) InternalRangeLookup

func (n *Node) InternalRangeLookup(args *proto.InternalRangeLookupRequest, reply *proto.InternalRangeLookupResponse) error

InternalRangeLookup .

func (*Node) InternalResolveIntent

func (n *Node) InternalResolveIntent(args *proto.InternalResolveIntentRequest, reply *proto.InternalResolveIntentResponse) error

InternalResolveIntent .

func (*Node) InternalTruncateLog

func (n *Node) InternalTruncateLog(args *proto.InternalTruncateLogRequest, reply *proto.InternalTruncateLogResponse) error

InternalTruncateLog .

func (*Node) Put

func (n *Node) Put(args *proto.PutRequest, reply *proto.PutResponse) error

Put .

func (*Node) ReapQueue

func (n *Node) ReapQueue(args *proto.ReapQueueRequest, reply *proto.ReapQueueResponse) error

ReapQueue .

func (*Node) Scan

func (n *Node) Scan(args *proto.ScanRequest, reply *proto.ScanResponse) error

Scan .

type Server

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

Server is the cockroach server node.

func NewServer

func NewServer(ctx *Context) (*Server, error)

NewServer creates a Server from a server.Context.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP is necessary to implement the http.Handler interface. It will gzip a response if the appropriate request headers are set.

func (*Server) Start

func (s *Server) Start(selfBootstrap bool) error

Start runs the RPC and HTTP servers, starts the gossip instance (if selfBootstrap is true, uses the rpc server's address as the gossip bootstrap), and starts the node using the supplied engines slice.

func (*Server) Stop

func (s *Server) Stop()

Stop stops the server.

type TestServer

type TestServer struct {
	// CertDir specifies the directory containing certs for SSL
	// connections. Default will load insecure TLS config.
	CertDir string
	// MaxOffset is the maximum offset for clocks in the cluster.
	// This is mostly irrelevant except when testing reads within
	// uncertainty intervals.
	MaxOffset time.Duration
	// HTTPAddr and RPCAddr default to localhost with port set
	// at time of call to Start() to an available port.
	HTTPAddr, RPCAddr string
	// server is the embedded Cockroach server struct.
	*Server
}

A TestServer encapsulates an in-memory instantiation of a cockroach node with a single store. Example usage of a TestServer follows:

s := &server.TestServer{}
if err := s.Start(); err != nil {
  t.Fatal(err)
}
defer s.Stop()

TODO(spencer): add support for multiple stores.

func (*TestServer) Clock

func (ts *TestServer) Clock() *hlc.Clock

Clock returns the clock used by the TestServer.

func (*TestServer) Gossip

func (ts *TestServer) Gossip() *gossip.Gossip

Gossip returns the gossip instance used by the TestServer.

func (*TestServer) SetRangeRetryOptions

func (ts *TestServer) SetRangeRetryOptions(ro util.RetryOptions)

SetRangeRetryOptions sets the retry options for stores in TestServer.

func (*TestServer) Start

func (ts *TestServer) Start() error

Start starts the TestServer by bootstrapping an in-memory store (defaults to maximum of 100M). The server is started, launching the node RPC server and all HTTP endpoints. Use the value of TestServer.HTTPAddr after Start() for client connections.

func (*TestServer) Stop

func (ts *TestServer) Stop()

Stop stops the TestServer.

Directories

Path Synopsis
Package status defines the data types of cluster-wide and per-node status responses.
Package status defines the data types of cluster-wide and per-node status responses.

Jump to

Keyboard shortcuts

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