MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ConfigRetriever.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 ConfigRetriever_H
19 #define ConfigRetriever_H
20 
21 #include <ndb_types.h>
22 #include <mgmapi.h>
23 #include <BaseString.hpp>
24 
30 public:
31  ConfigRetriever(const char * _connect_string, int force_nodeid,
32  Uint32 version, ndb_mgm_node_type nodeType,
33  const char * _bind_address = 0,
34  int timeout_ms = 30000);
35  ~ConfigRetriever();
36 
37  int do_connect(int no_retries, int retry_delay_in_seconds, int verbose);
38  int disconnect();
39  bool is_connected();
40 
52  struct ndb_mgm_configuration * getConfig(Uint32 nodeid);
53 
54  void resetError();
55  int hasError();
56  const char * getErrorString();
57 
61  Uint32 allocNodeId(int no_retries, int retry_delay_in_seconds);
62 
63  int setNodeId(Uint32 nodeid);
64 
69 
73  struct ndb_mgm_configuration * getConfig(const char * file);
74 
78  bool verifyConfig(const struct ndb_mgm_configuration *, Uint32 nodeid);
79 
80  Uint32 get_mgmd_port() const;
81  const char *get_mgmd_host() const;
82  const char *get_connectstring(char *buf, int buf_sz) const;
83  NdbMgmHandle get_mgmHandle() { return m_handle; };
84  NdbMgmHandle* get_mgmHandlePtr() { return &m_handle; };
85  void end_session(bool end) { m_end_session= end; };
86 
87  Uint32 get_configuration_nodeid() const;
88 private:
89  BaseString errorString;
90  enum ErrorType {
91  CR_NO_ERROR = 0,
92  CR_ERROR = 1
93  };
94  ErrorType latestErrorType;
95 
96  void setError(ErrorType, const char * errorMsg);
97  void setError(ErrorType, BaseString err);
98 
99  bool m_end_session;
100  Uint32 m_version;
101  ndb_mgm_node_type m_node_type;
102  NdbMgmHandle m_handle;
103 };
104 
105 #endif
106 
107