MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ConfigInfo.hpp
1 /*
2  Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; version 2 of the License.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #ifndef ConfigInfo_H
19 #define ConfigInfo_H
20 
21 #ifndef NDB_MGMAPI
22 #include <kernel_types.h>
23 #include <Properties.hpp>
24 #include <ndb_limits.h>
25 #include <NdbOut.hpp>
26 #include "InitConfigFileParser.hpp"
27 #endif /* NDB_MGMAPI */
28 
29 // Parameter must be specified in config file
30 #define MANDATORY ((char*)~(UintPtr)0)
31 
38 class ConfigInfo {
39 public:
40  enum Type { CI_BOOL,
41  CI_INT,
42  CI_INT64,
43  CI_STRING,
44  CI_ENUM, // String externaly, int internally
45  CI_BITMASK, // String both externally and internally
46  CI_SECTION
47  };
48  enum Status { CI_USED,
53  };
54 
55  enum Flags {
56  CI_ONLINE_UPDATEABLE = 1, // Parameter can be updated online
57  CI_CHECK_WRITABLE = 2, // Path given by parameter should be writable
58 
59  /*
60  Flags telling how the system must be restarted for a changed
61  parameter to take effect
62 
63  Default is none of these flags set, which means node restart
64  of one node at a time for the setting to take effect
65 
66  CS_RESTART_INITIAL
67  Each data node need to be restarted one at a time with --initial
68 
69  CS_RESTART_SYSTEM
70  The whole system need to be stopped and then started up again
71 
72  CS_RESTART_SYSTEM + CS_RESTART_INITIAL
73  The whole system need to be stopped and then restarted with --initial
74  thus destroying any data in the cluster
75 
76  These flags can not be combined with CI_ONLINE_UPDATABLE flag which
77  indicates that the parameter can be changed online without
78  restarting anything
79  */
80  CI_RESTART_SYSTEM = 4, // System restart is necessary to apply setting
81  CI_RESTART_INITIAL = 8 // Initial restart is necessary to apply setting
82  };
83 
84  struct Typelib {
85  const char* name;
86  Uint32 value;
87  };
88 
92  struct ParamInfo {
97  Uint32 _paramId;
98  /* External name, as given in text in config file. */
99  const char* _fname;
107  const char* _section;
108  /* Short textual description/documentation for entry. */
109  const char* _description;
110  Status _status;
111  Uint32 _flags;
112  Type _type;
121  const char* _default;
122  const char* _min;
123  const char* _max;
124  };
125 
129  static Uint32 getSectionType(const ParamInfo& p) {
130  assert(p._type == CI_SECTION);
131  return Uint32(reinterpret_cast<UintPtr>(p._default));
132  }
133 
137  static const Typelib* getTypelibPtr(const ParamInfo& p) {
138  assert(p._type == CI_ENUM);
139  return reinterpret_cast<const Typelib*>(p._min);
140  }
141 
143  const ConfigInfo& m_info;
144  const char* m_section_name;
145  int m_curr_param;
146  public:
147  ParamInfoIter(const ConfigInfo& info,
148  Uint32 section,
149  Uint32 section_type = ~0);
150 
151  const ParamInfo* next(void);
152  };
153 
154 #ifndef NDB_MGMAPI
155  struct AliasPair{
156  const char * name;
157  const char * alias;
158  };
159 
163  struct SectionRule {
164  const char * m_section;
165  bool (* m_sectionRule)(struct InitConfigFileParser::Context &,
166  const char * m_ruleData);
167  const char * m_ruleData;
168  };
169 
174  BaseString m_sectionType;
175  Properties * m_sectionData;
176  };
177 
178  struct ConfigRule {
179  bool (* m_configRule)(Vector<ConfigRuleSection>&,
181  const char * m_ruleData);
182  const char * m_ruleData;
183  };
184 
185  ConfigInfo();
186 
198  bool verify(const Properties* secti, const char* fname, Uint64 value) const;
199  bool verify_enum(const Properties * section, const char* fname,
200  const char* value, Uint32& value_int) const;
201  void get_enum_values(const Properties * section, const char* fname,
202  BaseString& err) const;
203  static const char* nameToAlias(const char*);
204  static const char* getAlias(const char*);
205  bool isSection(const char*) const;
206 
207  const char* getDescription(const Properties * sec, const char* fname) const;
208  Type getType(const Properties * section, const char* fname) const;
209  Status getStatus(const Properties* section, const char* fname) const;
210  Uint64 getMin(const Properties * section, const char* fname) const;
211  Uint64 getMax(const Properties * section, const char* fname) const;
212  Uint64 getDefault(const Properties * section, const char* fname) const;
213  Uint32 getFlags(const Properties* section, const char* fname) const;
214  const char* getDefaultString(const Properties * section,
215  const char* fname) const;
216  bool getMandatory(const Properties * section, const char* fname) const;
217  bool hasDefault(const Properties * section, const char* fname) const;
218 
219  const Properties * getInfo(const char * section) const;
220  const Properties * getDefaults(const char * section) const;
221 
222  const char* sectionName(Uint32 section_type, Uint32 type) const;
223 
224  void print(const char* section= NULL) const;
225  void print_xml(const char* section= NULL) const;
226 private:
227  bool is_internal_section(const Properties* sec) const;
228  void print_impl(const char* section,
229  class ConfigPrinter& printer) const;
230 private:
231  Properties m_info;
232  Properties m_systemDefaults;
233 
234  static const AliasPair m_sectionNameAliases[];
235  static const char* m_sectionNames[];
236  static const int m_noOfSectionNames;
237 #endif /* NDB_MGMAPI */
238 
239 public:
240  static const ParamInfo m_ParamInfo[];
241  static const int m_NoOfParams;
242 
243 #ifndef NDB_MGMAPI
244  static const SectionRule m_SectionRules[];
245  static const ConfigRule m_ConfigRules[];
246  static const int m_NoOfRules;
247 #endif /* NDB_MGMAPI */
248 };
249 
250 #endif // ConfigInfo_H