cluster

package
v0.0.0-...-6e535ca Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2016 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

This file implements a cluster state machine. It relies on a cluster wide key-value store for coordinating the state of the cluster. It also stores the state of the cluster in this key-value store.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Start

func Start() error

Start will run the cluster manager daemon.

Types

type Cluster

type Cluster interface {
	// LocateNode find the node given a UUID.
	LocateNode(string) (api.Node, error)

	// AddEventListener adds an event listener and exposes cluster events.
	AddEventListener(ClusterListener) error

	// Enumerate lists all the nodes in the cluster.
	Enumerate() (api.Cluster, error)

	// Remove node(s) from the cluster permanently.
	Remove(nodes []api.Node) error

	// Shutdown node(s) or the entire cluster.
	Shutdown(cluster bool, nodes []api.Node) error

	// Start starts the cluster manager and state machine.
	// It also causes this node to join the cluster.
	Start() error

	ClusterData
}

Cluster is the API that a cluster provider will implement.

func Inst

func Inst() (Cluster, error)

Inst returns an instance of an already instantiated cluster manager.

func New

func New(cfg Config, kv kvdb.Kvdb, dockerClient *docker.Client) Cluster

New instantiates and starts a new cluster manager.

type ClusterData

type ClusterData interface {
	// Update node data associated with this node
	UpdateData(dataKey string, value interface{})

	// Get data associated with all nodes.
	// Key is the node id
	GetData() map[string]*api.Node

	// Enables cluster data updates to be sent to listeners
	EnableUpdates()

	// Disables cluster data updates to be sent to listeners
	DisableUpdates()

	// Status of nodes according to gossip
	GetState() *ClusterState
}

type ClusterListener

type ClusterListener interface {
	// String returns a string representation of this listener.
	String() string

	// ClusterInit is called when a brand new cluster is initialized.
	ClusterInit(self *api.Node, db *Database) error

	// Init is called when this node is joining an existing cluster for the first time.
	Init(self *api.Node, db *Database) error

	// CleanupInit is called when Init failed.
	CleanupInit(self *api.Node, db *Database) error

	// Join is called when this node is joining an existing cluster.
	Join(self *api.Node, db *Database) error

	// Add is called when a new node joins the cluster.
	Add(node *api.Node) error

	// Remove is called when a node leaves the cluster
	Remove(node *api.Node) error

	// Update is called when a node status changes significantly
	// in the cluster changes.
	Update(node *api.Node) error

	// Leave is called when this node leaves the cluster.
	Leave(node *api.Node) error
}

ClusterListener is an interface to be implemented by a storage driver if it is participating in a multi host environment. It exposes events in the cluster state machine. Your driver can do the needful when these events are provided.

type ClusterManager

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

func (*ClusterManager) AddEventListener

func (c *ClusterManager) AddEventListener(listener ClusterListener) error

func (*ClusterManager) DisableUpdates

func (c *ClusterManager) DisableUpdates()

func (*ClusterManager) EnableUpdates

func (c *ClusterManager) EnableUpdates()

func (*ClusterManager) Enumerate

func (c *ClusterManager) Enumerate() (api.Cluster, error)

func (*ClusterManager) GetData

func (c *ClusterManager) GetData() map[string]*api.Node

func (*ClusterManager) GetState

func (c *ClusterManager) GetState() *ClusterState

func (*ClusterManager) LocateNode

func (c *ClusterManager) LocateNode(nodeID string) (api.Node, error)

func (*ClusterManager) Remove

func (c *ClusterManager) Remove(nodes []api.Node) error

func (*ClusterManager) Shutdown

func (c *ClusterManager) Shutdown(cluster bool, nodes []api.Node) error

func (*ClusterManager) Start

func (c *ClusterManager) Start() error

func (*ClusterManager) UpdateData

func (c *ClusterManager) UpdateData(dataKey string, value interface{})

type ClusterState

type ClusterState struct {
	History    []*types.GossipSessionInfo
	NodeStatus []types.NodeValue
}

type Config

type Config struct {
	ClusterId string
	NodeId    string
	MgtIface  string
	DataIface string
}

type Database

type Database struct {
	Status      api.Status
	Id          string
	NodeEntries map[string]NodeEntry
}

type NodeEntry

type NodeEntry struct {
	Id        string
	Ip        string
	GenNumber uint64
}

NodeEntry is used to discover other nodes in the cluster and setup the gossip protocol with them.

Jump to

Keyboard shortcuts

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