Represents a cluster definition. More...
#include <ClusterDefinition.h>
Public Member Functions | |
ClusterDefinition (const std::string &fname) | |
Constructor. More... | |
void | get_role_members (const std::string &role, std::vector< std::string > &members, int64_t *generation=nullptr) |
Get list of members of a role This method first refreshes its view of the cluster definition by reloading the cluster definition file, m_fname, if it has not been modified since the last refresh. More... | |
Private Member Functions | |
void | load_file () |
Load cluster definition from file Loads the cluster definition from the file m_fname, if the file was modified since the last time it was loaded. More... | |
void | add_role (const std::string &text) |
Parses a role definition statement Parses the role definition statement contained in text and adds the information to m_roles. More... | |
Private Attributes | |
std::mutex | m_mutex |
Mutex for serializing access to members. More... | |
std::string | m_fname |
Name of cluster definition file. More... | |
time_t | m_last_mtime |
Last modification time of cluster definition file. More... | |
std::unordered_map < std::string, std::vector < std::string > > | m_roles |
Map from role names to members. More... | |
Represents a cluster definition.
Definition at line 43 of file ClusterDefinition.h.
|
inline |
Constructor.
fname | Pathname of cluster definition file |
Definition at line 49 of file ClusterDefinition.h.
|
private |
Parses a role definition statement Parses the role definition statement contained in text
and adds the information to m_roles.
text |
Definition at line 94 of file ClusterDefinition.cc.
void ClusterDefinition::ClusterDefinition::get_role_members | ( | const std::string & | role, |
std::vector< std::string > & | members, | ||
int64_t * | generation = nullptr |
||
) |
Get list of members of a role This method first refreshes its view of the cluster definition by reloading the cluster definition file, m_fname, if it has not been modified since the last refresh.
If a role by the name of role
exists in the cluster definition, members
is populated with the corresponding members. If the generation
parameter is not nullptr, then it is set to the generation number of the cluster definition file (last modification time). If the cluster definition file, m_fname, does not exist, members
is cleared and the generation
is set to 0.
role | Role name |
members | Reference to vector to hold members |
generation | Address of variable populated with definition generation number |
Definition at line 52 of file ClusterDefinition.cc.
|
private |
Load cluster definition from file Loads the cluster definition from the file m_fname, if the file was modified since the last time it was loaded.
Definition at line 69 of file ClusterDefinition.cc.
|
private |
Name of cluster definition file.
Definition at line 86 of file ClusterDefinition.h.
|
private |
Last modification time of cluster definition file.
Definition at line 89 of file ClusterDefinition.h.
|
private |
Mutex for serializing access to members.
Definition at line 83 of file ClusterDefinition.h.
|
private |
Map from role names to members.
Definition at line 92 of file ClusterDefinition.h.