MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Configuration.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 Configuration_H
19 #define Configuration_H
20 
21 #include <ndb_global.h>
22 
23 #include <util/BaseString.hpp>
24 #include <mgmapi.h>
25 #include <kernel_types.h>
26 #include <NdbMutex.h>
27 #include <NdbThread.h>
28 #include <util/SparseBitmask.hpp>
29 #include <util/UtilBuffer.hpp>
30 #include "mt_thr_config.hpp"
31 
32 enum ThreadTypes
33 {
34  WatchDogThread = 1,
35  SocketServerThread = 2,
36  SocketClientThread = 3,
37  NdbfsThread = 4,
38  MainThread = 5,
39  NotInUse = 6
40 };
41 
42 #define MAX_NDB_THREADS 256
43 #define NO_LOCK_CPU 0x10000
44 
45 struct ThreadInfo
46 {
47  enum ThreadTypes type;
48  struct NdbThread* pThread;
49 };
50 
51 class ConfigRetriever;
52 
54 public:
55  Configuration();
56  ~Configuration();
57 
58  bool init(int _no_start, int _initial,
59  int _initialstart);
60 
61 
62  void fetch_configuration(const char* _connect_string, int force_nodeid,
63  const char* _bind_adress,
64  NodeId allocated_nodeid);
65  void setupConfiguration();
66  void closeConfiguration(bool end_session= true);
67 
68  Uint32 lockPagesInMainMemory() const;
69 
70  int schedulerExecutionTimer() const;
71  void schedulerExecutionTimer(int value);
72 
73  int schedulerSpinTimer() const;
74  void schedulerSpinTimer(int value);
75 
76  bool realtimeScheduler() const;
77  void realtimeScheduler(bool realtime_on);
78 
79  Uint32 executeLockCPU() const;
80  void executeLockCPU(Uint32 value);
81 
82  Uint32 maintLockCPU() const;
83  void maintLockCPU(Uint32 value);
84 
85  void setAllRealtimeScheduler();
86  void setAllLockCPU(bool exec_thread);
87  int setLockCPU(NdbThread*, enum ThreadTypes type);
88  int setRealtimeScheduler(NdbThread*,
89  enum ThreadTypes type,
90  bool real_time,
91  bool init);
92  Uint32 addThread(struct NdbThread*, enum ThreadTypes type);
93  void removeThreadId(Uint32 index);
94  void yield_main(Uint32 thread_index, bool start);
95  void initThreadArray();
96 
97  int timeBetweenWatchDogCheck() const ;
98  void timeBetweenWatchDogCheck(int value);
99 
100  int maxNoOfErrorLogs() const ;
101  void maxNoOfErrorLogs(int val);
102 
103  bool stopOnError() const;
104  void stopOnError(bool val);
105 
106  int getRestartOnErrorInsert() const;
107  void setRestartOnErrorInsert(int);
108 
109  // Cluster configuration
110  const char * fileSystemPath() const;
111  const char * backupFilePath() const;
112 
113  bool getInitialStart() const { return _initialStart; }
114 
115  const ndb_mgm_configuration_iterator * getOwnConfigIterator() const;
116 
117  ConfigRetriever* get_config_retriever() { return m_config_retriever; };
118 
119  class LogLevel * m_logLevel;
120  ndb_mgm_configuration_iterator * getClusterConfigIterator() const;
121 
122  ndb_mgm_configuration* getClusterConfig() const { return m_clusterConfig; }
123  Uint32 get_config_generation() const;
124 
125  THRConfigApplier m_thr_config;
126 private:
127  friend class Cmvmi;
128  friend class Qmgr;
129 
130  Uint32 _stopOnError;
131  Uint32 m_restartOnErrorInsert;
132  Uint32 _maxErrorLogs;
133  Uint32 _lockPagesInMainMemory;
134  Uint32 _timeBetweenWatchDogCheck;
135  Uint32 _schedulerExecutionTimer;
136  Uint32 _schedulerSpinTimer;
137  Uint32 _realtimeScheduler;
138  Uint32 _timeBetweenWatchDogCheckInitial;
139 
140  Vector<struct ThreadInfo> threadInfo;
141  NdbMutex *threadIdMutex;
142 
143  ndb_mgm_configuration * m_ownConfig;
144  ndb_mgm_configuration * m_clusterConfig;
145  UtilBuffer m_clusterConfigPacked;
146 
147  ndb_mgm_configuration_iterator * m_clusterConfigIter;
148  ndb_mgm_configuration_iterator * m_ownConfigIterator;
149 
150  ConfigRetriever *m_config_retriever;
151 
155  char * _fsPath;
156  char * _backupPath;
157  bool _initialStart;
158 
159  void calcSizeAlt(class ConfigValues * );
160 };
161 
162 inline
163 const char *
164 Configuration::fileSystemPath() const {
165  return _fsPath;
166 }
167 
168 inline
169 const char *
170 Configuration::backupFilePath() const {
171  return _backupPath;
172 }
173 
174 #endif