cluster

package
v0.0.0-...-585c797 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2015 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
}

Cluster is the API that a cluster provider will implement.

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

	// 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 Inst

func Inst() (*ClusterManager, error)

Inst returns an instance of an already instantiated cluster manager.

func New

func New(cfg Config, kv kvdb.Kvdb) (*ClusterManager, error)

New instantiates and starts a new cluster manager.

func (*ClusterManager) AddEventListener

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

func (*ClusterManager) Enumerate

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

func (*ClusterManager) Init

func (c *ClusterManager) Init() error

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

type Config

type Config struct {
	ClusterId string
	NodeId    string
}

type Database

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

type NodeEntry

type NodeEntry struct {
	Id string
	Ip string
}

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