base

package
v0.0.0-...-0a6799f Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2016 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// From IANA Service Name and Transport Protocol Port Number Registry. See
	// https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml?search=cockroachdb
	DefaultPort = "26257"

	// The default port for HTTP-for-humans.
	DefaultHTTPPort = "8080"

	// NetworkTimeout is the timeout used for network operations.
	NetworkTimeout = 3 * time.Second

	// DefaultRaftTickInterval is the default resolution of the Raft timer.
	DefaultRaftTickInterval = 200 * time.Millisecond
)

Base config defaults.

View Source
const (
	// DefaultHeartbeatInterval is how often heartbeats are sent from the
	// transaction coordinator to a live transaction. These keep it from
	// being preempted by other transactions writing the same keys. If a
	// transaction fails to be heartbeat within 2x the heartbeat interval,
	// it may be aborted by conflicting txns.
	DefaultHeartbeatInterval = 5 * time.Second

	// SlowRequestThreshold is the amount of time to wait before considering a
	// request to be "slow".
	SlowRequestThreshold = 60 * time.Second
)
View Source
const MinimumStoreSize = 10 * 64 << 20

MinimumStoreSize is the smallest size in bytes that a store can have. This number is based on config's defaultZoneConfig's RangeMaxBytes, which is extremely stable. To avoid adding the dependency on config here, it is just hard coded to 640MiB.

Variables

View Source
var DefaultTestStoreSpec = StoreSpec{
	SizeInBytes: 100 << 20,
	InMemory:    true,
}

DefaultTestStoreSpec is just a single in memory store of 100 MiB with no special attributes.

Functions

func DefaultRetryOptions

func DefaultRetryOptions() retry.Options

DefaultRetryOptions should be used for retrying most network-dependent operations.

Types

type Config

type Config struct {
	// Insecure specifies whether to use SSL or not.
	// This is really not recommended.
	Insecure bool

	// SSLCA and others contain the paths to the ssl certificates and keys.
	SSLCA      string // CA certificate
	SSLCAKey   string // CA key (to sign only)
	SSLCert    string // Client/server certificate
	SSLCertKey string // Client/server key

	// User running this process. It could be the user under which
	// the server is running or the user passed in client calls.
	User string

	// Addr is the address the server is listening on.
	Addr string

	// AdvertiseAddr is the address advertised by the server to other nodes
	// in the cluster. It should be reachable by all other nodes and should
	// route to an interface that Addr is listening on.
	AdvertiseAddr string

	// HTTPAddr is server's public HTTP address.
	//
	// This is temporary, and will be removed when grpc.(*Server).ServeHTTP
	// performance problems are addressed upstream.
	//
	// See https://github.com/grpc/grpc-go/issues/586.
	HTTPAddr string
	// contains filtered or unexported fields
}

Config is embedded by server.Config. A base config is not meant to be used directly, but embedding configs should call cfg.InitDefaults().

func (*Config) AdminURL

func (cfg *Config) AdminURL() string

AdminURL returns the URL for the admin UI.

func (*Config) GetClientTLSConfig

func (cfg *Config) GetClientTLSConfig() (*tls.Config, error)

GetClientTLSConfig returns the client TLS config, initializing it if needed. If Insecure is true, return a nil config, otherwise load a config based on the SSLCert file. If SSLCert is empty, use a very permissive config. TODO(marc): empty SSLCert should fail when client certificates are required.

func (*Config) GetHTTPClient

func (cfg *Config) GetHTTPClient() (http.Client, error)

GetHTTPClient returns the http client, initializing it if needed. It uses the client TLS config.

func (*Config) GetServerTLSConfig

func (cfg *Config) GetServerTLSConfig() (*tls.Config, error)

GetServerTLSConfig returns the server TLS config, initializing it if needed. If Insecure is true, return a nil config, otherwise load a config based on the SSLCert file. Fails if Insecure=false and SSLCert="".

func (*Config) HTTPRequestScheme

func (cfg *Config) HTTPRequestScheme() string

HTTPRequestScheme returns "http" or "https" based on the value of Insecure.

func (*Config) InitDefaults

func (cfg *Config) InitDefaults()

InitDefaults sets up the default values for a config.

func (*Config) PGURL

func (cfg *Config) PGURL(user *url.Userinfo) (*url.URL, error)

PGURL returns the URL for the postgres endpoint.

type JoinListType

type JoinListType []string

JoinListType is a slice of strings that implements pflag's value interface.

func (*JoinListType) Set

func (jls *JoinListType) Set(value string) error

Set adds a new value to the JoinListType. It is the important part of pflag's value interface.

func (JoinListType) String

func (jls JoinListType) String() string

String returns a string representation of all the JoinListType. This is part of pflag's value interface.

func (*JoinListType) Type

func (jls *JoinListType) Type() string

Type returns the underlying type in string form. This is part of pflag's value interface.

type ModuleTestingKnobs

type ModuleTestingKnobs interface {
	// ModuleTestingKnobs is a dummy function.
	ModuleTestingKnobs()
}

ModuleTestingKnobs is an interface for testing knobs for a submodule.

type NodeIDContainer

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

NodeIDContainer is used to share a single roachpb.NodeID instance between multiple layers. It allows setting and getting the value. Once a value is set, the value cannot change.

func (*NodeIDContainer) Get

func (n *NodeIDContainer) Get() roachpb.NodeID

Get returns the current node ID; 0 if it is unset.

func (*NodeIDContainer) Reset

func (n *NodeIDContainer) Reset(val roachpb.NodeID)

Reset changes the NodeID regardless of the old value.

Should only be used in testing code.

func (*NodeIDContainer) Set

func (n *NodeIDContainer) Set(ctx context.Context, val roachpb.NodeID)

Set sets the current node ID. If it is already set, the value must match.

func (*NodeIDContainer) String

func (n *NodeIDContainer) String() string

String returns the node ID, or "?" if it is unset.

type ReplicationTarget

type ReplicationTarget struct {
	NodeID  roachpb.NodeID
	StoreID roachpb.StoreID
}

ReplicationTarget identifies a node/store pair.

type StoreSpec

type StoreSpec struct {
	Path        string
	SizeInBytes int64
	SizePercent float64
	InMemory    bool
	Attributes  roachpb.Attributes
}

StoreSpec contains the details that can be specified in the cli pertaining to the --store flag.

func (StoreSpec) String

func (ss StoreSpec) String() string

String returns a fully parsable version of the store spec.

type StoreSpecList

type StoreSpecList struct {
	Specs []StoreSpec
	// contains filtered or unexported fields
}

StoreSpecList contains a slice of StoreSpecs that implements pflag's value interface.

func (*StoreSpecList) Set

func (ssl *StoreSpecList) Set(value string) error

Set adds a new value to the StoreSpecValue. It is the important part of pflag's value interface.

func (StoreSpecList) String

func (ssl StoreSpecList) String() string

String returns a string representation of all the StoreSpecs. This is part of pflag's value interface.

func (*StoreSpecList) Type

func (ssl *StoreSpecList) Type() string

Type returns the underlying type in string form. This is part of pflag's value interface.

type TestClusterArgs

type TestClusterArgs struct {
	// ServerArgs will be copied to each constituent TestServer. Used for all the
	// servers not overridden in ServerArgsPerNode.
	ServerArgs TestServerArgs
	// ReplicationMode controls how replication is to be done in the cluster.
	ReplicationMode TestClusterReplicationMode

	// ServerArgsPerNode override the default ServerArgs with the value in this
	// map. The map's key is an index within TestCluster.Servers. If there is
	// no entry in the map for a particular server, the default ServerArgs are
	// used.
	ServerArgsPerNode map[int]TestServerArgs
}

TestClusterArgs contains the parameters one can set when creating a test cluster. It contains a TestServerArgs instance which will be copied over to every server.

The zero value means "ReplicationAuto".

type TestClusterReplicationMode

type TestClusterReplicationMode int

TestClusterReplicationMode represents the replication settings for a TestCluster.

const (
	// ReplicationAuto means that ranges are replicated according to the
	// production default zone config. Replication is performed as in
	// production, by the replication queue.
	ReplicationAuto TestClusterReplicationMode = iota
	// ReplicationManual means that the split and replication queues of all
	// servers are stopped, and the test must manually control splitting and
	// replication through the TestServer.
	ReplicationManual
)

type TestServerArgs

type TestServerArgs struct {
	// Knobs for the test server.
	Knobs TestingKnobs

	// PartOfCluster must be set if the TestServer is joining others in a cluster.
	// If not set (and hence the server is the only one in the cluster), the
	// default zone config will be overridden to disable all replication - so that
	// tests don't get log spam about ranges not being replicated enough. This
	// is always set to true when the server is started via a TestCluster.
	PartOfCluster bool

	// Addr (if nonempty) is the address to use for the test server.
	Addr string

	// JoinAddr (if nonempty) is the address of a node we are joining.
	JoinAddr string

	// StoreSpecs define the stores for this server. If you want more than one
	// store per node, populate this array with StoreSpecs each representing a
	// store. If no StoreSpecs are provided than a single DefaultTestStoreSpec
	// will be used.
	StoreSpecs []StoreSpec

	// Fields copied to the server.Config.
	Insecure                 bool
	RetryOptions             retry.Options
	MetricsSampleInterval    time.Duration
	RaftTickInterval         time.Duration
	RaftElectionTimeoutTicks int
	SocketFile               string
	ScanInterval             time.Duration
	ScanMaxIdleTime          time.Duration
	SSLCA                    string
	SSLCert                  string
	SSLCertKey               string
	TimeSeriesQueryWorkerMax int

	// If set, this will be appended to the Postgres URL by functions that
	// automatically open a connection to the server. That's equivalent to running
	// SET DATABASE=foo, which works even if the database doesn't (yet) exist.
	UseDatabase string

	// Stopper can be used to stop the server. If not set, a stopper will be
	// constructed and it can be gotten through TestServerInterface.Stopper().
	Stopper *stop.Stopper

	// If set, the recording of events to the event log tables is disabled.
	DisableEventLog bool
}

TestServerArgs contains the parameters one can set when creating a test server. Notably, TestServerArgs are passed to serverutils.StartServer(). They're defined in base because they need to be shared between testutils/serverutils (test code) and server.TestServer (non-test code).

The zero value is suitable for most tests.

type TestingKnobs

type TestingKnobs struct {
	Store            ModuleTestingKnobs
	SQLExecutor      ModuleTestingKnobs
	SQLLeaseManager  ModuleTestingKnobs
	SQLSchemaChanger ModuleTestingKnobs
}

TestingKnobs contains facilities for controlling various parts of the system for testing.

Jump to

Keyboard shortcuts

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