server

package
v0.0.0-...-d3306dc Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2014 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Package server implements a basic HTTP server for interacting with a node.

Index

Constants

This section is empty.

Variables

View Source
var CmdGetZone = &commander.Command{
	UsageLine: "get-zone [options] <key-prefix>",
	Short:     "fetches and displays the zone config",
	Long: `
Fetches and displays the zone configuration for <key-prefix>. The key
prefix should be escaped via URL query escaping if it contains
non-ascii bytes or spaces.
`,
	Run:  runGetZones,
	Flag: *flag.CommandLine,
}

A CmdGetZone command displays the zone config for the specified prefix.

View Source
var CmdInit = &commander.Command{
	UsageLine: "init <bootstrap store>",
	Short:     "init new Cockroach cluster",
	Long: `
Initialize a new Cockroach cluster on this node. The cluster is
started with only a single replica, whose data is stored in the
directory specified by the first argument <bootstrap store>. The
format of the bootstrap store is given by the specification
below. Note that attributes should not specify in-memory ("mem").

  <comma-separated store attributes>=<data dir path>

For example:

  cockroach init hdd,7200rpm=/mnt/hda1

To start the cluster after initialization, run "cockroach start".
`,
	Run:  runInit,
	Flag: *flag.CommandLine,
}

A CmdInit command initializes a new Cockroach cluster.

View Source
var CmdLsZones = &commander.Command{
	UsageLine: "ls-zones [options] [key-regexp]",
	Short:     "list all zone configs by key prefix",
	Long: `
List zone configs. If a regular expression is given, the results of
the listing are filtered by key prefixes matching the regexp. The key
prefix should be escaped via URL query escaping if it contains
non-ascii bytes or spaces.
`,
	Run:  runLsZones,
	Flag: *flag.CommandLine,
}

A CmdLsZones command displays a list of zone configs by prefix.

View Source
var CmdRmZone = &commander.Command{
	UsageLine: "rm-zone [options] <key-prefix>",
	Short:     "remove a zone config by key prefix",
	Long: `
Remove an existing zone config by key prefix. No action is taken if no
zone configuration exists for the specified key prefix. Note that this
command can affect only a single zone config with an exactly matching
prefix. The key prefix should be escaped via URL query escaping if it
contains non-ascii bytes or spaces.
`,
	Run:  runRmZone,
	Flag: *flag.CommandLine,
}

A CmdRmZone command removes a zone config by prefix.

View Source
var CmdSetZone = &commander.Command{
	UsageLine: "set-zone [options] <key-prefix> <zone-config-file>",
	Short:     "create or update zone config for key prefix",
	Long: `
Create or update a zone config for the specified key prefix (first
argument: <key-prefix>) to the contents of the specified file
(second argument: <zone-config-file>). The key prefix should be
escaped via URL query escaping if it contains non-ascii bytes or
spaces.

The zone config format has the following YAML schema:

  replicas:
    - [comma-separated attribute list]
    - ...
  range_min_bytes: <size-in-bytes>
  range_max_bytes: <size-in-bytes>

For example:

  replicas:
    - [us-east-1a, ssd]
    - [us-east-1b, ssd]
    - [us-west-1b, ssd]
  range_min_bytes: 8388608
  range_min_bytes: 67108864

Setting zone configs will guarantee that key ranges will be split
such that no key range straddles two zone config specifications.
This feature can be taken advantage of to pre-split ranges.
`,
	Run:  runSetZone,
	Flag: *flag.CommandLine,
}

A CmdSetZone command creates a new or updates an existing zone config.

View Source
var CmdStart = &commander.Command{
	UsageLine: "start -gossip=host1:port1[,host2:port2...] " +
		"-stores=(ssd=<data-dir>|hdd=<data-dir>|mem=<capacity-in-bytes>)[,...]",
	Short: "start node by joining the gossip network",
	Long: fmt.Sprintf(`

Start Cockroach node by joining the gossip network and exporting key
ranges stored on physical device(s). The gossip network is joined by
contacting one or more well-known hosts specified by the -gossip
command line flag. Every node should be run with the same list of
bootstrap hosts to guarantee a connected network. An alternate
approach is to use a single host for -gossip and round-robin DNS.

Each node exports data from one or more physical devices. These
devices are specified via the -stores command line flag. This is a
comma-separated list of paths to storage directories or for in-memory
stores, the number of bytes. Although the paths should be specified to
correspond uniquely to physical devices, this requirement isn't
strictly enforced.

A node exports an HTTP API with the following endpoints:

  Health check:           /healthz
  Key-value REST:         %s
  Structured Schema REST: %s
`, kv.KVKeyPrefix, structured.StructuredKeyPrefix),
	Run:  runStart,
	Flag: *flag.CommandLine,
}

A CmdStart command starts nodes by joining the gossip network.

Functions

func BootstrapCluster

func BootstrapCluster(clusterID string, engine storage.Engine) (
	*kv.LocalDB, 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 direct-access kv.LocalDB for unittest purposes only.

Types

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 "distDB" 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(distDB kv.DB, gossip *gossip.Gossip) *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) AccumulateTS

func (n *Node) AccumulateTS(args *storage.AccumulateTSRequest, reply *storage.AccumulateTSResponse) error

AccumulateTS .

func (*Node) ConditionalPut

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

ConditionalPut .

func (*Node) Contains

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

Contains .

func (*Node) Delete

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

Delete .

func (*Node) DeleteRange

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

DeleteRange .

func (*Node) EndTransaction

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

EndTransaction .

func (*Node) EnqueueMessage

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

EnqueueMessage .

func (*Node) EnqueueUpdate

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

EnqueueUpdate .

func (*Node) Get

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

Get .

func (*Node) Increment

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

Increment .

func (*Node) InternalRangeLookup

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

InternalRangeLookup .

func (*Node) Put

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

Put .

func (*Node) ReapQueue

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

ReapQueue .

func (*Node) Scan

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

Scan .

Jump to

Keyboard shortcuts

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