~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to storage/ndb/src/mgmsrv/ConfigInfo.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2003 MySQL AB
 
2
 
 
3
   This program is free software; you can redistribute it and/or modify
 
4
   it under the terms of the GNU General Public License as published by
 
5
   the Free Software Foundation; version 2 of the License.
 
6
 
 
7
   This program is distributed in the hope that it will be useful,
 
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
   GNU General Public License for more details.
 
11
 
 
12
   You should have received a copy of the GNU General Public License
 
13
   along with this program; if not, write to the Free Software
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
 
 
16
#ifndef ConfigInfo_H
 
17
#define ConfigInfo_H
 
18
 
 
19
#ifndef NDB_MGMAPI
 
20
#include <kernel_types.h>
 
21
#include <Properties.hpp>
 
22
#include <ndb_limits.h>
 
23
#include <NdbOut.hpp>
 
24
#include "InitConfigFileParser.hpp"
 
25
#endif /* NDB_MGMAPI */
 
26
 
 
27
/**
 
28
 * A MANDATORY parameters must be specified in the config file
 
29
 * An UNDEFINED parameter may or may not be specified in the config file
 
30
 */
 
31
 
 
32
// Default value for mandatory params.
 
33
#define MANDATORY ((char*)~(UintPtr)0)
 
34
// Default value for undefined params.
 
35
#define UNDEFINED ((char*) 0)
 
36
 
 
37
/**
 
38
 * @class  ConfigInfo
 
39
 * @brief  Metainformation about ALL cluster configuration parameters 
 
40
 *
 
41
 * Use the getters to find out metainformation about parameters.
 
42
 */
 
43
class ConfigInfo {
 
44
public:
 
45
  enum Type        { CI_BOOL, CI_INT, CI_INT64, CI_STRING, CI_SECTION };
 
46
  enum Status      { CI_USED,            ///< Active
 
47
                     CI_DEPRICATED,      ///< Can be, but shouldn't
 
48
                     CI_NOTIMPLEMENTED,  ///< Is ignored.
 
49
                     CI_INTERNAL         ///< Not configurable by the user
 
50
  };
 
51
 
 
52
  /**
 
53
   *   Entry for one configuration parameter
 
54
   */
 
55
  struct ParamInfo {
 
56
    Uint32         _paramId;
 
57
    const char*    _fname;   
 
58
    const char*    _section;
 
59
    const char*    _description;
 
60
    Status         _status;
 
61
    bool           _updateable;    
 
62
    Type           _type;          
 
63
    const char*    _default;
 
64
    const char*    _min;
 
65
    const char*    _max;
 
66
  };
 
67
 
 
68
#ifndef NDB_MGMAPI
 
69
  struct AliasPair{
 
70
    const char * name;
 
71
    const char * alias;
 
72
  };
 
73
 
 
74
  /**
 
75
   * Entry for one section rule
 
76
   */
 
77
  struct SectionRule {
 
78
    const char * m_section;
 
79
    bool (* m_sectionRule)(struct InitConfigFileParser::Context &, 
 
80
                           const char * m_ruleData);
 
81
    const char * m_ruleData;
 
82
  };
 
83
  
 
84
  /**
 
85
   * Entry for config rule
 
86
   */
 
87
  struct ConfigRuleSection {
 
88
    BaseString m_sectionType;
 
89
    Properties * m_sectionData;
 
90
  };
 
91
 
 
92
  struct ConfigRule {
 
93
    bool (* m_configRule)(Vector<ConfigRuleSection>&, 
 
94
                          struct InitConfigFileParser::Context &, 
 
95
                          const char * m_ruleData);
 
96
    const char * m_ruleData;
 
97
  };
 
98
  
 
99
  ConfigInfo();
 
100
 
 
101
  /**
 
102
   *   Checks if the suggested value is valid for the suggested parameter
 
103
   *   (i.e. if it is >= than min and <= than max).
 
104
   *
 
105
   *   @param  section  Init Config file section name
 
106
   *   @param  fname    Name of parameter
 
107
   *   @param  value    Value to check
 
108
   *   @return true if parameter value is valid.
 
109
   * 
 
110
   *   @note Result is not defined if section/name are wrong!
 
111
   */
 
112
  bool verify(const Properties* secti, const char* fname, Uint64 value) const;
 
113
  static const char* nameToAlias(const char*);
 
114
  static const char* getAlias(const char*);
 
115
  bool isSection(const char*) const;
 
116
 
 
117
  const char*  getDescription(const Properties * sec, const char* fname) const;
 
118
  Type         getType(const Properties * section, const char* fname) const;
 
119
  Status       getStatus(const Properties* section, const char* fname) const;
 
120
  Uint64       getMin(const Properties * section, const char* fname) const;
 
121
  Uint64       getMax(const Properties * section, const char* fname) const;
 
122
  Uint64       getDefault(const Properties * section, const char* fname) const;
 
123
  
 
124
  const Properties * getInfo(const char * section) const;
 
125
  const Properties * getDefaults(const char * section) const;
 
126
  
 
127
  void print() const;
 
128
  void print(const char* section) const;
 
129
  void print(const Properties * section, const char* parameter) const;
 
130
 
 
131
private:
 
132
  Properties               m_info;
 
133
  Properties               m_systemDefaults;
 
134
 
 
135
  static const AliasPair   m_sectionNameAliases[];
 
136
  static const char*       m_sectionNames[];
 
137
  static const int         m_noOfSectionNames;
 
138
#endif /* NDB_MGMAPI */
 
139
 
 
140
public:
 
141
  static const ParamInfo   m_ParamInfo[];
 
142
  static const int         m_NoOfParams;
 
143
  
 
144
#ifndef NDB_MGMAPI
 
145
  static const SectionRule m_SectionRules[];
 
146
  static const ConfigRule  m_ConfigRules[];
 
147
  static const int         m_NoOfRules;
 
148
#endif /* NDB_MGMAPI */
 
149
};
 
150
 
 
151
#endif // ConfigInfo_H