libuav original

Dependents:   UAVCAN UAVCAN_Subscriber

Embed: (wiki syntax)

« Back to documentation index

ClusterManager Class Reference

ClusterManager Class Reference

This class maintains the cluster state. More...

#include <cluster_manager.hpp>

Inherits uavcan::TimerBase.

Public Member Functions

 ClusterManager (INode &node, IStorageBackend &storage, const Log &log, IEventTracer &tracer)
int init (const uint8_t init_cluster_size, const TransferPriority priority)
 If cluster_size is set to ClusterSizeUnknown, the class will try to read this parameter from the storage backend using key 'cluster_size'.
void addServer (NodeID node_id)
 Adds once server regardless of the discovery logic.
bool isKnownServer (NodeID node_id) const
 Whether such server has been discovered.
NodeID getRemoteServerNodeIDAtIndex (uint8_t index) const
 An invalid node ID will be returned if there's no such server.
Log::Index getServerNextIndex (NodeID server_node_id) const
 See next_index[] in Raft paper.
Log::Index getServerMatchIndex (NodeID server_node_id) const
 See match_index[] in Raft paper.
void resetAllServerIndices ()
 This method must be called when the current server becomes leader.
uint8_t getNumKnownServers () const
 Number of known servers can only grow, and it never exceeds the cluster size value.
uint8_t getClusterSize () const
 Cluster size and quorum size are constant.

Private Member Functions

void startOneShotWithDeadline (MonotonicTime deadline)
 Various ways to start the timer - periodically or once.
MonotonicDuration getPeriod () const
 Returns period if the timer is in periodic mode.

Detailed Description

This class maintains the cluster state.

Definition at line 30 of file cluster_manager.hpp.


Constructor & Destructor Documentation

ClusterManager ( INode node,
IStorageBackend storage,
const Log log,
IEventTracer tracer 
)
Parameters:
nodeNeeded to publish and subscribe to Discovery message
storageNeeded to read the cluster size parameter from the storage
logNeeded to initialize nextIndex[] values after elections

Definition at line 194 of file cluster_manager.hpp.


Member Function Documentation

void addServer ( NodeID  node_id )

Adds once server regardless of the discovery logic.

Definition at line 285 of file cluster_manager.hpp.

uint8_t getClusterSize (  ) const

Cluster size and quorum size are constant.

Definition at line 423 of file cluster_manager.hpp.

uint8_t getNumKnownServers (  ) const

Number of known servers can only grow, and it never exceeds the cluster size value.

This number does not include the local server.

Definition at line 418 of file cluster_manager.hpp.

NodeID getRemoteServerNodeIDAtIndex ( uint8_t  index ) const

An invalid node ID will be returned if there's no such server.

The local server is not listed there.

Definition at line 326 of file cluster_manager.hpp.

Log::Index getServerMatchIndex ( NodeID  server_node_id ) const

See match_index[] in Raft paper.

Definition at line 378 of file cluster_manager.hpp.

Log::Index getServerNextIndex ( NodeID  server_node_id ) const

See next_index[] in Raft paper.

Definition at line 338 of file cluster_manager.hpp.

int init ( const uint8_t  init_cluster_size,
const TransferPriority  priority 
)

If cluster_size is set to ClusterSizeUnknown, the class will try to read this parameter from the storage backend using key 'cluster_size'.

Returns negative error code.

Definition at line 210 of file cluster_manager.hpp.

bool isKnownServer ( NodeID  node_id ) const

Whether such server has been discovered.

Definition at line 304 of file cluster_manager.hpp.

void resetAllServerIndices (  )

This method must be called when the current server becomes leader.

Definition at line 405 of file cluster_manager.hpp.