base

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 18, 2017 License: Apache-2.0 Imports: 24 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

	// DefaultCertsDirectory is the default value for the cert directory flag.
	DefaultCertsDirectory = "${HOME}/.cockroach-certs"
)

Base config defaults.

View Source
const (
	// DefaultMaxClockOffset is the default maximum acceptable clock offset value.
	// On Azure, clock offsets between 250ms and 500ms are common. On AWS and GCE,
	// clock offsets generally stay below 250ms. See comments on Config.MaxOffset
	// for more on this setting.
	DefaultMaxClockOffset = 500 * time.Millisecond

	// 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 = 1 * time.Second

	// DefaultSendNextTimeout is the duration to wait before trying
	// another replica to send a KV batch.
	DefaultSendNextTimeout = 500 * time.Millisecond

	// 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

	// SSLCAKey is used to sign new certs.
	SSLCAKey string
	// SSLCertsDir is the path to the certificate/key directory.
	SSLCertsDir string

	// 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

	// HistogramWindowInterval is used to determine the approximate length of time
	// that individual samples are retained in in-memory histograms. Currently,
	// it is set to the arbitrary length of six times the Metrics sample interval.
	// See the comment in server.Config for more details.
	HistogramWindowInterval time.Duration
	// 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) ClientHasValidCerts

func (cfg *Config) ClientHasValidCerts(user string) bool

ClientHasValidCerts returns true if the specified client has a valid client cert and key.

func (*Config) GetCACertPath

func (cfg *Config) GetCACertPath() (string, error)

GetCACertPath returns the path to the CA certificate.

func (*Config) GetCertificateManager

func (cfg *Config) GetCertificateManager() (*security.CertificateManager, error)

GetCertificateManager returns the certificate manager, initializing it on the first call.

func (*Config) GetClientCertPaths

func (cfg *Config) GetClientCertPaths(user string) (string, string, error)

GetClientCertPaths returns the paths to the client cert and key.

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 ask the certificate manager for a TLS config using certs for the config.User.

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 ask the certificate manager for a server TLS config.

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. This is also used in tests to reset global objects.

func (*Config) InitializeNodeTLSConfigs

func (cfg *Config) InitializeNodeTLSConfigs(stopper *stop.Stopper) error

InitializeNodeTLSConfigs tries to load client and server-side TLS configs. It also enables the reload-on-SIGHUP functionality on the certificate manager. This should be called early in the life of the server to make sure there are no issues with TLS configs.

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 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 NewStoreSpec

func NewStoreSpec(value string) (StoreSpec, error)

NewStoreSpec parses the string passed into a --store flag and returns a StoreSpec if it is correctly parsed. There are four possible fields that can be passed in, comma separated:

  • path=xxx The directory in which to the rocks db instance should be located, required unless using a in memory storage.
  • type=mem This specifies that the store is an in memory storage instead of an on disk one. mem is currently the only other type available.
  • size=xxx The optional maximum size of the storage. This can be in one of a few different formats.
  • 10000000000 -> 10000000000 bytes
  • 20GB -> 20000000000 bytes
  • 20GiB -> 21474836480 bytes
  • 0.02TiB -> 21474836480 bytes
  • 20% -> 20% of the available space
  • 0.2 -> 20% of the available space
  • attrs=xxx:yyy:zzz A colon separated list of optional attributes.

Note that commas are forbidden within any field name or value.

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
	// HTTPAddr (if nonempty) is the HTTP address to use for the test server.
	HTTPAddr 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
	SSLCertsDir              string
	TimeSeriesQueryWorkerMax int
	SQLMemoryPoolSize        int64
	SendNextTimeout          time.Duration
	ListeningURLFile         string

	// 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
	DistSQL          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