Documentation ¶
Index ¶
- Constants
- func NewListener(scheme, addr string, cfg *tls.Config) net.Listener
- func NewPackageStats(now time.Time, size int) *packageStats
- func NewRaftFollowersStats(name string) *raftFollowersStats
- func NewRaftServerStats(name string) *raftServerStats
- func NewTransporter(followersStats *raftFollowersStats, serverStats *raftServerStats, ...) *transporter
- func TLSServerConfig(info *TLSInfo) *tls.Config
- func Usage() string
- type Client
- func (c *Client) AddMachine(url string, cmd *JoinCommand) (uint64, *etcdErr.Error)
- func (c *Client) CheckVersion(url string, version int) (bool, *etcdErr.Error)
- func (c *Client) GetClusterConfig(url string) (*ClusterConfig, *etcdErr.Error)
- func (c *Client) GetMachines(url string) ([]*machineMessage, *etcdErr.Error)
- func (c *Client) GetVersion(url string) (int, *etcdErr.Error)
- type ClusterConfig
- type HEADResponseWriter
- type JoinCommand
- type PeerServer
- func (ps *PeerServer) AppendEntriesHttpHandler(w http.ResponseWriter, req *http.Request)
- func (s *PeerServer) ClusterConfig() *ClusterConfig
- func (ps *PeerServer) EtcdURLHttpHandler(w http.ResponseWriter, req *http.Request)
- func (s *PeerServer) FindCluster(discoverURL string, peers []string) (toStart bool, possiblePeers []string, err error)
- func (ps *PeerServer) GetLogHttpHandler(w http.ResponseWriter, req *http.Request)
- func (s *PeerServer) HTTPHandler() http.Handler
- func (s *PeerServer) InitNewCluster(clusterConfig *ClusterConfig)
- func (ps *PeerServer) JoinHttpHandler(w http.ResponseWriter, req *http.Request)
- func (ps *PeerServer) NameHttpHandler(w http.ResponseWriter, req *http.Request)
- func (ps *PeerServer) NextInternalVersionHandler(w http.ResponseWriter, req *http.Request)
- func (s *PeerServer) PeerStats() []byte
- func (s *PeerServer) RaftServer() raft.Server
- func (ps *PeerServer) RemoveHttpHandler(w http.ResponseWriter, req *http.Request)
- func (s *PeerServer) RemoveNotify() <-chan bool
- func (s *PeerServer) SetClusterConfig(c *ClusterConfig)
- func (s *PeerServer) SetJoinIndex(joinIndex uint64)
- func (s *PeerServer) SetRaftServer(raftServer raft.Server, snapshot bool)
- func (s *PeerServer) SetRegistry(registry *Registry)
- func (s *PeerServer) SetServer(server *Server)
- func (s *PeerServer) SetStore(store store.Store)
- func (ps *PeerServer) SnapshotHttpHandler(w http.ResponseWriter, req *http.Request)
- func (ps *PeerServer) SnapshotRecoveryHttpHandler(w http.ResponseWriter, req *http.Request)
- func (s *PeerServer) Start(snapshot bool, clusterConfig *ClusterConfig) error
- func (s *PeerServer) Stats() []byte
- func (s *PeerServer) Stop()
- func (s *PeerServer) Upgradable() error
- func (ps *PeerServer) UpgradeHttpHandler(w http.ResponseWriter, req *http.Request)
- func (ps *PeerServer) VersionCheckHttpHandler(w http.ResponseWriter, req *http.Request)
- func (ps *PeerServer) VersionHttpHandler(w http.ResponseWriter, req *http.Request)
- func (ps *PeerServer) VoteHttpHandler(w http.ResponseWriter, req *http.Request)
- type PeerServerConfig
- type Registry
- func (r *Registry) ClientURL(name string) (string, bool)
- func (r *Registry) ClientURLs(leaderName, selfName string) []string
- func (r *Registry) Count() int
- func (r *Registry) Exists(name string) bool
- func (r *Registry) Invalidate(name string)
- func (r *Registry) Names() []string
- func (r *Registry) PeerHost(name string) (string, bool)
- func (r *Registry) PeerURL(name string) (string, bool)
- func (r *Registry) PeerURLs(leaderName, selfName string) []string
- func (r *Registry) Register(name string, peerURL string, machURL string) error
- func (r *Registry) Unregister(name string) error
- func (r *Registry) UpdatePeerURL(name string, peerURL string) error
- type RemoveCommand
- type Server
- func (s *Server) ClientURL(name string) (string, bool)
- func (s *Server) CommitIndex() uint64
- func (s *Server) Dispatch(c raft.Command, w http.ResponseWriter, req *http.Request) error
- func (s *Server) EnableTracing()
- func (s *Server) GetLeaderHandler(w http.ResponseWriter, req *http.Request) error
- func (s *Server) GetLeaderStatsHandler(w http.ResponseWriter, req *http.Request) error
- func (s *Server) GetMetricsHandler(w http.ResponseWriter, req *http.Request) error
- func (s *Server) GetPeersHandler(w http.ResponseWriter, req *http.Request) error
- func (s *Server) GetStatsHandler(w http.ResponseWriter, req *http.Request) error
- func (s *Server) GetStoreStatsHandler(w http.ResponseWriter, req *http.Request) error
- func (s *Server) GetVersionHandler(w http.ResponseWriter, req *http.Request) error
- func (s *Server) HTTPHandler() http.Handler
- func (s *Server) Leader() string
- func (s *Server) PeerHost(name string) (string, bool)
- func (s *Server) PeerURL(name string) (string, bool)
- func (s *Server) SetRegistry(registry *Registry)
- func (s *Server) SetStore(store store.Store)
- func (s *Server) SpeedTestHandler(w http.ResponseWriter, req *http.Request) error
- func (s *Server) State() string
- func (s *Server) Store() store.Store
- func (s *Server) Term() uint64
- func (s *Server) URL() string
- type SetClusterConfigCommand
- type StandbyServer
- func (s *StandbyServer) ClientHTTPHandler() http.Handler
- func (s *StandbyServer) ClusterLeader() *machineMessage
- func (s *StandbyServer) ClusterSize() int
- func (s *StandbyServer) ClusterURLs() []string
- func (s *StandbyServer) IsRunning() bool
- func (s *StandbyServer) JoinIndex() uint64
- func (s *StandbyServer) RemoveNotify() <-chan bool
- func (s *StandbyServer) SetRaftServer(raftServer raft.Server)
- func (s *StandbyServer) SetSyncInterval(second float64)
- func (s *StandbyServer) Start()
- func (s *StandbyServer) Stop()
- func (s *StandbyServer) SyncCluster(peers []string) error
- type StandbyServerConfig
- type TLSInfo
Constants ¶
const ( // DefaultActiveSize is the default number of active followers allowed. DefaultActiveSize = 9 // MinActiveSize is the minimum active size allowed. MinActiveSize = 3 // DefaultRemoveDelay is the default elapsed time before removal. DefaultRemoveDelay = float64((30 * time.Minute) / time.Second) // MinRemoveDelay is the minimum remove delay allowed. MinRemoveDelay = float64((2 * time.Second) / time.Second) // DefaultSyncInterval is the default interval for cluster sync. DefaultSyncInterval = float64((5 * time.Second) / time.Second) // MinSyncInterval is the minimum sync interval allowed. MinSyncInterval = float64((1 * time.Second) / time.Second) )
const ( DefaultReadTimeout = float64((5 * time.Minute) / time.Second) DefaultWriteTimeout = float64((5 * time.Minute) / time.Second) )
const ( // MaxHeartbeatTimeoutBackoff is the maximum number of seconds before we warn // the user again about a peer not accepting heartbeats. MaxHeartbeatTimeoutBackoff = 15 * time.Second // ThresholdMonitorTimeout is the time between log notifications that the // Raft heartbeat is too close to the election timeout. ThresholdMonitorTimeout = 5 * time.Second // ActiveMonitorTimeout is the time between checks on the active size of // the cluster. If the active size is bigger than the actual size then // etcd attempts to demote to bring it to the correct number. ActiveMonitorTimeout = 1 * time.Second // PeerActivityMonitorTimeout is the time between checks for dead nodes in // the cluster. PeerActivityMonitorTimeout = 1 * time.Second // The location of cluster config in key space. ClusterConfigKey = "/_etcd/config" )
const InternalVersion = "1"
const RegistryKey = "/_etcd/machines"
The location of the peer URL data.
const ReleaseVersion = "0.4.7"
const Version = "v2"
Variables ¶
This section is empty.
Functions ¶
func NewListener ¶ added in v0.3.0
NewListener creates a net.Listener If the given scheme is "https", it will use TLS config to set listener. If any error happens, this function will call log.Fatal
func NewPackageStats ¶
NewPackageStats creates a pacakgeStats and return the pointer to it.
func NewRaftFollowersStats ¶ added in v0.3.0
func NewRaftFollowersStats(name string) *raftFollowersStats
func NewRaftServerStats ¶ added in v0.3.0
func NewRaftServerStats(name string) *raftServerStats
func NewTransporter ¶ added in v0.3.0
func NewTransporter(followersStats *raftFollowersStats, serverStats *raftServerStats, registry *Registry, dialTimeout, requestTimeout, responseHeaderTimeout time.Duration) *transporter
Create transporter using by raft server Create http or https transporter based on whether the user give the server cert and key
func TLSServerConfig ¶ added in v0.4.0
TLSServerConfig generates tls configuration based on TLSInfo If any error happens, this function will call log.Fatal
Types ¶
type Client ¶ added in v0.4.0
Client sends various requests using HTTP API. It is different from raft communication, and doesn't record anything in the log. The argument url is required to contain scheme and host only, and there is no trailing slash in it. Public functions return "etcd/error".Error intentionally to figure out etcd error code easily. TODO(yichengq): It is similar to go-etcd. But it could have many efforts to integrate the two. Leave it for further discussion.
func NewClient ¶ added in v0.4.0
func NewClient(transport http.RoundTripper) *Client
func (*Client) AddMachine ¶ added in v0.4.0
AddMachine adds machine to the cluster. The first return value is the commit index of join command.
func (*Client) CheckVersion ¶ added in v0.4.0
CheckVersion returns true when the version check on the server returns 200.
func (*Client) GetClusterConfig ¶ added in v0.4.0
func (c *Client) GetClusterConfig(url string) (*ClusterConfig, *etcdErr.Error)
func (*Client) GetMachines ¶ added in v0.4.0
type ClusterConfig ¶ added in v0.4.0
type ClusterConfig struct { // ActiveSize is the maximum number of node that can join as Raft followers. // Nodes that join the cluster after the limit is reached are standbys. ActiveSize int `json:"activeSize"` // RemoveDelay is the amount of time, in seconds, after a node is // unreachable that it will be swapped out as a standby node. RemoveDelay float64 `json:"removeDelay"` // SyncInterval is the amount of time, in seconds, between // cluster sync when it runs in standby mode. SyncInterval float64 `json:"syncInterval"` }
ClusterConfig represents cluster-wide configuration settings.
func NewClusterConfig ¶ added in v0.4.0
func NewClusterConfig() *ClusterConfig
NewClusterConfig returns a cluster configuration with default settings.
type HEADResponseWriter ¶ added in v0.4.0
type HEADResponseWriter struct {
http.ResponseWriter
}
type JoinCommand ¶
type JoinCommand struct { MinVersion int `json:"minVersion"` MaxVersion int `json:"maxVersion"` Name string `json:"name"` RaftURL string `json:"raftURL"` EtcdURL string `json:"etcdURL"` }
JoinCommand represents a request to join the cluster. The command returns the join_index (Uvarint).
func (*JoinCommand) Apply ¶
func (c *JoinCommand) Apply(context raft.Context) (interface{}, error)
Apply attempts to join a machine to the cluster.
func (*JoinCommand) CommandName ¶
func (c *JoinCommand) CommandName() string
The name of the join command in the log
func (*JoinCommand) NodeName ¶
func (c *JoinCommand) NodeName() string
type PeerServer ¶
type PeerServer struct { Config PeerServerConfig sync.Mutex // contains filtered or unexported fields }
func NewPeerServer ¶
func NewPeerServer(psConfig PeerServerConfig, client *Client, registry *Registry, store store.Store, mb *metrics.Bucket, followersStats *raftFollowersStats, serverStats *raftServerStats) *PeerServer
func (*PeerServer) AppendEntriesHttpHandler ¶
func (ps *PeerServer) AppendEntriesHttpHandler(w http.ResponseWriter, req *http.Request)
Response to append entries request
func (*PeerServer) ClusterConfig ¶ added in v0.4.0
func (s *PeerServer) ClusterConfig() *ClusterConfig
ClusterConfig retrieves the current cluster configuration.
func (*PeerServer) EtcdURLHttpHandler ¶
func (ps *PeerServer) EtcdURLHttpHandler(w http.ResponseWriter, req *http.Request)
Get the port that listening for etcd connecting of the server
func (*PeerServer) FindCluster ¶ added in v0.4.0
func (s *PeerServer) FindCluster(discoverURL string, peers []string) (toStart bool, possiblePeers []string, err error)
Try all possible ways to find clusters to join Include log data in -data-dir, -discovery and -peers
Peer discovery follows this order: 1. previous peers in -data-dir 2. -discovery 3. -peers
func (*PeerServer) GetLogHttpHandler ¶
func (ps *PeerServer) GetLogHttpHandler(w http.ResponseWriter, req *http.Request)
Get all the current logs
func (*PeerServer) HTTPHandler ¶ added in v0.3.0
func (s *PeerServer) HTTPHandler() http.Handler
func (*PeerServer) InitNewCluster ¶ added in v0.4.0
func (s *PeerServer) InitNewCluster(clusterConfig *ClusterConfig)
func (*PeerServer) JoinHttpHandler ¶
func (ps *PeerServer) JoinHttpHandler(w http.ResponseWriter, req *http.Request)
Response to the join request
func (*PeerServer) NameHttpHandler ¶
func (ps *PeerServer) NameHttpHandler(w http.ResponseWriter, req *http.Request)
Response to the name request
func (*PeerServer) NextInternalVersionHandler ¶ added in v0.4.7
func (ps *PeerServer) NextInternalVersionHandler(w http.ResponseWriter, req *http.Request)
func (*PeerServer) PeerStats ¶
func (s *PeerServer) PeerStats() []byte
func (*PeerServer) RaftServer ¶
func (s *PeerServer) RaftServer() raft.Server
Retrieves the underlying Raft server.
func (*PeerServer) RemoveHttpHandler ¶
func (ps *PeerServer) RemoveHttpHandler(w http.ResponseWriter, req *http.Request)
Response to remove request
func (*PeerServer) RemoveNotify ¶ added in v0.4.0
func (s *PeerServer) RemoveNotify() <-chan bool
RemoveNotify notifies the server is removed from peer mode due to removal from the cluster.
func (*PeerServer) SetClusterConfig ¶ added in v0.4.0
func (s *PeerServer) SetClusterConfig(c *ClusterConfig)
SetClusterConfig updates the current cluster configuration. Adjusting the active size will cause cluster to add or remove machines to match the new size.
func (*PeerServer) SetJoinIndex ¶ added in v0.4.0
func (s *PeerServer) SetJoinIndex(joinIndex uint64)
func (*PeerServer) SetRaftServer ¶ added in v0.3.0
func (s *PeerServer) SetRaftServer(raftServer raft.Server, snapshot bool)
func (*PeerServer) SetRegistry ¶ added in v0.4.0
func (s *PeerServer) SetRegistry(registry *Registry)
func (*PeerServer) SetServer ¶
func (s *PeerServer) SetServer(server *Server)
Associates the client server with the peer server.
func (*PeerServer) SetStore ¶ added in v0.4.0
func (s *PeerServer) SetStore(store store.Store)
func (*PeerServer) SnapshotHttpHandler ¶
func (ps *PeerServer) SnapshotHttpHandler(w http.ResponseWriter, req *http.Request)
Response to recover from snapshot request
func (*PeerServer) SnapshotRecoveryHttpHandler ¶
func (ps *PeerServer) SnapshotRecoveryHttpHandler(w http.ResponseWriter, req *http.Request)
Response to recover from snapshot request
func (*PeerServer) Start ¶ added in v0.3.0
func (s *PeerServer) Start(snapshot bool, clusterConfig *ClusterConfig) error
Start starts the raft server. The function assumes that join has been accepted successfully.
func (*PeerServer) Stats ¶
func (s *PeerServer) Stats() []byte
func (*PeerServer) Stop ¶ added in v0.3.0
func (s *PeerServer) Stop()
Stop stops the server gracefully.
func (*PeerServer) Upgradable ¶
func (s *PeerServer) Upgradable() error
Upgradable checks whether all peers in a cluster support an upgrade to the next store version.
func (*PeerServer) UpgradeHttpHandler ¶
func (ps *PeerServer) UpgradeHttpHandler(w http.ResponseWriter, req *http.Request)
Upgrades the current store version to the next version.
func (*PeerServer) VersionCheckHttpHandler ¶
func (ps *PeerServer) VersionCheckHttpHandler(w http.ResponseWriter, req *http.Request)
Checks whether a given version is supported.
func (*PeerServer) VersionHttpHandler ¶
func (ps *PeerServer) VersionHttpHandler(w http.ResponseWriter, req *http.Request)
Response to the name request
func (*PeerServer) VoteHttpHandler ¶
func (ps *PeerServer) VoteHttpHandler(w http.ResponseWriter, req *http.Request)
Response to vote request
type PeerServerConfig ¶ added in v0.3.0
type Registry ¶
The Registry stores URL information for nodes.
func (*Registry) ClientURLs ¶
Retrieves the Client URLs for all nodes.
func (*Registry) Invalidate ¶
Removes a node from the cache.
func (*Registry) PeerHost ¶ added in v0.4.0
TODO(yichengq): have all of the code use a full URL with scheme and remove this method PeerHost retrieves the host part of peer URL for a given node by name.
func (*Registry) Unregister ¶
Unregister removes a peer from the registry.
type RemoveCommand ¶
type RemoveCommand struct {
Name string `json:"name"`
}
The RemoveCommand removes a server from the cluster.
func (*RemoveCommand) Apply ¶
func (c *RemoveCommand) Apply(context raft.Context) (interface{}, error)
Remove a server from the cluster
func (*RemoveCommand) CommandName ¶
func (c *RemoveCommand) CommandName() string
The name of the remove command in the log
type Server ¶
type Server struct { Name string // contains filtered or unexported fields }
This is the default implementation of the Server interface.
func New ¶
func New(name, url string, peerServer *PeerServer, registry *Registry, store store.Store, mb *metrics.Bucket) *Server
Creates a new Server.
func (*Server) CommitIndex ¶
The current Raft committed index.
func (*Server) EnableTracing ¶ added in v0.3.0
func (s *Server) EnableTracing()
func (*Server) GetLeaderHandler ¶
Handler to return the current leader's raft address
func (*Server) GetLeaderStatsHandler ¶
Retrieves stats on the leader.
func (*Server) GetMetricsHandler ¶ added in v0.3.0
Retrieves metrics from bucket
func (*Server) GetPeersHandler ¶
Handler to return all the known peers in the current cluster.
func (*Server) GetStatsHandler ¶
Retrieves stats on the Raft server.
func (*Server) GetStoreStatsHandler ¶
Retrieves stats on the leader.
func (*Server) GetVersionHandler ¶
Handler to return the current version of etcd.
func (*Server) HTTPHandler ¶ added in v0.3.0
func (*Server) PeerHost ¶ added in v0.4.0
PeerHost retrieves the host part of Peer URL for a given node name.
func (*Server) SetRegistry ¶ added in v0.4.0
func (*Server) SpeedTestHandler ¶
Executes a speed test to evaluate the performance of update replication.
type SetClusterConfigCommand ¶ added in v0.4.0
type SetClusterConfigCommand struct {
Config *ClusterConfig `json:"config"`
}
SetClusterConfigCommand sets the cluster-level configuration.
func (*SetClusterConfigCommand) Apply ¶ added in v0.4.0
func (c *SetClusterConfigCommand) Apply(context raft.Context) (interface{}, error)
Apply updates the cluster configuration.
func (*SetClusterConfigCommand) CommandName ¶ added in v0.4.0
func (c *SetClusterConfigCommand) CommandName() string
CommandName returns the name of the command.
type StandbyServer ¶ added in v0.4.0
type StandbyServer struct { Config StandbyServerConfig sync.Mutex // contains filtered or unexported fields }
func NewStandbyServer ¶ added in v0.4.0
func NewStandbyServer(config StandbyServerConfig, client *Client) *StandbyServer
func (*StandbyServer) ClientHTTPHandler ¶ added in v0.4.0
func (s *StandbyServer) ClientHTTPHandler() http.Handler
func (*StandbyServer) ClusterLeader ¶ added in v0.4.0
func (s *StandbyServer) ClusterLeader() *machineMessage
func (*StandbyServer) ClusterSize ¶ added in v0.4.0
func (s *StandbyServer) ClusterSize() int
func (*StandbyServer) ClusterURLs ¶ added in v0.4.0
func (s *StandbyServer) ClusterURLs() []string
func (*StandbyServer) IsRunning ¶ added in v0.4.0
func (s *StandbyServer) IsRunning() bool
func (*StandbyServer) JoinIndex ¶ added in v0.4.0
func (s *StandbyServer) JoinIndex() uint64
func (*StandbyServer) RemoveNotify ¶ added in v0.4.0
func (s *StandbyServer) RemoveNotify() <-chan bool
RemoveNotify notifies the server is removed from standby mode and ready for peer mode. It should have joined the cluster successfully.
func (*StandbyServer) SetRaftServer ¶ added in v0.4.2
func (s *StandbyServer) SetRaftServer(raftServer raft.Server)
func (*StandbyServer) SetSyncInterval ¶ added in v0.4.0
func (s *StandbyServer) SetSyncInterval(second float64)
func (*StandbyServer) Start ¶ added in v0.4.0
func (s *StandbyServer) Start()
func (*StandbyServer) Stop ¶ added in v0.4.0
func (s *StandbyServer) Stop()
Stop stops the server gracefully.
func (*StandbyServer) SyncCluster ¶ added in v0.4.0
func (s *StandbyServer) SyncCluster(peers []string) error
type StandbyServerConfig ¶ added in v0.4.0
Source Files ¶
- client.go
- cluster_config.go
- join_command.go
- listener.go
- package_stats.go
- peer_server.go
- peer_server_handlers.go
- raft_follower_stats.go
- raft_server_stats.go
- registry.go
- remove_command.go
- server.go
- set_cluster_config_command.go
- standby_server.go
- stats_queue.go
- tls_info.go
- transporter.go
- usage.go
- version.go