server

package
v0.0.0-...-49e565d Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2015 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SerfCheckID           = "serfHealth"
	// SerfCheckName         = "Serf Health Status"
	// SerfCheckAliveOutput  = "Agent alive and reachable"
	// SerfCheckFailedOutput = "Agent not live or unreachable"
	KappaServiceID   = "kappa"
	KappaServiceName = "kappa"
	LeaderEventName  = "kappa:new-leader"
)
View Source
const (

	// KappaEventPrefix is pre-pended to a kappa event to distinguish it
	KappaEventPrefix = "kappa-event:"
)
View Source
const (
	// StatusReap is used to update the status of a node if we
	// are handling a EventMemberReap
	StatusReap = serf.MemberStatus(-1)
)

Variables

This section is empty.

Functions

func GetKappaEventName

func GetKappaEventName(name string) string

GetKappaEventName computes the name of a kappa event

func GetRawEventName

func GetRawEventName(name string) string

GetRawEventName is used to get the raw kappa event name

func IsKappaEvent

func IsKappaEvent(name string) bool

IsKappaEvent checks if a serf event is a Kappa event

func PublicKeyCallback

func PublicKeyCallback(sys datamodel.System) (func(ssh.ConnMetadata, ssh.PublicKey) (*ssh.Permissions, error), error)

PublicKeyCallback returns a function to validate public keys for user login.

func ValidateNode

func ValidateNode(member serf.Member) (ok bool, role, cluster string)

ValidateNode returns whether a node is a Kappa server as well as its cluster.

Types

type DatabaseConfig

type DatabaseConfig struct {

	// NodeName is the name of the node. If it is empty, a name
	// will be generated.
	NodeName string

	// ClusterName prevents two clusters from merging.
	ClusterName string

	// ExistingNodes is an array of nodes already in the cluster.
	ExistingNodes []string

	// Bootstrap determines if the server is bootstrapped into the cluster.
	Bootstrap bool

	BootstrapExpect int

	// Build is the running server revision.
	Build string

	// AdminCertificateFile is the path to the admin user's certificate.
	AdminCertificateFile string

	// CACertificateFile is the path to the CA certificate.
	CACertificateFile string

	// DataPath is the root directory for all data produced by the database.
	DataPath string

	// LogOutput is the writer to which all logs are
	// written to. If nil, it defaults to os.Stdout.
	LogOutput io.Writer

	// SSHBindAddress is the address on which the SSH server listens.
	SSHBindAddress string

	// SSHConnectionDeadline is the deadline for maximum connection attempts.
	SSHConnectionDeadline time.Duration

	// SSHPrivateKeyFile refers to the private key file of the SSH server.
	SSHPrivateKeyFile string

	// GossipBindAddr
	GossipBindAddr string

	// GossipBindPort
	GossipBindPort int

	// GossipAdvertiseAddr
	GossipAdvertiseAddr string

	// GossipAdvertisePort
	GossipAdvertisePort int
}

DatabaseConfig contains all the information to start the Kappa server.

type EchoHandler

type EchoHandler struct {
}

func (*EchoHandler) Handle

func (e *EchoHandler) Handle(parentTomb tomb.Tomb, sshConn *ssh.ServerConn, channel ssh.Channel, requests <-chan *ssh.Request) error

type NodeDetails

type NodeDetails struct {
	Name       string
	Role       string
	Cluster    string
	DataCenter string
	Service    string
	SSHPort    int
	Bootstrap  bool
	Addr       net.TCPAddr
	Expect     int
}

NodeDetails stores details about a single serf.Member

func GetKappaServer

func GetKappaServer(m serf.Member) (n *NodeDetails, err error)

GetKappaServer should validate all the Serf tags for the given member and returns NodeDetails and any that occured error.

func (NodeDetails) String

func (n NodeDetails) String() (s string)

type NodeList

type NodeList interface {

	// AddNode adds a new node to the cluster.
	AddNode(NodeDetails)

	// RemoveNode removes a node from the cluster.
	RemoveNode(NodeDetails)

	// GetNodes returns a list of nodes currently in the cluster
	GetNodes() []NodeDetails

	// Size returns the number of nodes in the cluster.
	Size() int

	// FindByDataCenter returns a list of nodes which are in the given data denter.
	FindByDataCenter(string) []NodeDetails

	// FindByRole returns a list of nodes which have the given role.
	FindByRole(string) []NodeDetails

	// FindByService returns a list of nodes which are running the given service.
	FindByService(string) []NodeDetails

	// Filter returns a list of nodes which satisfy the given filter.
	Filter(func(NodeDetails) bool) []NodeDetails
}

NodeList maintains a list of remote nodes in the cluster.

func NewNodeList

func NewNodeList() NodeList

NewNodeList creates a new nodeList which tracks the number of nodes in the cluster.

type SerfNodeJoinHandler

type SerfNodeJoinHandler struct {
	// ClusterManager ClusterManager
	Cluster NodeList
	Logger  log.Logger
}

SerfNodeJoinHandler processes cluster Join events.

func (*SerfNodeJoinHandler) HandleMemberEvent

func (s *SerfNodeJoinHandler) HandleMemberEvent(me serf.MemberEvent)

HandleMemberEvent is used to handle join events on the serf cluster.

type SerfNodeLeaveHandler

type SerfNodeLeaveHandler struct {
	Cluster NodeList
	Logger  log.Logger
}

SerfNodeLeaveHandler processes cluster leave events.

func (*SerfNodeLeaveHandler) HandleMemberEvent

func (s *SerfNodeLeaveHandler) HandleMemberEvent(me serf.MemberEvent)

HandleMemberEvent is used to handle fail events in the Serf cluster.

type SerfNodeUpdateHandler

type SerfNodeUpdateHandler struct {
	Cluster NodeList
	Logger  log.Logger
}

func (*SerfNodeUpdateHandler) HandleMemberEvent

func (s *SerfNodeUpdateHandler) HandleMemberEvent(me serf.MemberEvent)

nodeJoin is used to handle join events on the both serf clusters

type SerfReconciler

type SerfReconciler struct {
	ReconcileCh chan serf.Member
}

SerfReconciler dispatches membership changes to Raft. If IsLeader is nil, the server will panic.

func (*SerfReconciler) Reconcile

func (s *SerfReconciler) Reconcile(m serf.Member)

Reconcile is used to reconcile Serf events with the strongly consistent store if we are the current leader

type SerfUserEventHandler

type SerfUserEventHandler struct {
	Logger      log.Logger
	UserEventCh chan serf.UserEvent
}

SerfUserEventHandler handles both local and remote user events in Serf.

func (*SerfUserEventHandler) HandleUserEvent

func (s *SerfUserEventHandler) HandleUserEvent(event serf.UserEvent)

HandleUserEvent is called when a user event is received from both local and remote nodes.

type Server

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

func NewServer

func NewServer(c *DatabaseConfig) (server *Server, err error)

func (*Server) Encrypted

func (s *Server) Encrypted() bool

Encrypted determines if gossip is encrypted

func (*Server) IsLeader

func (s *Server) IsLeader() bool

IsLeader checks if this server is the cluster leader

func (*Server) Join

func (s *Server) Join(addrs []string) (int, error)

Join is used to have Kappa join the cluster. The target address should be another node inside the cluster listening on the Serf address

func (*Server) KeyManager

func (s *Server) KeyManager() *serf.KeyManager

KeyManager returns the Serf keyring manager

func (*Server) LocalMember

func (c *Server) LocalMember() serf.Member

LocalMember is used to return the local node

func (*Server) Members

func (s *Server) Members() []serf.Member

Members is used to return the members of the cluster

func (*Server) RemoveFailedNode

func (s *Server) RemoveFailedNode(node string) error

RemoveFailedNode is used to remove a failed node from the cluster

func (*Server) Start

func (s *Server) Start() error

func (*Server) Stop

func (s *Server) Stop()

Jump to

Keyboard shortcuts

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