Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultRetryOptions() retry.Options
- type Config
- func (cfg *Config) AdminURL() *url.URL
- func (cfg *Config) ClientHasValidCerts(user string) bool
- func (cfg *Config) GetCACertPath() (string, error)
- func (cfg *Config) GetCertificateManager() (*security.CertificateManager, error)
- func (cfg *Config) GetClientCertPaths(user string) (string, string, error)
- func (cfg *Config) GetClientTLSConfig() (*tls.Config, error)
- func (cfg *Config) GetHTTPClient() (http.Client, error)
- func (cfg *Config) GetServerTLSConfig() (*tls.Config, error)
- func (cfg *Config) HTTPRequestScheme() string
- func (cfg *Config) InitDefaults()
- func (cfg *Config) InitializeNodeTLSConfigs(stopper *stop.Stopper) (*security.CertificateManager, error)
- func (cfg *Config) PGURL(user *url.Userinfo) (*url.URL, error)
- type JoinListType
- type ModuleTestingKnobs
- type NodeIDContainer
- type RaftConfig
- func (cfg RaftConfig) NodeLivenessDurations() (livenessActive, livenessRenewal time.Duration)
- func (cfg RaftConfig) RaftElectionTimeout() time.Duration
- func (cfg RaftConfig) RangeLeaseActiveDuration() time.Duration
- func (cfg RaftConfig) RangeLeaseDurations() (rangeLeaseActive, rangeLeaseRenewal time.Duration)
- func (cfg RaftConfig) RangeLeaseRenewalDuration() time.Duration
- func (cfg *RaftConfig) SetDefaults()
- type StoreSpec
- type StoreSpecList
- type TestClusterArgs
- type TestClusterReplicationMode
- type TestServerArgs
- type TestingKnobs
Constants ¶
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 // DefaultCertsDirectory is the default value for the cert directory flag. DefaultCertsDirectory = "${HOME}/.cockroach-certs" )
Base config defaults.
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 // SlowRequestThreshold is the amount of time to wait before considering a // request to be "slow". SlowRequestThreshold = 60 * time.Second )
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 ¶
var DefaultTestStoreSpec = StoreSpec{ InMemory: true, }
DefaultTestStoreSpec is just a single in memory store of 100 MiB with no special attributes.
Functions ¶
func DefaultRetryOptions ¶
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) ClientHasValidCerts ¶
ClientHasValidCerts returns true if the specified client has a valid client cert and key.
func (*Config) GetCACertPath ¶
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 ¶
GetClientCertPaths returns the paths to the client cert and key.
func (*Config) GetClientTLSConfig ¶
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 ¶
GetHTTPClient returns the http client, initializing it if needed. It uses the client TLS config.
func (*Config) GetServerTLSConfig ¶
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 ¶
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, ) (*security.CertificateManager, 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. Returns the certificate manager if successfully created and in secure mode.
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 RaftConfig ¶
type RaftConfig struct { // RaftTickInterval is the resolution of the Raft timer. RaftTickInterval time.Duration // RaftElectionTimeoutTicks is the number of raft ticks before the // previous election expires. This value is inherited by individual stores // unless overridden. RaftElectionTimeoutTicks int }
RaftConfig holds raft tuning parameters.
func (RaftConfig) NodeLivenessDurations ¶
func (cfg RaftConfig) NodeLivenessDurations() (livenessActive, livenessRenewal time.Duration)
NodeLivenessDurations computes durations for node liveness expiration and renewal based on a default multiple of Raft election timeout.
func (RaftConfig) RaftElectionTimeout ¶
func (cfg RaftConfig) RaftElectionTimeout() time.Duration
RaftElectionTimeout returns the raft election timeout, as computed from the tick interval and number of election timeout ticks.
func (RaftConfig) RangeLeaseActiveDuration ¶
func (cfg RaftConfig) RangeLeaseActiveDuration() time.Duration
RangeLeaseActiveDuration is the duration of the active period of leader leases requested.
func (RaftConfig) RangeLeaseDurations ¶
func (cfg RaftConfig) RangeLeaseDurations() (rangeLeaseActive, rangeLeaseRenewal time.Duration)
RangeLeaseDurations computes durations for range lease expiration and renewal based on a default multiple of Raft election timeout.
func (RaftConfig) RangeLeaseRenewalDuration ¶
func (cfg RaftConfig) RangeLeaseRenewalDuration() time.Duration
RangeLeaseRenewalDuration specifies a time interval at the end of the active lease interval (i.e. bounded to the right by the start of the stasis period) during which operations will trigger an asynchronous renewal of the lease.
func (*RaftConfig) SetDefaults ¶
func (cfg *RaftConfig) SetDefaults()
SetDefaults initializes unset fields.
type StoreSpec ¶
type StoreSpec struct { Path string // SizeInBytes is used for calculating free space and making rebalancing // decisions. Zero indicates that there is no maximum size. This value is not // actually used by the engine and thus not enforced. 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 ¶
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.
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 and potentially adjusted according to the // ReplicationMode for 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. // // A copy of an entry from this map will be copied to each individual server // and potentially adjusted according to ReplicationMode. 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 )
func (TestClusterReplicationMode) String ¶
func (i TestClusterReplicationMode) String() string
type TestServerArgs ¶
type TestServerArgs struct { // Knobs for the test server. Knobs TestingKnobs *cluster.Settings RaftConfig // 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 is the address of a node we are joining. // // If left empty and the TestServer is being added to a nonempty cluster, this // will be set to the the address of the cluster's first node. 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 SocketFile string ScanInterval time.Duration ScanMaxIdleTime time.Duration SSLCertsDir string TimeSeriesQueryWorkerMax int SQLMemoryPoolSize int64 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 // If set, web session authentication will be disabled, even if the server // is running in secure mode. DisableWebSessionAuthentication 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 DistSender ModuleTestingKnobs SQLExecutor ModuleTestingKnobs SQLLeaseManager ModuleTestingKnobs SQLSchemaChanger ModuleTestingKnobs DistSQL ModuleTestingKnobs }
TestingKnobs contains facilities for controlling various parts of the system for testing.