Documentation ¶
Index ¶
- Constants
- Variables
- type Cluster
- type ClusterAlerts
- type ClusterData
- type ClusterInfo
- type ClusterInitState
- type ClusterListener
- type ClusterListenerAlertOps
- type ClusterListenerGenericOps
- type ClusterListenerNodeOps
- type ClusterListenerPairOps
- type ClusterListenerStatusOps
- type ClusterNotify
- type ClusterPair
- type ClusterRemove
- type ClusterServerConfiguration
- type ClusterState
- type ClusterStatus
- type FinalizeInitCb
- type NodeEntry
- type NullClusterAlerts
- type NullClusterData
- func (m *NullClusterData) DisableUpdates() error
- func (m *NullClusterData) EnableUpdates() error
- func (m *NullClusterData) GetData() (map[string]*api.Node, error)
- func (m *NullClusterData) GetGossipState() *ClusterState
- func (m *NullClusterData) GetNodeIdFromIp(arg0 string) (string, error)
- func (m *NullClusterData) UpdateData(arg0 map[string]interface{}) error
- func (m *NullClusterData) UpdateLabels(arg0 map[string]string) error
- type NullClusterListener
- func (nc *NullClusterListener) Add(node *api.Node) error
- func (nc *NullClusterListener) CanNodeRemove(node *api.Node) (string, error)
- func (nc *NullClusterListener) CleanupInit(self *api.Node, clusterInfo *ClusterInfo) error
- func (nc *NullClusterListener) ClusterInit(self *api.Node) error
- func (nc *NullClusterListener) CreatePair(response *api.ClusterPairProcessResponse) error
- func (nc *NullClusterListener) Enumerate(cluster api.Cluster) error
- func (nc *NullClusterListener) EnumerateAlerts(timeStart, timeEnd time.Time, resource api.ResourceType) (*api.Alerts, error)
- func (nc *NullClusterListener) EraseAlert(resource api.ResourceType, alertID int64) error
- func (nc *NullClusterListener) Halt(self *api.Node, clusterInfo *ClusterInfo) error
- func (nc *NullClusterListener) Init(self *api.Node, state *ClusterInfo) (FinalizeInitCb, error)
- func (nc *NullClusterListener) Join(self *api.Node, state *ClusterInitState, clusterNotify ClusterNotify) error
- func (nc *NullClusterListener) JoinComplete(self *api.Node) error
- func (nc *NullClusterListener) Leave(node *api.Node) error
- func (nc *NullClusterListener) ListenerData() map[string]interface{}
- func (nc *NullClusterListener) ListenerPeerStatus() map[string]api.Status
- func (nc *NullClusterListener) ListenerStatus() api.Status
- func (nc *NullClusterListener) MarkNodeDown(node *api.Node) error
- func (nc *NullClusterListener) ProcessPairRequest(request *api.ClusterPairProcessRequest, ...) error
- func (nc *NullClusterListener) QuorumMember(node *api.Node) bool
- func (nc *NullClusterListener) Remove(node *api.Node, forceRemove bool) error
- func (nc *NullClusterListener) String() string
- func (nc *NullClusterListener) Update(node *api.Node) error
- func (nc *NullClusterListener) UpdateCluster(self *api.Node, clusterInfo *ClusterInfo) error
- type NullClusterManager
- func (m *NullClusterManager) AddEventListener(arg0 ClusterListener) error
- func (m *NullClusterManager) Enumerate() (api.Cluster, error)
- func (m *NullClusterManager) Inspect(arg0 string) (api.Node, error)
- func (m *NullClusterManager) SetSize(arg0 int) error
- func (m *NullClusterManager) Shutdown() error
- func (m *NullClusterManager) Start(arg0 int, arg1 bool, arg2 string) error
- func (m *NullClusterManager) StartWithConfiguration(arg0 int, arg1 bool, arg2 string, arg3 *ClusterServerConfiguration) error
- func (n *NullClusterManager) Uuid() string
- type NullClusterPair
- func (m *NullClusterPair) CreatePair(arg0 *api.ClusterPairCreateRequest) (*api.ClusterPairCreateResponse, error)
- func (m *NullClusterPair) DeletePair(arg0 string) error
- func (m *NullClusterPair) EnumeratePairs() (*api.ClusterPairsEnumerateResponse, error)
- func (m *NullClusterPair) GetPair(arg0 string) (*api.ClusterPairGetResponse, error)
- func (m *NullClusterPair) GetPairToken(arg0 bool) (*api.ClusterPairTokenGetResponse, error)
- func (m *NullClusterPair) ProcessPairRequest(arg0 *api.ClusterPairProcessRequest) (*api.ClusterPairProcessResponse, error)
- func (m *NullClusterPair) RefreshPair(arg0 string) error
- type NullClusterRemove
- type NullClusterStatus
Constants ¶
const ( // APIVersion for cluster APIs APIVersion = "v1" // APIBase url for cluster APIs APIBase = "/var/lib/osd/cluster/" )
Variables ¶
var ( // ErrNodeRemovePending is returned when Node remove does not succeed and is // kept in pending state ErrNodeRemovePending = errors.New("Node remove is pending") ErrInitNodeNotFound = errors.New("This node is already initialized but " + "could not be found in the cluster map.") ErrNodeDecommissioned = errors.New("Node is decomissioned.") ErrRemoveCausesDataLoss = errors.New("Cannot remove node without data loss") ErrNotImplemented = errors.New("Not Implemented") )
Functions ¶
This section is empty.
Types ¶
type Cluster ¶
type Cluster interface { // Inspect the node given a UUID. Inspect(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) // SetSize sets the maximum number of nodes in a cluster. SetSize(size int) error // Shutdown can be called when THIS node is gracefully shutting down. Shutdown() error // Start starts the cluster manager and state machine. // It also causes this node to join the cluster. // nodeInitialized indicates if the caller of this method expects the node // to have been in an already-initialized state. // All managers will default returning NotSupported. Start(clusterSize int, nodeInitialized bool, gossipPort string) error // Like Start, but have the ability to pass in managers to the cluster object StartWithConfiguration(clusterMaxSize int, nodeInitialized bool, gossipPort string, config *ClusterServerConfiguration) error // Get a unique identifier for this cluster. Depending on the implementation, this could // be different than the _id_ from ClusterInfo. This id _must_ be unique across // any cluster. Uuid() string ClusterData ClusterRemove ClusterStatus ClusterAlerts ClusterPair osdconfig.ConfigCaller secrets.Secrets sched.SchedulePolicyProvider objectstore.ObjectStore }
Cluster is the API that a cluster provider will implement.
func NewDefaultClusterManager ¶
func NewDefaultClusterManager() Cluster
type ClusterAlerts ¶
type ClusterAlerts interface { // Enumerate enumerates alerts on this cluster for the given resource // within a specific time range. EnumerateAlerts(timeStart, timeEnd time.Time, resource api.ResourceType) (*api.Alerts, error) // EraseAlert erases an alert for the given resource EraseAlert(resource api.ResourceType, alertID int64) error }
func NewDefaultClusterAlerts ¶
func NewDefaultClusterAlerts() ClusterAlerts
type ClusterData ¶
type ClusterData interface { // UpdateData updates node data associated with this node UpdateData(nodeData map[string]interface{}) error // UpdateLabels updates node labels associated with this node UpdateLabels(nodeLabels map[string]string) error // GetData get sdata associated with all nodes. // Key is the node id GetData() (map[string]*api.Node, error) // GetNodeIdFromIp returns a Node Id given an IP. GetNodeIdFromIp(idIp string) (string, error) // EnableUpdate cluster data updates to be sent to listeners EnableUpdates() error // DisableUpdates disables cluster data updates to be sent to listeners DisableUpdates() error // GetGossipState returns the state of nodes according to gossip GetGossipState() *ClusterState }
ClusterData interface provides apis to handle data of the cluster
func NewDefaultClusterData ¶
func NewDefaultClusterData() ClusterData
type ClusterInfo ¶
type ClusterInfo struct { Size int Status api.Status Id string NodeEntries map[string]NodeEntry PairToken string }
ClusterInfo is the basic info about the cluster and its nodes
type ClusterInitState ¶
type ClusterInitState struct { ClusterInfo *ClusterInfo InitDb kvdb.Kvdb Version uint64 Collector kvdb.UpdatesCollector }
ClusterInitState is the snapshot state which should be used to initialize
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) error // Init is called when this node is joining an existing cluster for the first time. Init(self *api.Node, state *ClusterInfo) (FinalizeInitCb, error) // Join is called when this node is joining an existing cluster. Join(self *api.Node, state *ClusterInitState, clusterNotify ClusterNotify) error // JoinComplete is called when this node has successfully joined a cluster JoinComplete(self *api.Node) error // CleanupInit is called when Init failed. CleanupInit(self *api.Node, clusterInfo *ClusterInfo) error // Halt is called when a node is gracefully shutting down. Halt(self *api.Node, clusterInfo *ClusterInfo) error ClusterListenerNodeOps ClusterListenerStatusOps ClusterListenerGenericOps ClusterListenerAlertOps ClusterListenerPairOps }
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. The basic set of APIs determine the lifecycle of a node and comprises of two operations 1. Setup ClusterInit -> (Node)Init -> Join -> JoinComplete 2. Teardown Halt -> CleanupInit The other APIs are helpers for cluster manager.
type ClusterListenerAlertOps ¶
type ClusterListenerAlertOps interface { ClusterAlerts }
ClusterListenerAlertOps is a wrapper over ClusterAlerts interface which the listeners need to implement if they want to handle alerts
type ClusterListenerGenericOps ¶
type ClusterListenerGenericOps interface { // ListenerData returns the data that the listener wants to share // with ClusterManager and would be stored in NodeData field. ListenerData() map[string]interface{} // QuorumMember returns true if the listener wants this node to // participate in quorum decisions. QuorumMember(node *api.Node) bool // UpdateClusterInfo is called when there is an update to the cluster. // XXX: Remove ClusterInfo from this API UpdateCluster(self *api.Node, clusterInfo *ClusterInfo) error // Enumerate updates listener specific data in Enumerate. Enumerate(cluster api.Cluster) error }
ClusterListenerGenericOps defines a set of generic helper APIs for listeners to implement
type ClusterListenerNodeOps ¶
type ClusterListenerNodeOps interface { // 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, forceRemove bool) error // CanNodeRemove test to see if we can remove this node CanNodeRemove(node *api.Node) (string, error) // MarkNodeDown marks the given node's status as down MarkNodeDown(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 }
ClusterListenerNodeOps defines APIs that a listener needs to implement to handle various node operations/updates
type ClusterListenerPairOps ¶
type ClusterListenerPairOps interface { // CreatePair is called when we are pairing with another cluster CreatePair(response *api.ClusterPairProcessResponse) error // ProcessPairRequest is called when we get a pair request from another cluster ProcessPairRequest(request *api.ClusterPairProcessRequest, response *api.ClusterPairProcessResponse) error }
ClusterListenerPairOps is an interface that must be implemented to support pairing of multiple clusters. It will be used at the destination cluster to listen for incoming pairing requests.
type ClusterListenerStatusOps ¶
type ClusterListenerStatusOps interface { // ListenerStatus returns the listener's Status ListenerStatus() api.Status // ListenerPeerStatus returns the peer Statuses for a listener ListenerPeerStatus() map[string]api.Status }
ClusterListenerStatusOps defines APIs that a listener needs to implement to indicate its own/peer statuses
type ClusterNotify ¶
type ClusterNotify func(string, api.ClusterNotify) (string, error)
ClusterNotify is the callback function listeners can use to notify cluster manager
type ClusterPair ¶
type ClusterPair interface { // PairCreate with a remote cluster CreatePair(*api.ClusterPairCreateRequest) (*api.ClusterPairCreateResponse, error) // PairProcess handles an incoming pair request from a remote cluster ProcessPairRequest(*api.ClusterPairProcessRequest) (*api.ClusterPairProcessResponse, error) // GetPair returns pair information for a cluster GetPair(string) (*api.ClusterPairGetResponse, error) // EnumeratePairs returns list of cluster pairs EnumeratePairs() (*api.ClusterPairsEnumerateResponse, error) // RefreshPair Refreshes a cluster pairing by fetching latest information // from the remote cluster RefreshPair(string) error // DeletePair Delete a cluster pairing DeletePair(string) error // GetPairToken gets the authentication token for this cluster GetPairToken(bool) (*api.ClusterPairTokenGetResponse, error) }
func NewDefaultCluterPair ¶
func NewDefaultCluterPair() ClusterPair
type ClusterRemove ¶
type ClusterRemove interface { // Remove node(s) from the cluster permanently. Remove(nodes []api.Node, forceRemove bool) error // NodeRemoveDone notify cluster manager NodeRemove is done. NodeRemoveDone(nodeID string, result error) }
ClusterRemove interface provides apis for removing nodes from a cluster
func NewDefaultClusterRemove ¶
func NewDefaultClusterRemove() ClusterRemove
type ClusterServerConfiguration ¶
type ClusterServerConfiguration struct { // holds implementation to Secrets interface ConfigSecretManager secrets.Secrets // holds implementeation to SchedulePolicy interface ConfigSchedManager sched.SchedulePolicyProvider // holds implementation to ObjectStore interface ConfigObjectStoreManager objectstore.ObjectStore }
ClusterServerConfiguration holds manager implementation Caller has to create the manager and passes it in
type ClusterState ¶
ClusterState is the gossip state of all nodes in the cluster
type ClusterStatus ¶
type ClusterStatus interface { // NodeStatus returns the status of THIS node as seen by the Cluster Provider // for a given listener. If listenerName is empty it returns the status of // THIS node maintained by the Cluster Provider. // At any time the status of the Cluster Provider takes precedence over // the status of listener. Precedence is determined by the severity of the status. NodeStatus() (api.Status, error) // PeerStatus returns the statuses of all peer nodes as seen by the // Cluster Provider for a given listener. If listenerName is empty is returns the // statuses of all peer nodes as maintained by the ClusterProvider (gossip) PeerStatus(listenerName string) (map[string]api.Status, error) }
ClusterStatus interface provides apis for cluster and node status
func NewDefaultClusterStatus ¶
func NewDefaultClusterStatus() ClusterStatus
type FinalizeInitCb ¶
type FinalizeInitCb func() error
FinalizeInitCb is invoked when init is complete and is in the process of updating the cluster database. This callback is invoked under lock and must finish quickly, else it will slow down other node joins.
type NodeEntry ¶
type NodeEntry struct { Id string SchedulerNodeName string MgmtIp string DataIp string GenNumber uint64 StartTime time.Time MemTotal uint64 Hostname string Status api.Status NodeLabels map[string]string NonQuorumMember bool }
NodeEntry is used to discover other nodes in the cluster and setup the gossip protocol with them.
type NullClusterAlerts ¶
type NullClusterAlerts struct { }
NullClusterAlerts is a NULL implementation of the ClusterAlerts interface
func (*NullClusterAlerts) EnumerateAlerts ¶
func (m *NullClusterAlerts) EnumerateAlerts(arg0, arg1 time.Time, arg2 api.ResourceType) (*api.Alerts, error)
EnumerateAlerts
func (*NullClusterAlerts) EraseAlert ¶
func (m *NullClusterAlerts) EraseAlert(arg0 api.ResourceType, arg1 int64) error
EraseAlert
type NullClusterData ¶
type NullClusterData struct { }
NullClusterData is a NULL implementation of the ClusterData interface
func (*NullClusterData) DisableUpdates ¶
func (m *NullClusterData) DisableUpdates() error
DisableUpdates
func (*NullClusterData) EnableUpdates ¶
func (m *NullClusterData) EnableUpdates() error
EnableUpdates
func (*NullClusterData) GetData ¶
func (m *NullClusterData) GetData() (map[string]*api.Node, error)
GetData
func (*NullClusterData) GetGossipState ¶
func (m *NullClusterData) GetGossipState() *ClusterState
GetGossipState
func (*NullClusterData) GetNodeIdFromIp ¶
func (m *NullClusterData) GetNodeIdFromIp(arg0 string) (string, error)
GetNodeIdFromIp
func (*NullClusterData) UpdateData ¶
func (m *NullClusterData) UpdateData(arg0 map[string]interface{}) error
UpdateData
func (*NullClusterData) UpdateLabels ¶
func (m *NullClusterData) UpdateLabels(arg0 map[string]string) error
UpdateLabels
type NullClusterListener ¶
type NullClusterListener struct { }
NullClusterListener is a NULL implementation of ClusterListener functions ClusterListeners should use this as the base override functions they are interested in.
func (*NullClusterListener) CanNodeRemove ¶
func (nc *NullClusterListener) CanNodeRemove(node *api.Node) (string, error)
func (*NullClusterListener) CleanupInit ¶
func (nc *NullClusterListener) CleanupInit( self *api.Node, clusterInfo *ClusterInfo, ) error
func (*NullClusterListener) ClusterInit ¶
func (nc *NullClusterListener) ClusterInit(self *api.Node) error
func (*NullClusterListener) CreatePair ¶
func (nc *NullClusterListener) CreatePair( response *api.ClusterPairProcessResponse, ) error
func (*NullClusterListener) Enumerate ¶
func (nc *NullClusterListener) Enumerate(cluster api.Cluster) error
func (*NullClusterListener) EnumerateAlerts ¶
func (nc *NullClusterListener) EnumerateAlerts( timeStart, timeEnd time.Time, resource api.ResourceType, ) (*api.Alerts, error)
func (*NullClusterListener) EraseAlert ¶
func (nc *NullClusterListener) EraseAlert( resource api.ResourceType, alertID int64, ) error
func (*NullClusterListener) Halt ¶
func (nc *NullClusterListener) Halt( self *api.Node, clusterInfo *ClusterInfo) error
func (*NullClusterListener) Init ¶
func (nc *NullClusterListener) Init(self *api.Node, state *ClusterInfo) (FinalizeInitCb, error)
func (*NullClusterListener) Join ¶
func (nc *NullClusterListener) Join( self *api.Node, state *ClusterInitState, clusterNotify ClusterNotify, ) error
func (*NullClusterListener) JoinComplete ¶
func (nc *NullClusterListener) JoinComplete( self *api.Node, ) error
func (*NullClusterListener) ListenerData ¶
func (nc *NullClusterListener) ListenerData() map[string]interface{}
func (*NullClusterListener) ListenerPeerStatus ¶
func (nc *NullClusterListener) ListenerPeerStatus() map[string]api.Status
func (*NullClusterListener) ListenerStatus ¶
func (nc *NullClusterListener) ListenerStatus() api.Status
func (*NullClusterListener) MarkNodeDown ¶
func (nc *NullClusterListener) MarkNodeDown(node *api.Node) error
func (*NullClusterListener) ProcessPairRequest ¶
func (nc *NullClusterListener) ProcessPairRequest( request *api.ClusterPairProcessRequest, response *api.ClusterPairProcessResponse, ) error
func (*NullClusterListener) QuorumMember ¶
func (nc *NullClusterListener) QuorumMember(node *api.Node) bool
func (*NullClusterListener) Remove ¶
func (nc *NullClusterListener) Remove(node *api.Node, forceRemove bool) error
func (*NullClusterListener) String ¶
func (nc *NullClusterListener) String() string
func (*NullClusterListener) UpdateCluster ¶
func (nc *NullClusterListener) UpdateCluster(self *api.Node, clusterInfo *ClusterInfo, ) error
type NullClusterManager ¶
type NullClusterManager struct { NullClusterData NullClusterRemove NullClusterStatus NullClusterAlerts NullClusterPair osdconfig.NullConfigCaller secrets.NullSecrets schedpolicy.NullSchedMgr objectstore.NullObjectStoreMgr }
NullClusterManager is a NULL implementation of the Cluster interface It is primarily used for testing the ClusterManager as well as the ClusterListener interface
func (*NullClusterManager) AddEventListener ¶
func (m *NullClusterManager) AddEventListener(arg0 ClusterListener) error
AddEventListener
func (*NullClusterManager) Enumerate ¶
func (m *NullClusterManager) Enumerate() (api.Cluster, error)
Enumerate
func (*NullClusterManager) Inspect ¶
func (m *NullClusterManager) Inspect(arg0 string) (api.Node, error)
Inspect
func (*NullClusterManager) Start ¶
func (m *NullClusterManager) Start(arg0 int, arg1 bool, arg2 string) error
Start
func (*NullClusterManager) StartWithConfiguration ¶
func (m *NullClusterManager) StartWithConfiguration(arg0 int, arg1 bool, arg2 string, arg3 *ClusterServerConfiguration) error
StartWithConfiguration
func (*NullClusterManager) Uuid ¶
func (n *NullClusterManager) Uuid() string
type NullClusterPair ¶
type NullClusterPair struct { }
NullClusterPair is a NULL implementation of the ClusterPair interface
func (*NullClusterPair) CreatePair ¶
func (m *NullClusterPair) CreatePair(arg0 *api.ClusterPairCreateRequest) (*api.ClusterPairCreateResponse, error)
CreatePair
func (*NullClusterPair) DeletePair ¶
func (m *NullClusterPair) DeletePair(arg0 string) error
DeletePair
func (*NullClusterPair) EnumeratePairs ¶
func (m *NullClusterPair) EnumeratePairs() (*api.ClusterPairsEnumerateResponse, error)
EnumeratePairs
func (*NullClusterPair) GetPair ¶
func (m *NullClusterPair) GetPair(arg0 string) (*api.ClusterPairGetResponse, error)
GetPair
func (*NullClusterPair) GetPairToken ¶
func (m *NullClusterPair) GetPairToken(arg0 bool) (*api.ClusterPairTokenGetResponse, error)
GetPairToken
func (*NullClusterPair) ProcessPairRequest ¶
func (m *NullClusterPair) ProcessPairRequest(arg0 *api.ClusterPairProcessRequest) (*api.ClusterPairProcessResponse, error)
ProcessPairRequest
func (*NullClusterPair) RefreshPair ¶
func (m *NullClusterPair) RefreshPair(arg0 string) error
RefreshPair
type NullClusterRemove ¶
type NullClusterRemove struct { }
NullClusterRemove is a NULL implementation of the ClusterRemove interface
func (*NullClusterRemove) NodeRemoveDone ¶
func (m *NullClusterRemove) NodeRemoveDone(arg0 string, arg1 error)
NodeRemoveDone
type NullClusterStatus ¶
type NullClusterStatus struct { }
NullClusterStatus is a NULL implementation of the ClusterStatus interface
func (*NullClusterStatus) NodeStatus ¶
func (m *NullClusterStatus) NodeStatus() (api.Status, error)
Nodestatus
func (*NullClusterStatus) PeerStatus ¶
PeerStatus