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 ¶
- func BootstrapCluster(clusterID string, engines []engine.Engine, stopper *util.Stopper) (*client.KV, error)
- func RunGetAcct(ctx *Context, keyPrefix string)
- func RunGetPerm(ctx *Context, keyPrefix string)
- func RunGetZone(ctx *Context, keyPrefix string)
- func RunLsAcct(ctx *Context, pattern string)
- func RunLsPerm(ctx *Context, pattern string)
- func RunLsZone(ctx *Context, pattern string)
- func RunRmAcct(ctx *Context, keyPrefix string)
- func RunRmPerm(ctx *Context, keyPrefix string)
- func RunRmZone(ctx *Context, keyPrefix string)
- func RunSetAcct(ctx *Context, keyPrefix, configFileName string)
- func RunSetPerm(ctx *Context, keyPrefix, configFileName string)
- func RunSetZone(ctx *Context, keyPrefix, configFileName string)
- func SendQuit(ctx *Context) error
- type Context
- type Node
- type Server
- type TestServer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BootstrapCluster ¶
func BootstrapCluster(clusterID string, engines []engine.Engine, stopper *util.Stopper) (*client.KV, error)
BootstrapCluster bootstraps a multiple stores using the provided engines and cluster ID. The first 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 ¶
RunGetAcct gets the account from the given key.
func RunGetPerm ¶
RunGetPerm gets the permission from the given key.
func RunGetZone ¶
RunGetZone gets the zone from the given key.
func RunSetAcct ¶
RunSetAcct sets the account to the key given the yaml filename.
func RunSetPerm ¶
RunSetPerm sets the permission to the key given the yaml filename.
func RunSetZone ¶
RunSetZone sets the zone to the key given the yaml filename.
Types ¶
type Context ¶
type Context struct { // Embed the base context. base.Context // Addr is the host:port to bind for HTTP/RPC traffic. Addr 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 // 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 // Enables the experimental RPC server for use by the experimental // RPC client. ExperimentalRPCServer 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 // GossipBootstrapResolvers is a list of gossip resolvers used // to find bootstrap nodes for connecting to the gossip network. GossipBootstrapResolvers []util.Resolver // ScanInterval determines a duration during which each range should be // visited approximately once by the range scanner. ScanInterval time.Duration // MetricsFrequency determines the frequency at which the server should // record internal metrics. MetricsFrequency time.Duration }
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 NewTestContext ¶
func NewTestContext() *Context
NewTestContext returns a context for testing. It overrides the Certs with the test certs directory. We need to override the certs loader.
type Node ¶
type Node struct { ClusterID string // UUID for Cockroach cluster Descriptor proto.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.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the cockroach server node.
func (*Server) ServeHTTP ¶
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP is necessary to implement the http.Handler interface. It will snappy a response if the appropriate request headers are set.
type TestServer ¶
type TestServer struct { // Ctx is the context used by this server. Ctx *Context SkipBootstrap bool // server is the embedded Cockroach server struct. *Server StoresPerNode int // Engines underlying the test server. Engines []engine.Engine }
A TestServer encapsulates an in-memory instantiation of a cockroach node with a single store. Example usage of a TestServer follows:
s := server.StartTestServer(t) defer s.Stop()
func StartTestServer ¶
func StartTestServer(t util.Tester) *TestServer
StartTestServer starts a in-memory test server.
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) ServingAddr ¶
func (ts *TestServer) ServingAddr() string
ServingAddr returns the rpc server's address. Should be used by clients.
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.ServingAddr() after Start() for client connections. Use Stop() to shutdown the server after the test completes.