0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Hypertable::ClusterDefinition::ClusterDefinition Class Reference

Represents a cluster definition. More...

#include <ClusterDefinition.h>

Collaboration diagram for Hypertable::ClusterDefinition::ClusterDefinition:
Collaboration graph
[legend]

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...
 

Detailed Description

Represents a cluster definition.

Definition at line 43 of file ClusterDefinition.h.

Constructor & Destructor Documentation

Hypertable::ClusterDefinition::ClusterDefinition::ClusterDefinition ( const std::string &  fname)
inline

Constructor.

Parameters
fnamePathname of cluster definition file

Definition at line 49 of file ClusterDefinition.h.

Member Function Documentation

void ClusterDefinition::ClusterDefinition::add_role ( const std::string &  text)
private

Parses a role definition statement Parses the role definition statement contained in text and adds the information to m_roles.

Parameters
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.

Parameters
roleRole name
membersReference to vector to hold members
generationAddress of variable populated with definition generation number

Definition at line 52 of file ClusterDefinition.cc.

void ClusterDefinition::ClusterDefinition::load_file ( )
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.

Member Data Documentation

std::string Hypertable::ClusterDefinition::ClusterDefinition::m_fname
private

Name of cluster definition file.

Definition at line 86 of file ClusterDefinition.h.

time_t Hypertable::ClusterDefinition::ClusterDefinition::m_last_mtime
private

Last modification time of cluster definition file.

Definition at line 89 of file ClusterDefinition.h.

std::mutex Hypertable::ClusterDefinition::ClusterDefinition::m_mutex
private

Mutex for serializing access to members.

Definition at line 83 of file ClusterDefinition.h.

std::unordered_map<std::string, std::vector<std::string> > Hypertable::ClusterDefinition::ClusterDefinition::m_roles
private

Map from role names to members.

Definition at line 92 of file ClusterDefinition.h.


The documentation for this class was generated from the following files: