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 ¶
- func Start() error
- type Cluster
- type ClusterListener
- type ClusterManager
- func (c *ClusterManager) AddEventListener(listener ClusterListener) error
- func (c *ClusterManager) Enumerate() (api.Cluster, error)
- func (c *ClusterManager) Init() error
- func (c *ClusterManager) LocateNode(nodeID string) (api.Node, error)
- func (c *ClusterManager) Remove(nodes []api.Node) error
- func (c *ClusterManager) Shutdown(cluster bool, nodes []api.Node) error
- func (c *ClusterManager) Start() error
- type Config
- type Database
- type NodeEntry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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) Init ¶
func (c *ClusterManager) Init() error
func (*ClusterManager) LocateNode ¶
func (c *ClusterManager) LocateNode(nodeID string) (api.Node, error)
func (*ClusterManager) Shutdown ¶
func (c *ClusterManager) Shutdown(cluster bool, nodes []api.Node) error
func (*ClusterManager) Start ¶
func (c *ClusterManager) Start() error
Click to show internal directories.
Click to hide internal directories.