Configuration.hpp 3.52 KB
Newer Older
1 2 3 4
/* Copyright (C) 2003 MySQL AB

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
unknown's avatar
unknown committed
5
   the Free Software Foundation; version 2 of the License.
6 7 8 9 10 11 12 13 14 15 16 17 18

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */

#ifndef Configuration_H
#define Configuration_H

19
#include <util/BaseString.hpp>
20 21
#include <mgmapi.h>
#include <ndb_types.h>
22

23 24
class ConfigRetriever;

25 26 27 28 29 30 31 32
class Configuration {
public:
  Configuration();
  ~Configuration();

  /**
   * Returns false if arguments are invalid
   */
33
  bool init(int argc, char** argv);
34

35
  void fetch_configuration();
36
  void setupConfiguration();
37
  void closeConfiguration(bool end_session= true);
38
  
unknown's avatar
unknown committed
39
  Uint32 lockPagesInMainMemory() const;
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
  
  int timeBetweenWatchDogCheck() const ;
  void timeBetweenWatchDogCheck(int value);
  
  int maxNoOfErrorLogs() const ;
  void maxNoOfErrorLogs(int val);

  bool stopOnError() const;
  void stopOnError(bool val);
  
  int getRestartOnErrorInsert() const;
  void setRestartOnErrorInsert(int);
  
  // Cluster configuration
  const char * programName() const;
  const char * fileSystemPath() const;
unknown's avatar
unknown committed
56
  const char * backupFilePath() const;
57
  const char * getConnectString() const;
58 59 60 61 62 63
  char * getConnectStringCopy() const;

  /**
   * 
   */
  bool getInitialStart() const;
64
  void setInitialStart(bool val);
65
  bool getDaemonMode() const;
66
  bool getForegroundMode() const;
67 68 69

  const ndb_mgm_configuration_iterator * getOwnConfigIterator() const;

70
  Uint32 get_mgmd_port() const {return m_mgmd_port;};
71
  const char *get_mgmd_host() const {return m_mgmd_host.c_str();};
unknown's avatar
unknown committed
72
  ConfigRetriever* get_config_retriever() { return m_config_retriever; };
73

74
  class LogLevel * m_logLevel;
75
private:
76 77
  friend class Cmvmi;
  friend class Qmgr;
unknown's avatar
unknown committed
78 79
  friend int reportShutdown(class Configuration *config, int error, int restart);

80 81
  ndb_mgm_configuration_iterator * getClusterConfigIterator() const;

82 83 84 85 86 87
  Uint32 _stopOnError;
  Uint32 m_restartOnErrorInsert;
  Uint32 _maxErrorLogs;
  Uint32 _lockPagesInMainMemory;
  Uint32 _timeBetweenWatchDogCheck;

88 89
  ndb_mgm_configuration * m_ownConfig;
  ndb_mgm_configuration * m_clusterConfig;
90

91 92
  ndb_mgm_configuration_iterator * m_clusterConfigIter;
  ndb_mgm_configuration_iterator * m_ownConfigIterator;
93
  
94 95
  ConfigRetriever *m_config_retriever;

unknown's avatar
unknown committed
96 97
  Vector<BaseString> m_mgmds;

98 99 100 101 102
  /**
   * arguments to NDB process
   */
  char * _programName;
  char * _fsPath;
unknown's avatar
unknown committed
103
  char * _backupPath;
104 105
  bool _initialStart;
  char * _connectString;
106
  Uint32 m_mgmd_port;
107
  BaseString m_mgmd_host;
108 109
  bool _daemonMode; // if not, angel in foreground
  bool _foregroundMode; // no angel, raw ndbd in foreground
110 111

  void calcSizeAlt(class ConfigValues * );
112 113 114 115 116 117 118 119 120 121 122 123 124 125
};

inline
const char *
Configuration::programName() const {
  return _programName;
}

inline
const char *
Configuration::fileSystemPath() const {
  return _fsPath;
}

unknown's avatar
unknown committed
126 127 128 129 130 131
inline
const char *
Configuration::backupFilePath() const {
  return _backupPath;
}

132 133 134 135 136 137 138 139 140 141 142 143
inline
bool
Configuration::getInitialStart() const {
  return _initialStart;
}

inline
bool
Configuration::getDaemonMode() const {
  return _daemonMode;
}

144 145 146 147 148 149
inline
bool
Configuration::getForegroundMode() const {
  return _foregroundMode;
}

150
#endif