0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ClusterDefinition.h
Go to the documentation of this file.
1 /* -*- c++ -*-
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; version 3 of the
9  * License, or any later version.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
26 
27 #ifndef Common_ClusterDefinition_ClusterDefinition_h
28 #define Common_ClusterDefinition_ClusterDefinition_h
29 
30 #include <ctime>
31 #include <mutex>
32 #include <string>
33 #include <unordered_map>
34 #include <vector>
35 
36 namespace Hypertable {
37 namespace ClusterDefinition {
38 
41 
44 
45  public:
46 
49  ClusterDefinition(const std::string &fname) : m_fname(fname) {};
50 
65  void get_role_members(const std::string &role,
66  std::vector<std::string> &members,
67  int64_t *generation = nullptr);
68 
69  private:
70 
74  void load_file();
75 
80  void add_role(const std::string &text);
81 
84 
86  std::string m_fname;
87 
89  time_t m_last_mtime {};
90 
92  std::unordered_map<std::string, std::vector<std::string>> m_roles;
93 
94  };
95 
97 
98 }}
99 
100 #endif // Common_ClusterDefinition_ClusterDefinition_h
static std::mutex mutex
Definition: Logger.cc:43
void add_role(const std::string &text)
Parses a role definition statement Parses the role definition statement contained in text and adds th...
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.
Hypertable definitions
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 reloa...
std::string m_fname
Name of cluster definition file.
time_t m_last_mtime
Last modification time of cluster definition file.
ClusterDefinition(const std::string &fname)
Constructor.
std::unordered_map< std::string, std::vector< std::string > > m_roles
Map from role names to members.
std::mutex m_mutex
Mutex for serializing access to members.