server

package
v0.3.1-0...-15126a6 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2014 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const RegistryKey = "/_etcd/machines"

The location of the peer URL data.

View Source
const ReleaseVersion = "0.3.0+git"
View Source
const ThresholdMonitorTimeout = 5 * time.Second
View Source
const Version = "v2"

Variables

This section is empty.

Functions

func NewListener

func NewListener(scheme, addr string, tlsInfo *TLSInfo) net.Listener

NewListener creates a net.Listener If the given scheme is "https", it will generate TLS configuration based on TLSInfo. If any error happens, this function will call log.Fatal

func NewPackageStats

func NewPackageStats(now time.Time, size int) *packageStats

NewPackageStats creates a pacakgeStats and return the pointer to it.

func NewRaftFollowersStats

func NewRaftFollowersStats(name string) *raftFollowersStats

func NewRaftServerStats

func NewRaftServerStats(name string) *raftServerStats

func NewTransporter

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 Usage

func Usage() string

Usage returns the usage message for etcd.

Types

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"`
}

The JoinCommand adds a node to the cluster.

func NewJoinCommand

func NewJoinCommand(minVersion int, maxVersion int, name, raftUrl, etcdUrl string) *JoinCommand

func (*JoinCommand) Apply

func (c *JoinCommand) Apply(context raft.Context) (interface{}, error)

Join a server 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
	// contains filtered or unexported fields
}

func NewPeerServer

func NewPeerServer(psConfig PeerServerConfig, 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) EtcdURLHttpHandler

func (ps *PeerServer) EtcdURLHttpHandler(w http.ResponseWriter, req *http.Request)

Get the port that listening for etcd connecting of the server

func (*PeerServer) GetLogHttpHandler

func (ps *PeerServer) GetLogHttpHandler(w http.ResponseWriter, req *http.Request)

Get all the current logs

func (*PeerServer) HTTPHandler

func (s *PeerServer) HTTPHandler() http.Handler

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) 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) SetRaftServer

func (s *PeerServer) SetRaftServer(raftServer raft.Server)

func (*PeerServer) SetServer

func (s *PeerServer) SetServer(server *Server)

Associates the client server with the peer server.

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

func (s *PeerServer) Start(snapshot bool, discoverURL string, peers []string) error

Start the raft server

func (*PeerServer) Stats

func (s *PeerServer) Stats() []byte

func (*PeerServer) Stop

func (s *PeerServer) Stop()

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

type PeerServerConfig struct {
	Name           string
	Scheme         string
	URL            string
	SnapshotCount  int
	MaxClusterSize int
	RetryTimes     int
	RetryInterval  float64
}

type Registry

type Registry struct {
	sync.Mutex
	// contains filtered or unexported fields
}

The Registry stores URL information for nodes.

func NewRegistry

func NewRegistry(s store.Store) *Registry

Creates a new Registry.

func (*Registry) ClientURL

func (r *Registry) ClientURL(name string) (string, bool)

Retrieves the client URL for a given node by name.

func (*Registry) ClientURLs

func (r *Registry) ClientURLs(leaderName, selfName string) []string

Retrieves the Client URLs for all nodes.

func (*Registry) Count

func (r *Registry) Count() int

Returns the number of nodes in the cluster.

func (*Registry) Invalidate

func (r *Registry) Invalidate(name string)

Removes a node from the cache.

func (*Registry) PeerHost

func (r *Registry) PeerHost(name string) (string, bool)

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) PeerURL

func (r *Registry) PeerURL(name string) (string, bool)

Retrieves the peer URL for a given node by name.

func (*Registry) PeerURLs

func (r *Registry) PeerURLs(leaderName, selfName string) []string

Retrieves the Peer URLs for all nodes.

func (*Registry) Register

func (r *Registry) Register(name string, peerURL string, machURL string) error

Adds a node to the registry.

func (*Registry) Unregister

func (r *Registry) Unregister(name string) error

Removes a node 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) ClientURL

func (s *Server) ClientURL(name string) (string, bool)

ClientURL retrieves the Client URL for a given node name.

func (*Server) CommitIndex

func (s *Server) CommitIndex() uint64

The current Raft committed index.

func (*Server) Dispatch

func (s *Server) Dispatch(c raft.Command, w http.ResponseWriter, req *http.Request) error

Dispatch command to the current leader

func (*Server) EnableTracing

func (s *Server) EnableTracing()

func (*Server) GetLeaderHandler

func (s *Server) GetLeaderHandler(w http.ResponseWriter, req *http.Request) error

Handler to return the current leader's raft address

func (*Server) GetLeaderStatsHandler

func (s *Server) GetLeaderStatsHandler(w http.ResponseWriter, req *http.Request) error

Retrieves stats on the leader.

func (*Server) GetMetricsHandler

func (s *Server) GetMetricsHandler(w http.ResponseWriter, req *http.Request) error

Retrieves metrics from bucket

func (*Server) GetPeersHandler

func (s *Server) GetPeersHandler(w http.ResponseWriter, req *http.Request) error

Handler to return all the known peers in the current cluster.

func (*Server) GetStatsHandler

func (s *Server) GetStatsHandler(w http.ResponseWriter, req *http.Request) error

Retrieves stats on the Raft server.

func (*Server) GetStoreStatsHandler

func (s *Server) GetStoreStatsHandler(w http.ResponseWriter, req *http.Request) error

Retrieves stats on the leader.

func (*Server) GetVersionHandler

func (s *Server) GetVersionHandler(w http.ResponseWriter, req *http.Request) error

Handler to return the current version of etcd.

func (*Server) HTTPHandler

func (s *Server) HTTPHandler() http.Handler

func (*Server) Leader

func (s *Server) Leader() string

The node name of the leader in the cluster.

func (*Server) PeerHost

func (s *Server) PeerHost(name string) (string, bool)

PeerHost retrieves the host part of Peer URL for a given node name.

func (*Server) PeerURL

func (s *Server) PeerURL(name string) (string, bool)

Retrives the Peer URL for a given node name.

func (*Server) SpeedTestHandler

func (s *Server) SpeedTestHandler(w http.ResponseWriter, req *http.Request) error

Executes a speed test to evaluate the performance of update replication.

func (*Server) State

func (s *Server) State() string

The current state of the server in the cluster.

func (*Server) Store

func (s *Server) Store() store.Store

Returns a reference to the Store.

func (*Server) Term

func (s *Server) Term() uint64

The current Raft term.

func (*Server) URL

func (s *Server) URL() string

The server URL.

type TLSInfo

type TLSInfo struct {
	CertFile string `json:"CertFile"`
	KeyFile  string `json:"KeyFile"`
	CAFile   string `json:"CAFile"`
}

TLSInfo holds the SSL certificates paths.

func (TLSInfo) ClientConfig

func (info TLSInfo) ClientConfig() (*tls.Config, error)

Generates a tls.Config object for a client from the given files.

func (TLSInfo) Scheme

func (info TLSInfo) Scheme() string

func (TLSInfo) ServerConfig

func (info TLSInfo) ServerConfig() (*tls.Config, error)

Generates a tls.Config object for a server from the given files.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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